53 use precon,
only :
pc_t, precon_factory, precon_destroy
62 use json_module,
only : json_file
67 use mpi_f08,
only : mpi_integer, mpi_sum
85 character(len=:),
allocatable :: name
111 integer :: ksp_maxiter
113 integer :: projection_dim
115 integer :: projection_activ_step
121 type(json_file),
pointer :: params
127 character(len=:),
allocatable :: nut_field_name
135 type(
field_t),
pointer :: lambda_tot => null()
137 real(kind=
rp) :: pr_turb
141 user_material_properties => null()
150 procedure, pass(this) :: set_material_properties => &
153 procedure, pass(this) :: update_material_properties => &
168 numerics_params, user, chkp, ulag, vlag, wlag, time_scheme, rho)
180 type(
mesh_t),
target,
intent(in) :: msh
181 type(
coef_t),
target,
intent(in) :: coef
182 type(
gs_t),
target,
intent(inout) :: gs
183 type(json_file),
target,
intent(inout) :: params
184 type(json_file),
target,
intent(inout) :: numerics_params
185 type(
user_t),
target,
intent(in) :: user
186 type(
chkp_t),
target,
intent(inout) :: chkp
189 type(
field_t),
target,
intent(in) :: rho
200 type(
chkp_t),
intent(inout) :: chkp
242 type(
mesh_t),
target,
intent(in) :: msh
243 type(
coef_t),
target,
intent(in) :: c_Xh
244 type(
gs_t),
target,
intent(inout) :: gs_Xh
245 type(json_file),
target,
intent(inout) :: params
246 character(len=*),
intent(in) :: scheme
247 type(
user_t),
target,
intent(in) :: user
248 type(
field_t),
target,
intent(in) :: rho
250 character(len=LOG_SIZE) :: log_buf
252 logical :: logical_val
253 real(kind=
rp) :: real_val, solver_abstol
254 integer :: integer_val, ierr
255 character(len=:),
allocatable :: solver_type, solver_precon
256 type(json_file) :: precon_params
257 real(kind=
rp) :: gjp_param_a, gjp_param_b
267 call json_get(params,
'name', this%name)
270 call json_get(params,
'solver.type', solver_type)
271 call json_get(params,
'solver.preconditioner.type', &
274 call json_get(params,
'solver.absolute_tolerance', &
278 'solver.projection_space_size', &
279 this%projection_dim, 0)
281 'solver.projection_hold_steps', &
282 this%projection_activ_step, 5)
285 write(log_buf,
'(A, A)')
'Type : ', trim(scheme)
287 write(log_buf,
'(A, A)')
'Name : ', trim(this%name)
289 call neko_log%message(
'Ksp scalar : ('// trim(solver_type) // &
290 ', ' // trim(solver_precon) //
')')
291 write(log_buf,
'(A,ES13.6)')
' `-abs tol :', solver_abstol
295 this%dm_Xh => this%u%dof
296 this%params => params
300 ignore_existing = .true.)
304 call this%slag%init(this%s, 2)
312 call this%set_material_properties(params,
user)
318 if (params%valid_path(
'nut_field'))
then
319 call json_get(params,
'Pr_t', this%pr_turb)
320 call json_get(params,
'nut_field', this%nut_field_name)
322 this%nut_field_name =
""
329 call this%f_Xh%init(this%dm_Xh, fld_name =
"scalar_rhs")
332 call this%source_term%init(this%f_Xh, this%c_Xh,
user, this%name)
333 call this%source_term%add(params,
'source_terms')
337 'solver.max_iterations', &
341 logical_val, .false.)
343 solver_type, integer_val, solver_abstol, logical_val)
345 this%c_Xh, this%dm_Xh, this%gs_Xh, this%bcs, &
346 solver_precon, precon_params)
363 if (
allocated(this%ksp))
then
368 if (
allocated(this%pc))
then
369 call precon_destroy(this%pc)
373 if (
allocated(this%name))
then
374 deallocate(this%name)
377 call this%source_term%free()
380 call this%slag%free()
384 nullify(this%lambda_tot)
393 if ( (.not.
allocated(this%u%x)) .or. &
394 (.not.
allocated(this%v%x)) .or. &
395 (.not.
allocated(this%w%x)) .or. &
396 (.not.
allocated(this%s%x)))
then
400 if (.not.
allocated(this%ksp))
then
401 call neko_error(
'No Krylov solver for velocity defined')
404 if (.not.
associated(this%Xh))
then
408 if (.not.
associated(this%dm_Xh))
then
412 if (.not.
associated(this%c_Xh))
then
416 if (.not.
associated(this%f_Xh))
then
420 if (.not.
associated(this%params))
then
424 if (.not.
associated(this%rho))
then
434 class(
ksp_t),
allocatable,
target,
intent(inout) :: ksp
435 integer,
intent(in),
value :: n
436 integer,
intent(in) :: max_iter
437 character(len=*),
intent(in) :: solver
438 real(kind=
rp) :: abstol
439 logical,
intent(in) :: monitor
441 call krylov_solver_factory(ksp, n, solver, max_iter, &
442 abstol, monitor = monitor)
449 class(
pc_t),
allocatable,
target,
intent(inout) :: pc
450 class(
ksp_t),
target,
intent(inout) :: ksp
451 type(
coef_t),
target,
intent(in) :: coef
452 type(
dofmap_t),
target,
intent(in) :: dof
453 type(
gs_t),
target,
intent(inout) :: gs
454 type(
bc_list_t),
target,
intent(inout) :: bclst
455 character(len=*) :: pctype
456 type(json_file),
intent(inout) :: pcparams
458 call precon_factory(pc, pctype)
460 select type (pcp => pc)
462 call pcp%init(coef, dof, gs)
464 call pcp%init(coef, dof, gs)
466 call pcp%init(coef, dof, gs)
468 call pcp%init(coef, bclst, pcparams)
485 type(
field_t),
pointer :: lambda_factor
487 call this%user_material_properties(this%name, this%material_properties, &
491 if (len(trim(this%nut_field_name)) > 0)
then
496 call field_col3(lambda_factor, this%cp, this%rho)
497 call field_cmult2(lambda_factor, nut, 1.0_rp / this%pr_turb)
498 call field_add3(this%lambda_tot, this%lambda, lambda_factor)
518 type(json_file),
intent(inout) :: params
519 type(
user_t),
target,
intent(in) :: user
520 character(len=LOG_SIZE) :: log_buf
523 real(kind=
rp) :: const_cp, const_lambda
538 call this%material_properties%init(2)
539 call this%material_properties%assign(1, this%cp)
540 call this%material_properties%assign(2, this%lambda)
542 if (.not.
associated(
user%material_properties, dummy_mp_ptr))
then
544 write(log_buf,
'(A)')
"Material properties must be set in the user " // &
547 this%user_material_properties =>
user%material_properties
549 call user%material_properties(this%name, this%material_properties, time)
552 if (params%valid_path(
'Pe') .and. &
553 (params%valid_path(
'lambda') .or. &
554 params%valid_path(
'cp')))
then
555 call neko_error(
"To set the material properties for the scalar, " // &
556 "either provide Pe OR lambda and cp in the case file.")
558 else if (params%valid_path(
'Pe'))
then
559 write(log_buf,
'(A)')
'Non-dimensional scalar material properties' //&
562 write(log_buf,
'(A)')
'Specific heat capacity will be set to 1,'
564 write(log_buf,
'(A)')
'conductivity to 1/Pe. Assumes density is 1.'
568 call json_get(params,
'Pe', const_lambda)
569 write(log_buf,
'(A,ES13.6)')
'Pe :', const_lambda
575 const_lambda = 1.0_rp/const_lambda
578 call json_get(params,
'lambda', const_lambda)
579 call json_get(params,
'cp', const_cp)
584 if (
associated(
user%material_properties, dummy_mp_ptr))
then
589 write(log_buf,
'(A,ES13.6)')
'lambda :', const_lambda
591 write(log_buf,
'(A,ES13.6)')
'cp :', const_cp
Copy data between host and device (or device and device)
Abstract interface defining a dirichlet condition on a list of fields.
Retrieves a parameter by name or assigns a provided default value. In the latter case also adds the m...
Retrieves a parameter by name or throws an error.
Abstract interface to dealocate a scalar formulation.
Abstract interface to initialize a scalar formulation.
Abstract interface to restart a scalar formulation.
Abstract interface to compute a time-step.
Abstract interface for setting material properties.
Defines a boundary condition.
type(mpi_comm), public neko_comm
MPI communicator.
Jacobi preconditioner accelerator backend.
subroutine, public device_add2s2(a_d, b_d, c1, n, strm)
Vector addition with scalar multiplication (multiplication on first argument)
subroutine, public device_cfill(a_d, c, n, strm)
Set all elements to a constant c .
Device abstraction, common interface for various accelerators.
integer, parameter, public device_to_host
Defines a dirichlet boundary condition.
Defines a mapping of the degrees of freedom.
Defines a zone as a subset of facets in a mesh.
Defines user dirichlet condition for a scalar field.
subroutine, public field_cmult2(a, b, c, n)
Multiplication by constant c .
subroutine, public field_cfill(a, c, n)
Set all elements to a constant c .
subroutine, public field_col3(a, b, c, n)
Vector multiplication with 3 vectors .
subroutine, public field_copy(a, b, n)
Copy a vector .
subroutine, public field_add3(a, b, c, n)
Vector addition .
Defines a registry for storing solution fields.
type(field_registry_t), target, public neko_field_registry
Global field registry.
Contains the field_serties_t type.
Utilities for retrieving parameters from the case files.
subroutine, public json_extract_object(json, name, object)
Extract object as a separate JSON dictionary.
Implements the base abstract type for Krylov solvers plus helper types.
integer, parameter, public ksp_max_iter
Maximum number of iters.
integer, parameter, public neko_log_verbose
Verbose log level.
type(log_t), public neko_log
Global log stream.
integer, parameter, public log_size
subroutine, public cfill(a, c, n)
Set all elements to a constant c .
subroutine, public add2s2(a, b, c1, n)
Vector addition with scalar multiplication (multiplication on second argument)
integer, parameter, public neko_msh_max_zlbls
Max num. zone labels.
integer, parameter, public neko_msh_max_zlbl_len
Max length of a zone label.
integer, parameter neko_bcknd_device
Defines a Neumann boundary condition.
integer, parameter, public rp
Global precision used in computations.
Contains the scalar_scheme_t type.
subroutine scalar_scheme_init(this, msh, c_xh, gs_xh, params, scheme, user, rho)
Initialize all related components of the current scheme.
subroutine scalar_scheme_precon_factory(pc, ksp, coef, dof, gs, bclst, pctype, pcparams)
Initialize a Krylov preconditioner.
subroutine scalar_scheme_free(this)
Deallocate a scalar formulation.
subroutine scalar_scheme_solver_factory(ksp, n, solver, max_iter, abstol, monitor)
Initialize a linear solver.
subroutine scalar_scheme_validate(this)
Validate that all fields, solvers etc necessary for performing time-stepping are defined.
subroutine scalar_scheme_update_material_properties(this, time)
Call user material properties routine and update the values of lambda if necessary.
subroutine scalar_scheme_set_material_properties(this, params, user)
Set lamdba and cp.
Implements the scalar_source_term_t type.
Defines a registry for storing and requesting temporary fields This can be used when you have a funct...
type(scratch_registry_t), target, public neko_scratch_registry
Global scratch registry.
Implements the source_term_t type and a wrapper source_term_wrapper_t.
Defines a function space.
Jacobi preconditioner SX-Aurora backend.
Compound scheme for the advection and diffusion operators in a transport equation.
Module with things related to the simulation time.
Implements type time_step_controller.
Interfaces for user interaction with NEKO.
subroutine, public dummy_user_material_properties(scheme_name, properties, time)
subroutine, public neko_warning(warning_msg)
Reports a warning to standard output.
Base type for a boundary condition.
A list of allocatable `bc_t`. Follows the standard interface of lists.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Defines a jacobi preconditioner.
Generic Dirichlet boundary condition on .
User defined dirichlet condition, for which the user can work with an entire field....
field_list_t, To be able to group fields together
Stores a series (sequence) of fields, logically connected to a base field, and arranged according to ...
Defines a jacobi preconditioner.
Type for storing initial and final residuals in a Krylov solver.
Base abstract type for a canonical Krylov method, solving .
A Neumann boundary condition for scalar fields. Sets the flux of the field to the chosen value.
Defines a canonical Krylov preconditioner.
Base type for a scalar advection-diffusion solver.
Wrapper contaning and executing the scalar source terms.
The function space for the SEM solution fields.
Defines a jacobi preconditioner for SX-Aurora.
Implements the logic to compute the time coefficients for the advection and diffusion operators in a ...
A struct that contains all info about the time, expand as needed.
Provides a tool to set time step dt.
A type collecting all the overridable user routines and flag to suppress type injection from custom m...