52 use precon,
only :
pc_t, precon_allocator, precon_destroy
59 use json_module,
only : json_file
79 character(len=:),
allocatable :: name
95 type(
gs_t),
pointer :: gs_xh
105 integer :: ksp_maxiter
107 integer :: projection_dim
109 integer :: projection_activ_step
115 type(json_file),
pointer :: params => null()
121 character(len=:),
allocatable :: nut_field_name
123 character(len=:),
allocatable :: alphat_field_name
131 type(
field_t),
pointer :: lambda_tot => null()
133 real(kind=
rp) :: pr_turb
137 user_material_properties => null()
139 logical :: freeze = .false.
141 logical :: svv_enabled = .false.
152 procedure, pass(this) :: set_initial_condition => &
155 procedure, pass(this) :: register_checkpoint => &
158 procedure, pass(this) :: set_material_properties => &
161 procedure, pass(this) :: update_material_properties => &
176 numerics_params, user, chkp, ulag, vlag, wlag, time_scheme, rho)
188 type(
mesh_t),
target,
intent(in) :: msh
189 type(
coef_t),
target,
intent(in) :: coef
190 type(
gs_t),
target,
intent(inout) :: gs
191 type(json_file),
target,
intent(inout) :: params
192 type(json_file),
target,
intent(inout) :: numerics_params
193 type(
user_t),
target,
intent(in) :: user
194 type(
chkp_t),
target,
intent(inout) :: chkp
197 type(
field_t),
target,
intent(in) :: rho
208 type(
chkp_t),
intent(inout) :: chkp
251 procedure, pass(this) :: move_from => &
254 procedure, pass(this) :: is_allocated => &
273 module subroutine scalar_scheme_factory(object, msh, coef, gs, params, &
275 class(scalar_scheme_t),
allocatable,
intent(inout) :: object
276 type(
mesh_t),
target,
intent(in) :: msh
277 type(
coef_t),
target,
intent(in) :: coef
278 type(
gs_t),
target,
intent(inout) :: gs
279 type(json_file),
target,
intent(inout) :: params
280 type(json_file),
target,
intent(inout) :: numerics_params
282 type(
chkp_t),
target,
intent(inout) :: chkp
285 type(
field_t),
target,
intent(in) :: rho
286 end subroutine scalar_scheme_factory
293 module subroutine scalar_scheme_allocator(object, type_name)
294 class(scalar_scheme_t),
allocatable,
intent(inout) :: object
295 character(len=*),
intent(in):: type_name
296 end subroutine scalar_scheme_allocator
307 subroutine scalar_scheme_allocate(obj)
308 import scalar_scheme_t
309 class(scalar_scheme_t),
allocatable,
intent(inout) :: obj
310 end subroutine scalar_scheme_allocate
315 module subroutine register_scalar_scheme(type_name, allocator)
316 character(len=*),
intent(in) :: type_name
317 procedure(scalar_scheme_allocate),
pointer,
intent(in) :: allocator
318 end subroutine register_scalar_scheme
323 type scalar_scheme_allocator_entry
324 character(len=20) :: type_name
325 procedure(scalar_scheme_allocate),
pointer,
nopass :: allocator
326 end type scalar_scheme_allocator_entry
329 type(scalar_scheme_allocator_entry),
allocatable,
private :: &
330 scalar_scheme_registry(:)
333 integer,
private :: scalar_scheme_registry_size = 0
345 subroutine scalar_scheme_init(this, msh, c_Xh, gs_Xh, params, scheme, user, &
347 class(scalar_scheme_t),
target,
intent(inout) :: this
348 type(
mesh_t),
target,
intent(in) :: msh
349 type(
coef_t),
target,
intent(in) :: c_Xh
350 type(
gs_t),
target,
intent(inout) :: gs_Xh
351 type(json_file),
target,
intent(inout) :: params
352 character(len=*),
intent(in) :: scheme
353 type(
user_t),
target,
intent(in) :: user
354 type(
field_t),
target,
intent(in) :: rho
356 character(len=LOG_SIZE) :: log_buf
358 logical :: logical_val
359 real(kind=
rp) :: real_val, solver_abstol
360 integer :: integer_val, ierr
361 character(len=:),
allocatable :: solver_type, solver_precon
362 type(json_file) :: precon_params
363 type(json_file) :: json_subdict
364 logical :: nut_dependency
374 call json_get(params,
'name', this%name)
380 call json_get(params,
'solver.type', solver_type)
381 call json_get(params,
'solver.preconditioner.type', &
383 call json_get(params,
'solver.preconditioner', precon_params)
388 'solver.projection_space_size', &
389 this%projection_dim, 0)
391 'solver.projection_hold_steps', &
392 this%projection_activ_step, 5)
395 write(log_buf,
'(A, A)')
'Type : ', trim(scheme)
397 write(log_buf,
'(A, A)')
'Name : ', trim(this%name)
399 call neko_log%message(
'Ksp scalar : ('// trim(solver_type) // &
400 ', ' // trim(solver_precon) //
')')
401 write(log_buf,
'(A,ES13.6)')
' `-abs tol :', solver_abstol
405 this%dm_Xh => this%u%dof
406 if (
associated(this%params))
then
407 deallocate(this%params)
409 allocate(this%params)
414 ignore_existing = .true.)
418 call this%slag%init(this%s, 2)
426 call this%set_material_properties(params,
user)
431 if (params%valid_path(
'svv'))
then
434 if (this%svv_enabled)
then
436 call this%svv%init(params, this%c_Xh, this%rho)
444 this%alphat_field_name =
""
445 this%nut_field_name =
""
446 if (params%valid_path(
'alphat'))
then
447 call json_get(this%params,
'alphat', json_subdict)
448 call json_get(json_subdict,
'nut_dependency', nut_dependency)
449 if (nut_dependency)
then
451 call json_get(json_subdict,
'nut_field', this%nut_field_name)
453 call json_get(json_subdict,
'alphat_field', this%alphat_field_name)
461 call this%f_Xh%init(this%dm_Xh, fld_name =
"scalar_rhs")
464 call this%source_term%init(this%f_Xh, this%c_Xh,
user, this%name)
465 call this%source_term%add(params,
'source_terms')
469 'solver.max_iterations', &
473 logical_val, .false.)
474 call scalar_scheme_solver_factory(this%ksp, this%dm_Xh%size(), &
475 solver_type, integer_val, solver_abstol, logical_val)
476 call scalar_scheme_precon_factory(this%pc, this%ksp, &
477 this%c_Xh, this%dm_Xh, this%gs_Xh, this%bcs, &
478 solver_precon, precon_params)
482 end subroutine scalar_scheme_init
487 subroutine scalar_scheme_set_initial_condition(this, user, scalar_index)
488 class(scalar_scheme_t),
intent(inout) :: this
489 type(
user_t),
intent(in) :: user
490 integer,
intent(in) :: scalar_index
491 character(len=:),
allocatable :: ic_type
492 type(json_file) :: ic_params
494 call json_get(this%params,
'initial_condition.type', ic_type)
495 call json_get(this%params,
'initial_condition', ic_params)
497 if (trim(ic_type) .ne.
'user')
then
499 ic_params, scalar_index)
501 call set_scalar_ic(this%name, this%s, this%c_Xh, this%gs_Xh, &
502 user%initial_conditions)
505 call ic_params%destroy()
508 end subroutine scalar_scheme_set_initial_condition
512 subroutine scalar_scheme_register_checkpoint(this, chkp)
513 class(scalar_scheme_t),
target,
intent(inout) :: this
514 type(
chkp_t),
intent(inout) :: chkp
517 payload => chkp%add_payload(
"scalars/" // trim(this%name))
518 call payload%add_field(this%s)
519 call payload%add_series(this%slag)
521 end subroutine scalar_scheme_register_checkpoint
525 subroutine scalar_scheme_free(this)
526 class(scalar_scheme_t),
intent(inout) :: this
527 class(
bc_t),
pointer :: bc
532 if (
allocated(this%svv))
then
536 this%svv_enabled = .false.
542 if (
associated(this%params))
then
543 deallocate(this%params)
547 if (
allocated(this%ksp))
then
552 if (
allocated(this%pc))
then
553 call precon_destroy(this%pc)
557 if (
allocated(this%name))
then
558 deallocate(this%name)
561 call this%source_term%free()
563 if (
associated(this%f_Xh))
then
564 call this%f_Xh%free()
565 deallocate(this%f_Xh)
568 do i = 1, this%bcs%size()
569 bc => this%bcs%get(i)
570 if (
associated(
bc))
then
577 call this%slag%free()
578 call this%material_properties%free()
580 if (
allocated(this%nut_field_name))
then
581 deallocate(this%nut_field_name)
584 if (
allocated(this%alphat_field_name))
then
585 deallocate(this%alphat_field_name)
590 nullify(this%lambda_tot)
593 end subroutine scalar_scheme_free
597 subroutine scalar_scheme_validate(this)
598 class(scalar_scheme_t),
target,
intent(inout) :: this
600 if ( (.not.
allocated(this%u%x)) .or. &
601 (.not.
allocated(this%v%x)) .or. &
602 (.not.
allocated(this%w%x)) .or. &
603 (.not.
allocated(this%s%x)))
then
607 if (.not.
allocated(this%ksp))
then
608 call neko_error(
'No Krylov solver for velocity defined')
611 if (.not.
associated(this%Xh))
then
615 if (.not.
associated(this%dm_Xh))
then
619 if (.not.
associated(this%c_Xh))
then
623 if (.not.
associated(this%f_Xh))
then
627 if (.not.
associated(this%params))
then
631 if (.not.
associated(this%rho))
then
635 end subroutine scalar_scheme_validate
639 subroutine scalar_scheme_solver_factory(ksp, n, solver, max_iter, &
641 class(
ksp_t),
allocatable,
target,
intent(inout) :: ksp
642 integer,
intent(in),
value :: n
643 integer,
intent(in) :: max_iter
644 character(len=*),
intent(in) :: solver
645 real(kind=
rp) :: abstol
646 logical,
intent(in) :: monitor
648 call krylov_solver_factory(ksp, n, solver, max_iter, &
649 abstol, monitor = monitor)
651 end subroutine scalar_scheme_solver_factory
654 subroutine scalar_scheme_precon_factory(pc, ksp, coef, dof, gs, bclst, &
656 class(
pc_t),
allocatable,
target,
intent(inout) :: pc
657 class(
ksp_t),
target,
intent(inout) :: ksp
658 type(
coef_t),
target,
intent(in) :: coef
659 type(
dofmap_t),
target,
intent(in) :: dof
660 type(
gs_t),
target,
intent(inout) :: gs
661 type(
bc_list_t),
target,
intent(inout) :: bclst
662 character(len=*) :: pctype
663 type(json_file),
intent(inout) :: pcparams
665 call precon_allocator(pc, pctype)
667 select type (pcp => pc)
669 call pcp%init(coef, dof, gs)
671 call pcp%init(coef, dof, gs)
673 call pcp%init(coef, dof, gs)
675 call pcp%init(coef, bclst, pcparams)
680 end subroutine scalar_scheme_precon_factory
686 subroutine scalar_scheme_update_material_properties(this, time)
687 class(scalar_scheme_t),
intent(inout) :: this
689 type(
field_t),
pointer :: nut, alphat
692 type(
field_t),
pointer :: lambda_factor
694 call this%user_material_properties(this%name, this%material_properties, &
698 if (len_trim(this%nut_field_name) .gt. 0 &
699 .and. len_trim(this%alphat_field_name) .eq. 0 )
then
704 call field_cmult2(lambda_factor, nut, 1.0_rp / this%pr_turb)
707 call field_add3(this%lambda_tot, this%lambda, lambda_factor)
710 else if (len_trim(this%alphat_field_name) .gt. 0 &
711 .and. len_trim(this%nut_field_name) .eq. 0 )
then
716 call field_col3(lambda_factor, this%cp, alphat)
718 call field_add3(this%lambda_tot, this%lambda, lambda_factor)
721 else if (len_trim(this%alphat_field_name) .gt. 0 &
722 .and. len_trim(this%nut_field_name) .gt. 0 )
then
723 call neko_error(
"Conflicting definition of eddy diffusivity " // &
724 "for the scalar equation")
736 end subroutine scalar_scheme_update_material_properties
741 subroutine scalar_scheme_set_material_properties(this, params, user)
742 class(scalar_scheme_t),
intent(inout) :: this
743 type(json_file),
intent(inout) :: params
744 type(
user_t),
target,
intent(in) :: user
745 character(len=LOG_SIZE) :: log_buf
748 real(kind=
rp) :: const_cp, const_lambda
756 call neko_registry%add_field(this%dm_Xh, this%name //
"_lambda")
757 call neko_registry%add_field(this%dm_Xh, this%name //
"_lambda_tot")
759 this%lambda =>
neko_registry%get_field(this%name //
"_lambda")
760 this%lambda_tot =>
neko_registry%get_field(this%name //
"_lambda_tot")
763 call this%material_properties%init(2)
764 call this%material_properties%assign(1, this%cp)
765 call this%material_properties%assign(2, this%lambda)
767 if (.not.
associated(
user%material_properties, dummy_mp_ptr))
then
769 write(log_buf,
'(A)')
"Material properties must be set in the user " // &
772 this%user_material_properties =>
user%material_properties
774 call user%material_properties(this%name, this%material_properties, time)
777 if (params%valid_path(
'Pe') .and. &
778 (params%valid_path(
'lambda') .or. &
779 params%valid_path(
'cp')))
then
780 call neko_error(
"To set the material properties for the scalar, " // &
781 "either provide Pe OR lambda and cp in the case file.")
783 else if (params%valid_path(
'Pe'))
then
784 write(log_buf,
'(A)')
'Non-dimensional scalar material properties' //&
787 write(log_buf,
'(A)')
'Specific heat capacity will be set to 1, '
789 write(log_buf,
'(A)')
'conductivity to 1/Pe. Assumes density is 1.'
794 write(log_buf,
'(A,ES13.6)')
'Pe :', const_lambda
800 const_lambda = 1.0_rp/const_lambda
809 if (
associated(
user%material_properties, dummy_mp_ptr))
then
814 write(log_buf,
'(A,ES13.6)')
'lambda :', const_lambda
816 write(log_buf,
'(A,ES13.6)')
'cp :', const_cp
831 end subroutine scalar_scheme_set_material_properties
837 subroutine scalar_scheme_wrapper_init(this, msh, coef, gs, params, &
838 numerics_params, user, chkp, ulag, vlag, wlag, time_scheme, rho)
839 class(scalar_scheme_wrapper_t),
intent(inout) :: this
840 type(
mesh_t),
target,
intent(in) :: msh
841 type(
coef_t),
target,
intent(in) :: coef
842 type(
gs_t),
target,
intent(inout) :: gs
843 type(json_file),
target,
intent(inout) :: params
844 type(json_file),
target,
intent(inout) :: numerics_params
845 type(
user_t),
target,
intent(in) :: user
846 type(
chkp_t),
target,
intent(inout) :: chkp
849 type(
field_t),
target,
intent(in) :: rho
852 call scalar_scheme_factory(this%scalar, msh, coef, gs, params, &
855 end subroutine scalar_scheme_wrapper_init
858 subroutine scalar_scheme_wrapper_free(this)
859 class(scalar_scheme_wrapper_t),
intent(inout) :: this
861 if (
allocated(this%scalar))
then
862 call this%scalar%free()
863 deallocate(this%scalar)
866 end subroutine scalar_scheme_wrapper_free
872 subroutine scalar_scheme_wrapper_move_from(this, other)
873 class(scalar_scheme_wrapper_t),
intent(inout) :: this
874 class(scalar_scheme_wrapper_t),
intent(inout) :: other
877 call move_alloc(other%scalar, this%scalar)
879 end subroutine scalar_scheme_wrapper_move_from
883 function scalar_scheme_wrapper_is_allocated(this)
result(is_alloc)
884 class(scalar_scheme_wrapper_t),
intent(in) :: this
886 is_alloc =
allocated(this%scalar)
887 end function scalar_scheme_wrapper_is_allocated
Copy data between host and device (or device and device)
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.
Format-independent checkpoint payloads.
Defines format-independent checkpoint registration and restart state.
Jacobi preconditioner accelerator backend.
Device abstraction, common interface for various accelerators.
integer, parameter, public device_to_host
Defines a mapping of the degrees of freedom.
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.
type(log_t), public neko_log
Global log stream.
integer, parameter, public log_size
integer, parameter neko_bcknd_device
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.
Scalar initial condition.
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.
logical function scalar_scheme_wrapper_is_allocated(this)
Return allocation status.
subroutine scalar_scheme_wrapper_free(this)
Destructor. Just deallocates the pointer.
subroutine scalar_scheme_free(this)
Deallocate a scalar formulation.
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_register_checkpoint(this, chkp)
Register this scalar scheme with the checkpoint.
subroutine scalar_scheme_set_material_properties(this, params, user)
Set lamdba and cp.
subroutine scalar_scheme_wrapper_init(this, msh, coef, gs, params, numerics_params, user, chkp, ulag, vlag, wlag, time_scheme, rho)
Constructor. Initializes the object.
subroutine scalar_scheme_wrapper_move_from(this, other)
Move assignment operator for the wrapper, needed for storing schemes in lists and arrays.
subroutine scalar_scheme_set_initial_condition(this, user, scalar_index)
Set the initial condition.
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.
Data and filter construction for spectral vanishing viscosity.
Jacobi preconditioner SX-Aurora backend.
Compound scheme for the advection and diffusion operators in a transport equation.
Base class for time integration schemes.
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)
Base type for a boundary condition.
A list of allocatable `bc_t`. Follows the standard interface of lists.
Collection of live simulation data registered for checkpointing.
A named collection of live fields to checkpoint together.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Defines a jacobi preconditioner.
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 .
Defines a canonical Krylov preconditioner.
Base type for a scalar advection-diffusion solver.
A helper type that is needed to have an array of polymorphic objects.
Wrapper contaning and executing the scalar source terms.
The function space for the SEM solution fields.
Spectral vanishing viscosity configuration and coefficients.
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...