59 use json_module,
only : json_file, json_core, json_value
68 type(json_file) :: params
70 real(kind=
rp),
dimension(10) :: tlag
71 real(kind=
rp),
dimension(10) :: dtlag
73 real(kind=
rp) :: end_time
82 class(fluid_scheme_t),
allocatable :: fluid
97 type(
case_t),
target,
intent(inout) :: C
98 character(len=*),
intent(in) :: case_file
99 integer :: ierr, integer_val
100 character(len=:),
allocatable :: json_buffer
103 call neko_log%message(
'Reading case file ' // trim(case_file), &
107 call c%params%load_file(filename=trim(case_file))
108 call c%params%print_to_string(json_buffer)
109 integer_val = len(json_buffer)
112 call mpi_bcast(integer_val, 1, mpi_integer, 0,
neko_comm, ierr)
113 if (
pe_rank .ne. 0)
allocate(
character(len=integer_val)::json_buffer)
114 call mpi_bcast(json_buffer, integer_val, mpi_character, 0,
neko_comm, ierr)
115 call c%params%load_from_string(json_buffer)
117 deallocate(json_buffer)
125 type(
case_t),
target,
intent(inout) :: C
126 type(json_file),
intent(in) :: case_json
139 type(
case_t),
target,
intent(inout) :: c
140 character(len=:),
allocatable :: output_directory
142 logical :: scalar = .false.
143 type(
file_t) :: msh_file, bdry_file, part_file
145 logical :: found, logical_val
146 integer :: integer_val
147 real(kind=
rp) :: real_val
148 character(len=:),
allocatable :: string_val
149 real(kind=
rp) :: stats_start_time, stats_output_val
150 integer :: stats_sampling_interval
151 integer :: output_dir_len
152 integer :: n_simcomps
158 call json_get(c%params,
'case.mesh_file', string_val)
159 msh_file =
file_t(string_val)
161 call msh_file%read(c%msh)
169 if (
pe_size .gt. 1 .and. logical_val)
then
170 call neko_log%section(
'Load Balancing')
179 call c%params%get(
'case.variable_timestep', logical_val, found)
180 if (.not. logical_val)
then
181 call json_get(c%params,
'case.timestep', c%dt)
190 call json_get(c%params,
'case.end_time', c%end_time)
201 call c%usr%user_mesh_setup(c%msh)
207 call c%material_properties%init(c%params, c%usr)
212 call json_get(c%params,
'case.fluid.scheme', string_val)
215 call json_get(c%params,
'case.numerics.polynomial_order', lx)
217 call c%fluid%init(c%msh, lx, c%params, c%usr, c%material_properties)
218 c%fluid%chkp%tlag => c%tlag
219 c%fluid%chkp%dtlag => c%dtlag
220 select type(f => c%fluid)
221 type is(fluid_pnpn_t)
222 f%chkp%abx1 => f%abx1
223 f%chkp%abx2 => f%abx2
224 f%chkp%aby1 => f%aby1
225 f%chkp%aby2 => f%aby2
226 f%chkp%abz1 => f%abz1
227 f%chkp%abz2 => f%abz2
240 if (c%params%valid_path(
'case.scalar'))
then
247 call c%scalar%init(c%msh, c%fluid%c_Xh, c%fluid%gs_Xh, c%params, c%usr,&
248 c%material_properties)
249 call c%fluid%chkp%add_scalar(c%scalar%s)
250 c%fluid%chkp%abs1 => c%scalar%abx1
251 c%fluid%chkp%abs2 => c%scalar%abx2
252 c%fluid%chkp%slag => c%scalar%slag
258 if (c%params%valid_path(
'case.fluid.inflow_condition'))
then
259 call json_get(c%params,
'case.fluid.inflow_condition.type',&
261 if (trim(string_val) .eq.
'user')
then
262 call c%fluid%set_usr_inflow(c%usr%fluid_user_if)
268 call c%scalar%set_user_bc(c%usr%scalar_user_bc)
274 call json_get(c%params,
'case.fluid.initial_condition.type',&
276 if (trim(string_val) .ne.
'user')
then
277 call set_flow_ic(c%fluid%u, c%fluid%v, c%fluid%w, c%fluid%p, &
278 c%fluid%c_Xh, c%fluid%gs_Xh, string_val, c%params)
280 call set_flow_ic(c%fluid%u, c%fluid%v, c%fluid%w, c%fluid%p, &
281 c%fluid%c_Xh, c%fluid%gs_Xh, c%usr%fluid_user_ic, c%params)
285 call json_get(c%params,
'case.scalar.initial_condition.type', string_val)
286 if (trim(string_val) .ne.
'user')
then
288 c%scalar%c_Xh, c%scalar%gs_Xh, string_val, c%params)
291 c%scalar%c_Xh, c%scalar%gs_Xh, c%usr%scalar_user_ic, c%params)
296 select type(f => c%fluid)
297 type is(fluid_pnpn_t)
306 call c%fluid%validate
309 call c%scalar%slag%set(c%scalar%s)
310 call c%scalar%validate
316 call json_get(c%params,
'case.numerics.time_order', integer_val)
317 call c%ext_bdf%init(integer_val)
323 output_directory,
'')
325 output_dir_len = len(trim(output_directory))
326 if (output_dir_len .gt. 0)
then
327 if (output_directory(output_dir_len:output_dir_len) .ne.
"/")
then
328 output_directory = trim(output_directory)//
"/"
330 call execute_command_line(
'mkdir -p '//output_directory)
339 logical_val, .false.)
340 if (logical_val)
then
341 bdry_file =
file_t(trim(output_directory)//
'bdry.fld')
342 call bdry_file%write(c%fluid%bdry)
349 logical_val, .false.)
350 if (logical_val)
then
353 part_file =
file_t(trim(output_directory)//
'partitions.vtk')
354 call part_file%write(msh_part)
364 if (trim(string_val) .eq.
'double')
then
373 call c%s%init(c%end_time)
376 path=trim(output_directory))
379 path=trim(output_directory))
385 if (trim(string_val) .eq.
'org')
then
387 call json_get(c%params,
'case.nsamples', real_val)
388 call c%s%add(c%f_out, real_val,
'nsamples')
389 else if (trim(string_val) .eq.
'never')
then
393 call c%s%add(c%f_out, 0.0_rp, string_val)
395 call json_get(c%params,
'case.fluid.output_value', real_val)
396 call c%s%add(c%f_out, real_val, string_val)
404 if (logical_val)
then
405 c%f_chkp =
chkp_output_t(c%fluid%chkp, path=output_directory)
407 string_val,
"simulationtime")
410 call c%s%add(c%f_chkp, real_val, string_val)
420 call c%params%get(
'case.statistics.start_time', stats_start_time,&
422 if (.not. found) stats_start_time = 0.0_rp
424 call c%params%get(
'case.statistics.sampling_interval', &
425 stats_sampling_interval, found)
426 if (.not. found) stats_sampling_interval = 10
428 call c%q%init(stats_start_time, stats_sampling_interval)
430 found = c%params%valid_path(
'case.statistics')
434 if (logical_val)
then
435 call c%q%add(c%fluid%mean%u)
436 call c%q%add(c%fluid%mean%v)
437 call c%q%add(c%fluid%mean%w)
438 call c%q%add(c%fluid%mean%p)
441 path=output_directory)
443 call json_get(c%params,
'case.statistics.output_control', &
445 call json_get(c%params,
'case.statistics.output_value', &
448 call c%s%add(c%f_mf, stats_output_val, string_val)
449 call c%q%add(c%fluid%stats)
452 stats_start_time, path=output_directory)
453 call c%s%add(c%f_stats_output, stats_output_val, string_val)
475 if (c%params%valid_path(
'case.job_timelimit'))
then
476 call json_get(c%params,
'case.job_timelimit', string_val)
486 type(
case_t),
intent(inout) :: C
488 if (
allocated(c%fluid))
then
493 if (
allocated(c%scalar))
then
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.
Defines a simulation case.
subroutine case_free(C)
Deallocate a case.
subroutine, private case_init_from_json(C, case_json)
Initialize a case from a JSON object describing a case.
subroutine, private case_init_from_file(C, case_file)
Initialize a case from an input file case_file.
subroutine, private case_init_common(C)
Initialize a case from its (loaded) params object.
Defines an output for a checkpoint.
type(mpi_comm) neko_comm
MPI communicator.
integer pe_size
MPI size of communicator.
Module for file I/O operations.
Factory for all fluid schemes.
subroutine fluid_scheme_factory(fluid, fluid_scheme)
Initialise a fluid scheme.
Defines an output for a fluid.
Defines an output for a mean flow field.
Utilities for retrieving parameters from the case files.
integer, parameter, public neko_log_quiet
Always logged.
type(log_t), public neko_log
Global log stream.
Implements material_properties_t type.
Defines an output for a mean flow field.
Defines an output for a mean squared flow field.
subroutine, public mesh_field_free(fld)
subroutine, public mesh_field_init(fld, msh, fld_name)
integer, parameter, public dp
integer, parameter, public sp
integer, parameter, public rp
Global precision used in computations.
subroutine, public parmetis_partmeshkway(msh, parts, weights, nprts)
Compute a k-way partitioning of a mesh msh.
type(point_zone_registry_t), target, public neko_point_zone_registry
Global point_zone registry.
subroutine, public redist_mesh(msh, parts)
Redistribute a mesh msh according to new partitions.
Scalar initial condition.
Containts the scalar_pnpn_t type.
Defines a registry for storing and requesting temporary fields This can be used when you have a funct...
type(scratch_registry_t), target, public neko_scratch_registry
Global scratch registry.
Defines a container for all statistics.
Compound scheme for the advection and diffusion operators in a transport equation.
Interfaces for user interaction with NEKO.
A wrapper around a polymorphic generic_file_t that handles its init. This is essentially a factory fo...
Contains all the material properties necessary in the simulation.
Implements the logic to compute the time coefficients for the advection and diffusion operators in a ...