53 use precon,
only :
pc_t, precon_factory, precon_destroy
61 use json_module,
only : json_file
66 use mpi_f08,
only : mpi_integer, mpi_sum
83 character(len=:),
allocatable :: name
99 type(
gs_t),
pointer :: gs_xh
109 integer :: ksp_maxiter
111 integer :: projection_dim
113 integer :: projection_activ_step
119 type(json_file),
pointer :: params
125 character(len=:),
allocatable :: nut_field_name
127 character(len=:),
allocatable :: alphat_field_name
135 type(
field_t),
pointer :: lambda_tot => null()
137 real(kind=
rp) :: pr_turb
141 user_material_properties => null()
143 logical :: freeze = .false.
152 procedure, pass(this) :: set_material_properties => &
155 procedure, pass(this) :: update_material_properties => &
170 numerics_params, user, chkp, ulag, vlag, wlag, time_scheme, rho)
182 type(
mesh_t),
target,
intent(in) :: msh
183 type(
coef_t),
target,
intent(in) :: coef
184 type(
gs_t),
target,
intent(inout) :: gs
185 type(json_file),
target,
intent(inout) :: params
186 type(json_file),
target,
intent(inout) :: numerics_params
187 type(
user_t),
target,
intent(in) :: user
188 type(
chkp_t),
target,
intent(inout) :: chkp
191 type(
field_t),
target,
intent(in) :: rho
202 type(
chkp_t),
intent(inout) :: chkp
244 type(
mesh_t),
target,
intent(in) :: msh
245 type(
coef_t),
target,
intent(in) :: c_Xh
246 type(
gs_t),
target,
intent(inout) :: gs_Xh
247 type(json_file),
target,
intent(inout) :: params
248 character(len=*),
intent(in) :: scheme
249 type(
user_t),
target,
intent(in) :: user
250 type(
field_t),
target,
intent(in) :: rho
252 character(len=LOG_SIZE) :: log_buf
254 logical :: logical_val
255 real(kind=
rp) :: real_val, solver_abstol
256 integer :: integer_val, ierr
257 character(len=:),
allocatable :: solver_type, solver_precon
258 type(json_file) :: precon_params
259 type(json_file) :: json_subdict
260 logical :: nut_dependency
270 call json_get(params,
'name', this%name)
276 call json_get(params,
'solver.type', solver_type)
277 call json_get(params,
'solver.preconditioner.type', &
279 call json_get(params,
'solver.preconditioner', precon_params)
280 call json_get(params,
'solver.absolute_tolerance', &
284 'solver.projection_space_size', &
285 this%projection_dim, 0)
287 'solver.projection_hold_steps', &
288 this%projection_activ_step, 5)
291 write(log_buf,
'(A, A)')
'Type : ', trim(scheme)
293 write(log_buf,
'(A, A)')
'Name : ', trim(this%name)
295 call neko_log%message(
'Ksp scalar : ('// trim(solver_type) // &
296 ', ' // trim(solver_precon) //
')')
297 write(log_buf,
'(A,ES13.6)')
' `-abs tol :', solver_abstol
301 this%dm_Xh => this%u%dof
302 this%params => params
306 ignore_existing = .true.)
310 call this%slag%init(this%s, 2)
318 call this%set_material_properties(params,
user)
324 this%alphat_field_name =
""
325 this%nut_field_name =
""
326 if (params%valid_path(
'alphat'))
then
327 call json_get(this%params,
'alphat', json_subdict)
328 call json_get(json_subdict,
'nut_dependency', nut_dependency)
329 if (nut_dependency)
then
330 call json_get(json_subdict,
'Pr_t', this%pr_turb)
331 call json_get(json_subdict,
'nut_field', this%nut_field_name)
333 call json_get(json_subdict,
'alphat_field', this%alphat_field_name)
341 call this%f_Xh%init(this%dm_Xh, fld_name =
"scalar_rhs")
344 call this%source_term%init(this%f_Xh, this%c_Xh,
user, this%name)
345 call this%source_term%add(params,
'source_terms')
349 'solver.max_iterations', &
353 logical_val, .false.)
355 solver_type, integer_val, solver_abstol, logical_val)
357 this%c_Xh, this%dm_Xh, this%gs_Xh, this%bcs, &
358 solver_precon, precon_params)
375 if (
allocated(this%ksp))
then
380 if (
allocated(this%pc))
then
381 call precon_destroy(this%pc)
385 if (
allocated(this%name))
then
386 deallocate(this%name)
389 call this%source_term%free()
392 call this%slag%free()
396 nullify(this%lambda_tot)
405 if ( (.not.
allocated(this%u%x)) .or. &
406 (.not.
allocated(this%v%x)) .or. &
407 (.not.
allocated(this%w%x)) .or. &
408 (.not.
allocated(this%s%x)))
then
412 if (.not.
allocated(this%ksp))
then
413 call neko_error(
'No Krylov solver for velocity defined')
416 if (.not.
associated(this%Xh))
then
420 if (.not.
associated(this%dm_Xh))
then
424 if (.not.
associated(this%c_Xh))
then
428 if (.not.
associated(this%f_Xh))
then
432 if (.not.
associated(this%params))
then
436 if (.not.
associated(this%rho))
then
446 class(
ksp_t),
allocatable,
target,
intent(inout) :: ksp
447 integer,
intent(in),
value :: n
448 integer,
intent(in) :: max_iter
449 character(len=*),
intent(in) :: solver
450 real(kind=
rp) :: abstol
451 logical,
intent(in) :: monitor
453 call krylov_solver_factory(ksp, n, solver, max_iter, &
454 abstol, monitor = monitor)
461 class(
pc_t),
allocatable,
target,
intent(inout) :: pc
462 class(
ksp_t),
target,
intent(inout) :: ksp
463 type(
coef_t),
target,
intent(in) :: coef
464 type(
dofmap_t),
target,
intent(in) :: dof
465 type(
gs_t),
target,
intent(inout) :: gs
466 type(
bc_list_t),
target,
intent(inout) :: bclst
467 character(len=*) :: pctype
468 type(json_file),
intent(inout) :: pcparams
470 call precon_factory(pc, pctype)
472 select type (pcp => pc)
474 call pcp%init(coef, dof, gs)
476 call pcp%init(coef, dof, gs)
478 call pcp%init(coef, dof, gs)
480 call pcp%init(coef, bclst, pcparams)
494 type(
field_t),
pointer :: nut, alphat
497 type(
field_t),
pointer :: lambda_factor
499 call this%user_material_properties(this%name, this%material_properties, &
503 if (len_trim(this%nut_field_name) .gt. 0 &
504 .and. len_trim(this%alphat_field_name) .eq. 0 )
then
509 call field_cmult2(lambda_factor, nut, 1.0_rp / this%pr_turb)
512 call field_add3(this%lambda_tot, this%lambda, lambda_factor)
515 else if (len_trim(this%alphat_field_name) .gt. 0 &
516 .and. len_trim(this%nut_field_name) .eq. 0 )
then
521 call field_col3(lambda_factor, this%cp, alphat)
523 call field_add3(this%lambda_tot, this%lambda, lambda_factor)
526 else if (len_trim(this%alphat_field_name) .gt. 0 &
527 .and. len_trim(this%nut_field_name) .gt. 0 )
then
528 call neko_error(
"Conflicting definition of eddy diffusivity " // &
529 "for the scalar equation")
548 type(json_file),
intent(inout) :: params
549 type(
user_t),
target,
intent(in) :: user
550 character(len=LOG_SIZE) :: log_buf
553 real(kind=
rp) :: const_cp, const_lambda
561 call neko_registry%add_field(this%dm_Xh, this%name //
"_lambda")
562 call neko_registry%add_field(this%dm_Xh, this%name //
"_lambda_tot")
564 this%lambda =>
neko_registry%get_field(this%name //
"_lambda")
565 this%lambda_tot =>
neko_registry%get_field(this%name //
"_lambda_tot")
568 call this%material_properties%init(2)
569 call this%material_properties%assign(1, this%cp)
570 call this%material_properties%assign(2, this%lambda)
572 if (.not.
associated(
user%material_properties, dummy_mp_ptr))
then
574 write(log_buf,
'(A)')
"Material properties must be set in the user " // &
577 this%user_material_properties =>
user%material_properties
579 call user%material_properties(this%name, this%material_properties, time)
582 if (params%valid_path(
'Pe') .and. &
583 (params%valid_path(
'lambda') .or. &
584 params%valid_path(
'cp')))
then
585 call neko_error(
"To set the material properties for the scalar, " // &
586 "either provide Pe OR lambda and cp in the case file.")
588 else if (params%valid_path(
'Pe'))
then
589 write(log_buf,
'(A)')
'Non-dimensional scalar material properties' //&
592 write(log_buf,
'(A)')
'Specific heat capacity will be set to 1,'
594 write(log_buf,
'(A)')
'conductivity to 1/Pe. Assumes density is 1.'
598 call json_get(params,
'Pe', const_lambda)
599 write(log_buf,
'(A,ES13.6)')
'Pe :', const_lambda
605 const_lambda = 1.0_rp/const_lambda
608 call json_get(params,
'lambda', const_lambda)
609 call json_get(params,
'cp', const_cp)
614 if (
associated(
user%material_properties, dummy_mp_ptr))
then
619 write(log_buf,
'(A,ES13.6)')
'lambda :', const_lambda
621 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_col2(a, b, n)
Vector multiplication .
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 .
Contains the field_serties_t type.
Utilities for retrieving parameters from the case files.
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.
Defines a registry for storing solution fields.
type(registry_t), target, public neko_registry
Global field registry.
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 objects This can be used when you have a func...
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. Sets the flux of the field to the chosen values.
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...