50 use precon,
only :
pc_t, precon_factory, precon_destroy
57 use json_module,
only : json_file
75 character(len=:),
allocatable :: name
91 type(
gs_t),
pointer :: gs_xh
99 class(
ksp_t),
allocatable :: ksp
101 integer :: ksp_maxiter
103 integer :: projection_dim
105 integer :: projection_activ_step
111 type(json_file),
pointer :: params
117 character(len=:),
allocatable :: nut_field_name
119 character(len=:),
allocatable :: alphat_field_name
127 type(
field_t),
pointer :: lambda_tot => null()
129 real(kind=
rp) :: pr_turb
133 user_material_properties => null()
135 logical :: freeze = .false.
144 procedure, pass(this) :: set_material_properties => &
147 procedure, pass(this) :: update_material_properties => &
162 numerics_params, user, chkp, ulag, vlag, wlag, time_scheme, rho)
174 type(
mesh_t),
target,
intent(in) :: msh
175 type(
coef_t),
target,
intent(in) :: coef
176 type(
gs_t),
target,
intent(inout) :: gs
177 type(json_file),
target,
intent(inout) :: params
178 type(json_file),
target,
intent(inout) :: numerics_params
179 type(
user_t),
target,
intent(in) :: user
180 type(
chkp_t),
target,
intent(inout) :: chkp
183 type(
field_t),
target,
intent(in) :: rho
194 type(
chkp_t),
intent(inout) :: chkp
237 procedure, pass(this) :: move_from => &
240 procedure, pass(this) :: is_allocated => &
259 module subroutine scalar_scheme_factory(object, msh, coef, gs, params, &
261 class(scalar_scheme_t),
allocatable,
intent(inout) :: object
262 type(
mesh_t),
target,
intent(in) :: msh
263 type(
coef_t),
target,
intent(in) :: coef
264 type(
gs_t),
target,
intent(inout) :: gs
265 type(json_file),
target,
intent(inout) :: params
266 type(json_file),
target,
intent(inout) :: numerics_params
268 type(
chkp_t),
target,
intent(inout) :: chkp
271 type(
field_t),
target,
intent(in) :: rho
272 end subroutine scalar_scheme_factory
279 module subroutine scalar_scheme_allocator(object, type_name)
280 class(scalar_scheme_t),
allocatable,
intent(inout) :: object
281 character(len=*),
intent(in):: type_name
282 end subroutine scalar_scheme_allocator
293 subroutine scalar_scheme_allocate(obj)
294 import scalar_scheme_t
295 class(scalar_scheme_t),
allocatable,
intent(inout) :: obj
296 end subroutine scalar_scheme_allocate
301 module subroutine register_scalar_scheme(type_name, allocator)
302 character(len=*),
intent(in) :: type_name
303 procedure(scalar_scheme_allocate),
pointer,
intent(in) :: allocator
304 end subroutine register_scalar_scheme
309 type scalar_scheme_allocator_entry
310 character(len=20) :: type_name
311 procedure(scalar_scheme_allocate),
pointer,
nopass :: allocator
312 end type scalar_scheme_allocator_entry
315 type(scalar_scheme_allocator_entry),
allocatable,
private :: &
316 scalar_scheme_registry(:)
319 integer,
private :: scalar_scheme_registry_size = 0
331 subroutine scalar_scheme_init(this, msh, c_Xh, gs_Xh, params, scheme, user, &
333 class(scalar_scheme_t),
target,
intent(inout) :: this
334 type(
mesh_t),
target,
intent(in) :: msh
335 type(
coef_t),
target,
intent(in) :: c_Xh
336 type(
gs_t),
target,
intent(inout) :: gs_Xh
337 type(json_file),
target,
intent(inout) :: params
338 character(len=*),
intent(in) :: scheme
339 type(
user_t),
target,
intent(in) :: user
340 type(
field_t),
target,
intent(in) :: rho
342 character(len=LOG_SIZE) :: log_buf
344 logical :: logical_val
345 real(kind=
rp) :: real_val, solver_abstol
346 integer :: integer_val, ierr
347 character(len=:),
allocatable :: solver_type, solver_precon
348 type(json_file) :: precon_params
349 type(json_file) :: json_subdict
350 logical :: nut_dependency
360 call json_get(params,
'name', this%name)
366 call json_get(params,
'solver.type', solver_type)
367 call json_get(params,
'solver.preconditioner.type', &
369 call json_get(params,
'solver.preconditioner', precon_params)
374 'solver.projection_space_size', &
375 this%projection_dim, 0)
377 'solver.projection_hold_steps', &
378 this%projection_activ_step, 5)
381 write(log_buf,
'(A, A)')
'Type : ', trim(scheme)
383 write(log_buf,
'(A, A)')
'Name : ', trim(this%name)
385 call neko_log%message(
'Ksp scalar : ('// trim(solver_type) // &
386 ', ' // trim(solver_precon) //
')')
387 write(log_buf,
'(A,ES13.6)')
' `-abs tol :', solver_abstol
391 this%dm_Xh => this%u%dof
392 this%params => params
396 ignore_existing = .true.)
400 call this%slag%init(this%s, 2)
408 call this%set_material_properties(params,
user)
414 this%alphat_field_name =
""
415 this%nut_field_name =
""
416 if (params%valid_path(
'alphat'))
then
417 call json_get(this%params,
'alphat', json_subdict)
418 call json_get(json_subdict,
'nut_dependency', nut_dependency)
419 if (nut_dependency)
then
420 call json_get(json_subdict,
'Pr_t', this%pr_turb)
421 call json_get(json_subdict,
'nut_field', this%nut_field_name)
423 call json_get(json_subdict,
'alphat_field', this%alphat_field_name)
431 call this%f_Xh%init(this%dm_Xh, fld_name =
"scalar_rhs")
434 call this%source_term%init(this%f_Xh, this%c_Xh,
user, this%name)
435 call this%source_term%add(params,
'source_terms')
439 'solver.max_iterations', &
443 logical_val, .false.)
444 call scalar_scheme_solver_factory(this%ksp, this%dm_Xh%size(), &
445 solver_type, integer_val, solver_abstol, logical_val)
446 call scalar_scheme_precon_factory(this%pc, this%ksp, &
447 this%c_Xh, this%dm_Xh, this%gs_Xh, this%bcs, &
448 solver_precon, precon_params)
452 end subroutine scalar_scheme_init
456 subroutine scalar_scheme_free(this)
457 class(scalar_scheme_t),
intent(inout) :: this
465 if (
allocated(this%ksp))
then
470 if (
allocated(this%pc))
then
471 call precon_destroy(this%pc)
475 if (
allocated(this%name))
then
476 deallocate(this%name)
479 call this%source_term%free()
482 call this%slag%free()
486 nullify(this%lambda_tot)
488 end subroutine scalar_scheme_free
492 subroutine scalar_scheme_validate(this)
493 class(scalar_scheme_t),
target,
intent(inout) :: this
495 if ( (.not.
allocated(this%u%x)) .or. &
496 (.not.
allocated(this%v%x)) .or. &
497 (.not.
allocated(this%w%x)) .or. &
498 (.not.
allocated(this%s%x)))
then
502 if (.not.
allocated(this%ksp))
then
503 call neko_error(
'No Krylov solver for velocity defined')
506 if (.not.
associated(this%Xh))
then
510 if (.not.
associated(this%dm_Xh))
then
514 if (.not.
associated(this%c_Xh))
then
518 if (.not.
associated(this%f_Xh))
then
522 if (.not.
associated(this%params))
then
526 if (.not.
associated(this%rho))
then
530 end subroutine scalar_scheme_validate
534 subroutine scalar_scheme_solver_factory(ksp, n, solver, max_iter, &
536 class(
ksp_t),
allocatable,
target,
intent(inout) :: ksp
537 integer,
intent(in),
value :: n
538 integer,
intent(in) :: max_iter
539 character(len=*),
intent(in) :: solver
540 real(kind=
rp) :: abstol
541 logical,
intent(in) :: monitor
543 call krylov_solver_factory(ksp, n, solver, max_iter, &
544 abstol, monitor = monitor)
546 end subroutine scalar_scheme_solver_factory
549 subroutine scalar_scheme_precon_factory(pc, ksp, coef, dof, gs, bclst, &
551 class(
pc_t),
allocatable,
target,
intent(inout) :: pc
552 class(
ksp_t),
target,
intent(inout) :: ksp
553 type(
coef_t),
target,
intent(in) :: coef
554 type(
dofmap_t),
target,
intent(in) :: dof
555 type(
gs_t),
target,
intent(inout) :: gs
556 type(
bc_list_t),
target,
intent(inout) :: bclst
557 character(len=*) :: pctype
558 type(json_file),
intent(inout) :: pcparams
560 call precon_factory(pc, pctype)
562 select type (pcp => pc)
564 call pcp%init(coef, dof, gs)
566 call pcp%init(coef, dof, gs)
568 call pcp%init(coef, dof, gs)
570 call pcp%init(coef, bclst, pcparams)
575 end subroutine scalar_scheme_precon_factory
581 subroutine scalar_scheme_update_material_properties(this, time)
582 class(scalar_scheme_t),
intent(inout) :: this
584 type(
field_t),
pointer :: nut, alphat
587 type(
field_t),
pointer :: lambda_factor
589 call this%user_material_properties(this%name, this%material_properties, &
593 if (len_trim(this%nut_field_name) .gt. 0 &
594 .and. len_trim(this%alphat_field_name) .eq. 0 )
then
599 call field_cmult2(lambda_factor, nut, 1.0_rp / this%pr_turb)
602 call field_add3(this%lambda_tot, this%lambda, lambda_factor)
605 else if (len_trim(this%alphat_field_name) .gt. 0 &
606 .and. len_trim(this%nut_field_name) .eq. 0 )
then
611 call field_col3(lambda_factor, this%cp, alphat)
613 call field_add3(this%lambda_tot, this%lambda, lambda_factor)
616 else if (len_trim(this%alphat_field_name) .gt. 0 &
617 .and. len_trim(this%nut_field_name) .gt. 0 )
then
618 call neko_error(
"Conflicting definition of eddy diffusivity " // &
619 "for the scalar equation")
631 end subroutine scalar_scheme_update_material_properties
636 subroutine scalar_scheme_set_material_properties(this, params, user)
637 class(scalar_scheme_t),
intent(inout) :: this
638 type(json_file),
intent(inout) :: params
639 type(
user_t),
target,
intent(in) :: user
640 character(len=LOG_SIZE) :: log_buf
643 real(kind=
rp) :: const_cp, const_lambda
651 call neko_registry%add_field(this%dm_Xh, this%name //
"_lambda")
652 call neko_registry%add_field(this%dm_Xh, this%name //
"_lambda_tot")
654 this%lambda =>
neko_registry%get_field(this%name //
"_lambda")
655 this%lambda_tot =>
neko_registry%get_field(this%name //
"_lambda_tot")
658 call this%material_properties%init(2)
659 call this%material_properties%assign(1, this%cp)
660 call this%material_properties%assign(2, this%lambda)
662 if (.not.
associated(
user%material_properties, dummy_mp_ptr))
then
664 write(log_buf,
'(A)')
"Material properties must be set in the user " // &
667 this%user_material_properties =>
user%material_properties
669 call user%material_properties(this%name, this%material_properties, time)
672 if (params%valid_path(
'Pe') .and. &
673 (params%valid_path(
'lambda') .or. &
674 params%valid_path(
'cp')))
then
675 call neko_error(
"To set the material properties for the scalar, " // &
676 "either provide Pe OR lambda and cp in the case file.")
678 else if (params%valid_path(
'Pe'))
then
679 write(log_buf,
'(A)')
'Non-dimensional scalar material properties' //&
682 write(log_buf,
'(A)')
'Specific heat capacity will be set to 1, '
684 write(log_buf,
'(A)')
'conductivity to 1/Pe. Assumes density is 1.'
689 write(log_buf,
'(A,ES13.6)')
'Pe :', const_lambda
695 const_lambda = 1.0_rp/const_lambda
704 if (
associated(
user%material_properties, dummy_mp_ptr))
then
709 write(log_buf,
'(A,ES13.6)')
'lambda :', const_lambda
711 write(log_buf,
'(A,ES13.6)')
'cp :', const_cp
726 end subroutine scalar_scheme_set_material_properties
732 subroutine scalar_scheme_wrapper_init(this, msh, coef, gs, params, &
733 numerics_params, user, chkp, ulag, vlag, wlag, time_scheme, rho)
734 class(scalar_scheme_wrapper_t),
intent(inout) :: this
735 type(
mesh_t),
target,
intent(in) :: msh
736 type(
coef_t),
target,
intent(in) :: coef
737 type(
gs_t),
target,
intent(inout) :: gs
738 type(json_file),
target,
intent(inout) :: params
739 type(json_file),
target,
intent(inout) :: numerics_params
740 type(
user_t),
target,
intent(in) :: user
741 type(
chkp_t),
target,
intent(inout) :: chkp
744 type(
field_t),
target,
intent(in) :: rho
747 call scalar_scheme_factory(this%scalar, msh, coef, gs, params, &
750 end subroutine scalar_scheme_wrapper_init
753 subroutine scalar_scheme_wrapper_free(this)
754 class(scalar_scheme_wrapper_t),
intent(inout) :: this
756 if (
allocated(this%scalar))
then
757 call this%scalar%free()
758 deallocate(this%scalar)
761 end subroutine scalar_scheme_wrapper_free
767 subroutine scalar_scheme_wrapper_move_from(this, other)
768 class(scalar_scheme_wrapper_t),
intent(inout) :: this
769 class(scalar_scheme_wrapper_t),
intent(inout) :: other
772 call move_alloc(other%scalar, this%scalar)
774 end subroutine scalar_scheme_wrapper_move_from
778 function scalar_scheme_wrapper_is_allocated(this)
result(is_alloc)
779 class(scalar_scheme_wrapper_t),
intent(in) :: this
781 is_alloc =
allocated(this%scalar)
782 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.
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 log level.
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.
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_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.
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.
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)
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.
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.
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...