44 use json_module,
only : json_file, json_array
65 class(
ksp_t),
allocatable :: shared_ksp
87 numerics_params, user, chkp, ulag, vlag, wlag, time_scheme, rho)
89 integer,
intent(in) :: n_scalars
90 type(
mesh_t),
target,
intent(in) :: msh
91 type(
coef_t),
target,
intent(in) :: coef
92 type(
gs_t),
target,
intent(inout) :: gs
93 type(json_file),
target,
intent(inout) :: params
94 type(json_file),
target,
intent(inout) :: numerics_params
95 type(
user_t),
target,
intent(in) :: user
98 TYPE(
field_t),
TARGET,
INTENT(IN) :: rho
99 type(
chkp_t),
target,
intent(inout) :: chkp
100 type(json_file) :: json_subdict
102 character(len=:),
allocatable :: field_name
103 character(len=:),
allocatable :: field_names(:)
104 character(len=256) :: error_msg, buffer
107 allocate(this%scalar_fields(n_scalars))
110 allocate(
character(len=256) :: field_names(n_scalars))
120 if (len_trim(field_name) == 0)
then
121 if (n_scalars == 1)
then
124 write(
buffer,
'(A,I0)')
's_', i
129 field_names(i) = trim(field_name)
132 if (n_scalars > 1)
then
135 if (trim(field_names(i)) == trim(field_names(j)))
then
136 call neko_error(
"Duplicate scalar field name detected: "// &
137 trim(field_names(i)) // &
138 ". Please provide unique names for each scalar field.")
150 call json_subdict%add(
'name', trim(field_names(i)))
153 call this%scalar_fields(i)%init(msh, coef, gs, json_subdict, &
159 user, chkp, ulag, vlag, wlag, time_scheme, rho)
161 type(
mesh_t),
target,
intent(in) :: msh
162 type(
coef_t),
target,
intent(in) :: coef
163 type(
gs_t),
target,
intent(inout) :: gs
164 type(json_file),
target,
intent(inout) :: params
165 type(json_file),
target,
intent(inout) :: numerics_params
166 type(
user_t),
target,
intent(in) :: user
167 type(
chkp_t),
target,
intent(inout) :: chkp
170 TYPE(
field_t),
TARGET,
INTENT(IN) :: rho
173 allocate(this%scalar_fields(1))
176 if (.not. params%valid_path(
'name'))
then
177 call params%add(
'name',
's')
181 call this%scalar_fields(1)%init(msh, coef, gs, params, numerics_params, &
192 type(
ksp_monitor_t),
dimension(size(this%scalar_fields)) :: ksp_results
193 logical :: all_frozen
200 do i = 1,
size(this%scalar_fields)
201 all_frozen = all_frozen .and. this%scalar_fields(i)%scalar%freeze
202 call this%scalar_fields(i)%scalar%step(time, ext_bdf, dt_controller, &
207 if (.not. all_frozen)
then
208 call ksp_results(i)%print_header()
211 do i = 1,
size(this%scalar_fields)
212 if (this%scalar_fields(i)%scalar%freeze) cycle
220 type(
chkp_t),
intent(inout) :: chkp
221 integer :: i, n_scalars
223 n_scalars =
size(this%scalar_fields)
224 do i = 1,
size(this%scalar_fields)
225 call this%scalar_fields(i)%scalar%restart(chkp)
236 type(json_file),
intent(inout) :: params
237 type(
user_t),
intent(in) :: user
238 logical,
intent(in) :: is_restart
239 integer :: i, running_scalar_index, scalar_index, var_type
240 type(json_file) :: json_subdict
242 call neko_log%section(
"Scalar initial condition ")
245 call neko_log%message(
"Restart file specified, " // &
246 "initial conditions ignored")
250 call params%info(
'', var_type = var_type)
252 running_scalar_index = 0
253 do i = 1,
size(this%scalar_fields)
254 if (trim(this%scalar_fields(i)%scalar%name) .eq.
'temperature')
then
257 running_scalar_index = running_scalar_index + 1
258 scalar_index = running_scalar_index
261 if (var_type .eq. json_array)
then
263 call this%scalar_fields(i)%scalar%set_initial_condition( &
264 json_subdict,
user, scalar_index)
266 call this%scalar_fields(i)%scalar%set_initial_condition( &
267 params,
user, scalar_index)
270 call json_subdict%destroy()
282 do i = 1,
size(this%scalar_fields)
283 call this%scalar_fields(i)%scalar%slag%set( &
284 this%scalar_fields(i)%scalar%s)
285 call this%scalar_fields(i)%scalar%validate()
295 if (
allocated(this%scalar_fields))
then
296 do i = 1,
size(this%scalar_fields)
297 call this%scalar_fields(i)%free()
299 deallocate(this%scalar_fields)
302 if (
allocated(this%shared_ksp))
then
303 call this%shared_ksp%free()
304 deallocate(this%shared_ksp)
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.
Generic buffer that is extended with buffers of varying rank.
Defines format-independent checkpoint registration and restart state.
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 neko_log_verbose
Verbose.
type(log_t), public neko_log
Global log stream.
integer, parameter, public log_size
integer, parameter, public rp
Global precision used in computations.
subroutine, public profiler_start_region(name, region_id)
Started a named (name) profiler region.
subroutine, public profiler_end_region(name, region_id)
End the most recently started profiler region.
Auxiliary routines for fluid solvers.
subroutine, public scalar_step_info(time, ksp_results, strict_convergence, allow_stabilization)
Prints for prs, velx, vely, velz the following: Number of iterations, start residual,...
Contains the scalar_scheme_t type.
Contains the scalars_t type that manages multiple scalar fields.
subroutine scalars_set_initial_conditions(this, params, user, is_restart)
Set initial conditions for all scalar fields.
subroutine scalars_validate(this)
Check if the configuration is valid.
subroutine scalars_init(this, n_scalars, msh, coef, gs, params, numerics_params, user, chkp, ulag, vlag, wlag, time_scheme, rho)
Initialize the scalars container.
subroutine scalars_init_single(this, msh, coef, gs, params, numerics_params, user, chkp, ulag, vlag, wlag, time_scheme, rho)
subroutine scalars_free(this)
Clean up all resources.
subroutine scalars_step(this, time, ext_bdf, dt_controller)
Perform a time step for all scalar fields.
subroutine scalars_restart(this, chkp)
Restart from checkpoint data.
Defines a function space.
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.
Collection of live simulation data registered for checkpointing.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
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 ...
Type for storing initial and final residuals in a Krylov solver.
Base abstract type for a canonical Krylov method, solving .
A helper type that is needed to have an array of polymorphic objects.
Type to manage multiple scalar transport equations.
The function space for the SEM solution fields.
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...