43 use krylov,
only :
ksp_t, krylov_solver_factory, krylov_solver_destroy, &
54 use precon,
only :
pc_t, precon_factory, precon_destroy
63 use json_module,
only : json_file
96 type(
gs_t),
pointer :: gs_xh
106 integer :: ksp_maxiter
108 integer :: projection_dim
110 integer :: projection_activ_step
116 type(json_file),
pointer :: params
122 real(kind=
rp) :: lambda
126 character(len=:),
allocatable :: nut_field_name
132 real(kind=
rp) :: pr_turb
134 logical :: variable_material_properties = .false.
136 logical :: if_gradient_jump_penalty
146 procedure, pass(this) :: set_material_properties => &
149 procedure, pass(this) :: update_material_properties => &
164 ulag, vlag, wlag, time_scheme, rho)
175 type(
mesh_t),
target,
intent(in) :: msh
176 type(
coef_t),
target,
intent(in) :: coef
177 type(
gs_t),
target,
intent(inout) :: gs
178 type(json_file),
target,
intent(inout) :: params
179 type(
user_t),
target,
intent(in) :: user
182 real(kind=
rp),
intent(in) :: rho
193 real(kind=
rp) :: dtlag(10), tlag(10)
214 real(kind=
rp),
intent(in) :: t
215 integer,
intent(in) :: tstep
216 real(kind=
rp),
intent(in) :: dt
235 type(
mesh_t),
target,
intent(in) :: msh
236 type(
coef_t),
target,
intent(in) :: c_Xh
237 type(
gs_t),
target,
intent(inout) :: gs_Xh
238 type(json_file),
target,
intent(inout) :: params
239 character(len=*),
intent(in) :: scheme
240 type(
user_t),
target,
intent(in) :: user
241 real(kind=
rp),
intent(in) :: rho
243 character(len=LOG_SIZE) :: log_buf
245 logical :: logical_val
246 real(kind=
rp) :: real_val, solver_abstol
247 integer :: integer_val, ierr
248 character(len=:),
allocatable :: solver_type, solver_precon
249 real(kind=
rp) :: gjp_param_a, gjp_param_b
256 call json_get(params,
'case.scalar.solver.type', solver_type)
257 call json_get(params,
'case.scalar.solver.preconditioner', &
259 call json_get(params,
'case.scalar.solver.absolute_tolerance', &
263 'case.scalar.solver.projection_space_size', &
264 this%projection_dim, 20)
266 'case.scalar.solver.projection_hold_steps', &
267 this%projection_activ_step, 5)
270 write(log_buf,
'(A, A)')
'Type : ', trim(scheme)
272 call neko_log%message(
'Ksp scalar : ('// trim(solver_type) // &
273 ', ' // trim(solver_precon) //
')')
274 write(log_buf,
'(A,ES13.6)')
' `-abs tol :', solver_abstol
278 this%dm_Xh => this%u%dof
279 this%params => params
286 call this%slag%init(this%s, 2)
295 call this%set_material_properties(params, user)
297 write(log_buf,
'(A,ES13.6)')
'rho :', this%rho
299 write(log_buf,
'(A,ES13.6)')
'lambda :', this%lambda
301 write(log_buf,
'(A,ES13.6)')
'cp :', this%cp
307 if (params%valid_path(
'case.scalar.nut_field'))
then
308 call json_get(params,
'case.scalar.Pr_t', this%pr_turb)
309 call json_get(params,
'case.scalar.nut_field', this%nut_field_name)
310 this%variable_material_properties = .true.
312 this%nut_field_name =
""
315 write(log_buf,
'(A,L1)')
'LES : ', this%variable_material_properties
319 call this%lambda_field%init(this%dm_Xh,
"lambda")
322 this%lambda_field%size())
324 call cfill(this%lambda_field%x, this%lambda, this%lambda_field%size())
331 call this%f_Xh%init(this%dm_Xh, fld_name =
"scalar_rhs")
334 call this%source_term%init(this%f_Xh, this%c_Xh, user)
335 call this%source_term%add(params,
'case.scalar.source_terms')
339 'case.fluid.velocity_solver.max_iterations', &
342 'case.fluid.velocity_solver.monitor', &
343 logical_val, .false.)
345 solver_type, integer_val, solver_abstol, logical_val)
347 this%c_Xh, this%dm_Xh, this%gs_Xh, this%bcs, solver_precon)
351 'case.scalar.gradient_jump_penalty.enabled',&
352 this%if_gradient_jump_penalty, .false.)
354 if (this%if_gradient_jump_penalty .eqv. .true.)
then
355 if ((this%dm_Xh%xh%lx - 1) .eq. 1)
then
357 'case.scalar.gradient_jump_penalty.tau',&
358 gjp_param_a, 0.02_rp)
362 'case.scalar.gradient_jump_penalty.scaling_factor',&
365 'case.scalar.gradient_jump_penalty.scaling_exponent',&
368 call this%gradient_jump_penalty%init(params, this%dm_Xh, this%c_Xh, &
369 gjp_param_a, gjp_param_b)
387 if (
allocated(this%ksp))
then
388 call krylov_solver_destroy(this%ksp)
392 if (
allocated(this%pc))
then
393 call precon_destroy(this%pc)
397 call this%source_term%free()
401 call this%lambda_field%free()
402 call this%slag%free()
405 if (this%if_gradient_jump_penalty .eqv. .true.)
then
406 call this%gradient_jump_penalty%free()
416 if ( (.not.
allocated(this%u%x)) .or. &
417 (.not.
allocated(this%v%x)) .or. &
418 (.not.
allocated(this%w%x)) .or. &
419 (.not.
allocated(this%s%x)))
then
423 if (.not.
allocated(this%ksp))
then
424 call neko_error(
'No Krylov solver for velocity defined')
427 if (.not.
associated(this%Xh))
then
431 if (.not.
associated(this%dm_Xh))
then
435 if (.not.
associated(this%c_Xh))
then
439 if (.not.
associated(this%f_Xh))
then
443 if (.not.
associated(this%params))
then
459 class(
ksp_t),
allocatable,
target,
intent(inout) :: ksp
460 integer,
intent(in),
value :: n
461 integer,
intent(in) :: max_iter
462 character(len=*),
intent(in) :: solver
463 real(kind=
rp) :: abstol
464 logical,
intent(in) :: monitor
466 call krylov_solver_factory(ksp, n, solver, max_iter, &
467 abstol, monitor = monitor)
474 class(
pc_t),
allocatable,
target,
intent(inout) :: pc
475 class(
ksp_t),
target,
intent(inout) :: ksp
476 type(
coef_t),
target,
intent(in) :: coef
477 type(
dofmap_t),
target,
intent(in) :: dof
478 type(
gs_t),
target,
intent(inout) :: gs
479 type(
bc_list_t),
target,
intent(inout) :: bclst
480 character(len=*) :: pctype
482 call precon_factory(pc, pctype)
484 select type (pcp => pc)
486 call pcp%init(coef, dof, gs)
488 call pcp%init(coef, dof, gs)
490 call pcp%init(coef, dof, gs)
492 if (len_trim(pctype) .gt. 4)
then
493 if (index(pctype,
'+') .eq. 5)
then
494 call pcp%init(dof%msh, dof%Xh, coef, dof, gs, bclst, &
500 call pcp%init(dof%msh, dof%Xh, coef, dof, gs, bclst)
514 real(kind=
rp) :: lambda_factor
516 lambda_factor = this%rho*this%cp/this%pr_turb
517 this%lambda_field = this%lambda
519 if (this%variable_material_properties)
then
522 call field_add2s2(this%lambda_field, nut, lambda_factor, n)
532 type(json_file),
intent(inout) :: params
533 type(
user_t),
target,
intent(in) :: user
534 character(len=LOG_SIZE) :: log_buf
537 real(kind=
rp) :: dummy_mu, dummy_rho
541 if (.not.
associated(user%material_properties, dummy_mp_ptr))
then
543 write(log_buf,
'(A)')
"Material properties must be set in the user&
546 call user%material_properties(0.0_rp, 0, dummy_rho, dummy_mu, &
547 this%cp, this%lambda, params)
549 if (params%valid_path(
'case.scalar.Pe') .and. &
550 (params%valid_path(
'case.scalar.lambda') .or. &
551 params%valid_path(
'case.scalar.cp')))
then
552 call neko_error(
"To set the material properties for the scalar,&
553 & either provide Pe OR lambda and cp in the case file.")
555 else if (params%valid_path(
'case.scalar.Pe'))
then
556 write(log_buf,
'(A)')
'Non-dimensional scalar material properties &
559 write(log_buf,
'(A)')
'Specific heat capacity will be set to 1,'
561 write(log_buf,
'(A)')
'conductivity to 1/Pe. Assumes density is 1.'
565 call json_get(params,
'case.scalar.Pe', this%lambda)
566 write(log_buf,
'(A,ES13.6)')
'Pe :', this%lambda
573 this%lambda = 1.0_rp/this%lambda
576 call json_get(params,
'case.scalar.lambda', this%lambda)
577 call json_get(params,
'case.scalar.cp', this%cp)
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.
Abstract interface defining a user defined scalar boundary condition (pointwise) Just imitating inflo...
Defines a boundary condition.
type(mpi_comm) neko_comm
MPI communicator.
Jacobi preconditioner accelerator backend.
subroutine, public device_add2s2(a_d, b_d, c1, n)
Vector addition with scalar multiplication (multiplication on first argument)
subroutine, public device_cfill(a_d, c, n)
Set all elements to a constant c .
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_add2s2(a, b, c1, n)
Vector addition with scalar multiplication (multiplication on second argument)
Defines a registry for storing solution fields.
type(field_registry_t), target, public neko_field_registry
Global field registry.
Implements gradient_jump_penalty_t.
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.
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_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)
Update the values of lambda_field if necessary.
subroutine scalar_scheme_precon_factory(pc, ksp, coef, dof, gs, bclst, pctype)
Initialize a Krylov preconditioner.
subroutine scalar_scheme_set_material_properties(this, params, user)
Set lamdba and cp.
Implements the scalar_source_term_t type.
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.
Implements type time_step_controller.
Interfaces for user interaction with NEKO.
subroutine, public dummy_user_material_properties(t, tstep, rho, mu, cp, lambda, params)
Defines dirichlet conditions for scalars.
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
Implements the gradient jump penalty.
Defines a jacobi preconditioner.
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 ...
Provides a tool to set time step dt.
User defined dirichlet condition for scalars.