59 use json_module,
only : json_file, json_core, json_value
69 type(json_file) :: params
71 real(kind=
rp),
dimension(10) :: tlag
72 real(kind=
rp),
dimension(10) :: dtlag
74 real(kind=
rp) :: end_time
98 type(
case_t),
target,
intent(inout) :: C
99 character(len=*),
intent(in) :: case_file
100 integer :: ierr, integer_val
101 character(len=:),
allocatable :: json_buffer
104 call neko_log%message(
'Reading case file ' // trim(case_file), &
108 call c%params%load_file(filename = trim(case_file))
109 call c%params%print_to_string(json_buffer)
110 integer_val = len(json_buffer)
113 call mpi_bcast(integer_val, 1, mpi_integer, 0,
neko_comm, ierr)
114 if (
pe_rank .ne. 0)
allocate(
character(len=integer_val)::json_buffer)
115 call mpi_bcast(json_buffer, integer_val, mpi_character, 0,
neko_comm, ierr)
116 call c%params%load_from_string(json_buffer)
118 deallocate(json_buffer)
126 type(
case_t),
target,
intent(inout) :: C
127 type(json_file),
intent(in) :: case_json
140 type(
case_t),
target,
intent(inout) :: C
141 character(len=:),
allocatable :: output_directory
143 logical :: scalar = .false.
144 type(
file_t) :: msh_file, bdry_file, part_file
146 logical :: found, logical_val
147 integer :: integer_val
148 real(kind=
rp) :: real_val
149 character(len=:),
allocatable :: string_val
150 real(kind=
rp) :: stats_start_time, stats_output_val
151 integer :: stats_sampling_interval
152 integer :: output_dir_len
159 if (trim(string_val) .eq.
'no mesh')
then
160 call neko_error(
'The mesh_file keyword could not be found in the .' // &
161 'case file. Often caused by incorrectly formatted json.')
163 msh_file =
file_t(string_val)
165 call msh_file%read(c%msh)
173 if (
pe_size .gt. 1 .and. logical_val)
then
174 call neko_log%section(
'Load Balancing')
183 call c%params%get(
'case.variable_timestep', logical_val, found)
184 if (.not. logical_val)
then
185 call json_get(c%params,
'case.timestep', c%dt)
194 call json_get(c%params,
'case.end_time', c%end_time)
205 call c%usr%user_mesh_setup(c%msh)
210 call json_get(c%params,
'case.numerics.time_order', integer_val)
211 call c%ext_bdf%init(integer_val)
217 call c%material_properties%init(c%params, c%usr)
222 call json_get(c%params,
'case.fluid.scheme', string_val)
223 call fluid_scheme_factory(c%fluid, trim(string_val))
225 call json_get(c%params,
'case.numerics.polynomial_order', lx)
227 c%fluid%chkp%tlag => c%tlag
228 c%fluid%chkp%dtlag => c%dtlag
229 call c%fluid%init(c%msh, lx, c%params, c%usr, c%material_properties, &
231 select type (f => c%fluid)
233 f%chkp%abx1 => f%abx1
234 f%chkp%abx2 => f%abx2
235 f%chkp%aby1 => f%aby1
236 f%chkp%aby2 => f%aby2
237 f%chkp%abz1 => f%abz1
238 f%chkp%abz2 => f%abz2
251 if (c%params%valid_path(
'case.scalar'))
then
258 c%scalar%chkp%tlag => c%tlag
259 c%scalar%chkp%dtlag => c%dtlag
260 call c%scalar%init(c%msh, c%fluid%c_Xh, c%fluid%gs_Xh, c%params, c%usr,&
261 c%material_properties, c%fluid%ulag, c%fluid%vlag, &
262 c%fluid%wlag, c%ext_bdf)
263 call c%fluid%chkp%add_scalar(c%scalar%s)
264 c%fluid%chkp%abs1 => c%scalar%abx1
265 c%fluid%chkp%abs2 => c%scalar%abx2
266 c%fluid%chkp%slag => c%scalar%slag
272 if (c%params%valid_path(
'case.fluid.inflow_condition'))
then
273 call json_get(c%params,
'case.fluid.inflow_condition.type',&
275 if (trim(string_val) .eq.
'user')
then
276 call c%fluid%set_usr_inflow(c%usr%fluid_user_if)
282 call c%scalar%set_user_bc(c%usr%scalar_user_bc)
288 call json_get(c%params,
'case.fluid.initial_condition.type',&
290 if (trim(string_val) .ne.
'user')
then
291 call set_flow_ic(c%fluid%u, c%fluid%v, c%fluid%w, c%fluid%p, &
292 c%fluid%c_Xh, c%fluid%gs_Xh, string_val, c%params)
294 call set_flow_ic(c%fluid%u, c%fluid%v, c%fluid%w, c%fluid%p, &
295 c%fluid%c_Xh, c%fluid%gs_Xh, c%usr%fluid_user_ic, c%params)
299 call json_get(c%params,
'case.scalar.initial_condition.type', string_val)
300 if (trim(string_val) .ne.
'user')
then
302 c%scalar%c_Xh, c%scalar%gs_Xh, string_val, c%params)
305 c%scalar%c_Xh, c%scalar%gs_Xh, c%usr%scalar_user_ic, c%params)
310 select type (f => c%fluid)
320 call c%fluid%validate
323 call c%scalar%slag%set(c%scalar%s)
324 call c%scalar%validate
331 output_directory,
'')
333 output_dir_len = len(trim(output_directory))
334 if (output_dir_len .gt. 0)
then
335 if (output_directory(output_dir_len:output_dir_len) .ne.
"/")
then
336 output_directory = trim(output_directory)//
"/"
338 call execute_command_line(
'mkdir -p '//output_directory)
347 logical_val, .false.)
348 if (logical_val)
then
349 bdry_file =
file_t(trim(output_directory)//
'bdry.fld')
350 call bdry_file%write(c%fluid%bdry)
357 logical_val, .false.)
358 if (logical_val)
then
361 part_file =
file_t(trim(output_directory)//
'partitions.vtk')
362 call part_file%write(msh_part)
372 if (trim(string_val) .eq.
'double')
then
381 call c%s%init(c%end_time)
384 path = trim(output_directory))
387 path = trim(output_directory))
393 if (trim(string_val) .eq.
'org')
then
395 call json_get(c%params,
'case.nsamples', real_val)
396 call c%s%add(c%f_out, real_val,
'nsamples')
397 else if (trim(string_val) .eq.
'never')
then
401 call c%s%add(c%f_out, 0.0_rp, string_val)
403 call json_get(c%params,
'case.fluid.output_value', real_val)
404 call c%s%add(c%f_out, real_val, string_val)
412 if (logical_val)
then
415 c%f_chkp =
chkp_output_t(c%fluid%chkp, path = output_directory, &
416 fmt = trim(string_val))
418 string_val,
"simulationtime")
421 call c%s%add(c%f_chkp, real_val, string_val)
431 call c%params%get(
'case.statistics.start_time', stats_start_time,&
433 if (.not. found) stats_start_time = 0.0_rp
435 call c%params%get(
'case.statistics.sampling_interval', &
436 stats_sampling_interval, found)
437 if (.not. found) stats_sampling_interval = 10
439 call c%q%init(stats_start_time, stats_sampling_interval)
441 found = c%params%valid_path(
'case.statistics')
445 if (logical_val)
then
446 call c%q%add(c%fluid%mean%u)
447 call c%q%add(c%fluid%mean%v)
448 call c%q%add(c%fluid%mean%w)
449 call c%q%add(c%fluid%mean%p)
452 path = output_directory)
454 call json_get(c%params,
'case.statistics.output_control', &
456 call json_get(c%params,
'case.statistics.output_value', &
459 call c%s%add(c%f_mf, stats_output_val, string_val)
460 call c%q%add(c%fluid%stats)
463 stats_start_time, path = output_directory)
464 call c%s%add(c%f_stats_output, stats_output_val, string_val)
471 if (c%params%valid_path(
'case.job_timelimit'))
then
472 call json_get(c%params,
'case.job_timelimit', string_val)
482 type(
case_t),
intent(inout) :: c
484 if (
allocated(c%fluid))
then
489 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_init_common(C)
Initialize a case from its (loaded) params object.
subroutine, public case_free(C)
Deallocate a case.
subroutine case_init_from_json(C, case_json)
Initialize a case from a JSON object describing a case.
subroutine case_init_from_file(C, case_file)
Initialize a case from an input file case_file.
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.
Defines an output for a fluid.
Modular version of the Classic Nek5000 Pn/Pn formulation for fluids.
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.
integer, parameter, public log_size
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...
Base type of all fluid formulations.
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 ...