56 use json_module,
only : json_file, json_core, json_value
65 type(json_file) :: params
67 real(kind=
rp),
dimension(10) :: tlag
68 real(kind=
rp),
dimension(10) :: dtlag
70 real(kind=
rp) :: end_time
71 character(len=:),
allocatable :: output_directory
90 type(
case_t),
target,
intent(inout) :: this
91 character(len=*),
intent(in) :: case_file
92 integer :: ierr, integer_val
93 character(len=:),
allocatable :: json_buffer
96 call neko_log%message(
'Reading case file ' // trim(case_file), &
100 call this%params%load_file(filename = trim(case_file))
101 call this%params%print_to_string(json_buffer)
102 integer_val = len(json_buffer)
105 call mpi_bcast(integer_val, 1, mpi_integer, 0,
neko_comm, ierr)
106 if (
pe_rank .ne. 0)
allocate(
character(len = integer_val) :: json_buffer)
107 call mpi_bcast(json_buffer, integer_val, mpi_character, 0,
neko_comm, ierr)
108 call this%params%load_from_string(json_buffer)
110 deallocate(json_buffer)
118 type(
case_t),
target,
intent(inout) :: this
119 type(json_file),
intent(in) :: case_json
124 this%params = case_json
132 type(
case_t),
target,
intent(inout) :: this
134 logical :: scalar = .false.
135 type(
file_t) :: msh_file, bdry_file, part_file
137 logical :: found, logical_val
138 integer :: integer_val
139 real(kind=
rp) :: real_val
140 character(len = :),
allocatable :: string_val
141 real(kind=
rp) :: stats_start_time, stats_output_val
142 integer :: stats_sampling_interval
143 integer :: output_dir_len
151 if (trim(string_val) .eq.
'no mesh')
then
152 call neko_error(
'The mesh_file keyword could not be found in the .' // &
153 'case file. Often caused by incorrectly formatted json.')
155 msh_file =
file_t(string_val)
157 call msh_file%read(this%msh)
165 if (
pe_size .gt. 1 .and. logical_val)
then
166 call neko_log%section(
'Load Balancing')
175 call this%params%get(
'case.variable_timestep', logical_val, found)
176 if (.not. logical_val)
then
177 call json_get(this%params,
'case.timestep', this%dt)
186 call json_get(this%params,
'case.end_time', this%end_time)
197 call this%usr%user_mesh_setup(this%msh)
202 call json_get(this%params,
'case.numerics.time_order', integer_val)
203 call this%ext_bdf%init(integer_val)
208 call json_get(this%params,
'case.fluid.scheme', string_val)
209 call fluid_scheme_factory(this%fluid, trim(string_val))
211 call json_get(this%params,
'case.numerics.polynomial_order', lx)
213 this%fluid%chkp%tlag => this%tlag
214 this%fluid%chkp%dtlag => this%dtlag
215 call this%fluid%init(this%msh, lx, this%params, this%usr, this%ext_bdf)
216 select type (f => this%fluid)
218 f%chkp%abx1 => f%abx1
219 f%chkp%abx2 => f%abx2
220 f%chkp%aby1 => f%aby1
221 f%chkp%aby2 => f%aby2
222 f%chkp%abz1 => f%abz1
223 f%chkp%abz2 => f%abz2
236 if (this%params%valid_path(
'case.scalar'))
then
242 allocate(this%scalar)
243 this%scalar%chkp%tlag => this%tlag
244 this%scalar%chkp%dtlag => this%dtlag
245 call this%scalar%init(this%msh, this%fluid%c_Xh, this%fluid%gs_Xh, &
246 this%params, this%usr, this%fluid%ulag, this%fluid%vlag, &
247 this%fluid%wlag, this%ext_bdf, this%fluid%rho)
249 call this%fluid%chkp%add_scalar(this%scalar%s)
251 this%fluid%chkp%abs1 => this%scalar%abx1
252 this%fluid%chkp%abs2 => this%scalar%abx2
253 this%fluid%chkp%slag => this%scalar%slag
259 if (this%params%valid_path(
'case.fluid.inflow_condition'))
then
260 call json_get(this%params,
'case.fluid.inflow_condition.type',&
262 if (trim(string_val) .eq.
'user')
then
263 call this%fluid%set_usr_inflow(this%usr%fluid_user_if)
269 call this%scalar%set_user_bc(this%usr%scalar_user_bc)
275 call json_get(this%params,
'case.fluid.initial_condition.type',&
279 call neko_log%section(
"Fluid initial condition ")
281 if (trim(string_val) .ne.
'user')
then
282 call set_flow_ic(this%fluid%u, this%fluid%v, this%fluid%w, &
283 this%fluid%p, this%fluid%c_Xh, this%fluid%gs_Xh, string_val, &
287 call set_flow_ic(this%fluid%u, this%fluid%v, this%fluid%w, this%fluid%p,&
288 this%fluid%c_Xh, this%fluid%gs_Xh, this%usr%fluid_user_ic, &
296 call json_get(this%params,
'case.scalar.initial_condition.type', &
299 call neko_log%section(
"Scalar initial condition ")
301 if (trim(string_val) .ne.
'user')
then
303 this%scalar%c_Xh, this%scalar%gs_Xh, string_val, this%params)
306 this%scalar%c_Xh, this%scalar%gs_Xh, this%usr%scalar_user_ic, &
315 select type (f => this%fluid)
325 call this%fluid%validate
328 call this%scalar%slag%set(this%scalar%s)
329 call this%scalar%validate
336 this%output_directory,
'')
338 output_dir_len = len(trim(this%output_directory))
339 if (output_dir_len .gt. 0)
then
340 if (this%output_directory(output_dir_len:output_dir_len) .ne.
"/")
then
341 this%output_directory = trim(this%output_directory)//
"/"
343 call execute_command_line(
'mkdir -p '//this%output_directory)
352 logical_val, .false.)
353 if (logical_val)
then
354 bdry_file =
file_t(trim(this%output_directory)//
'bdry.fld')
355 call bdry_file%write(this%fluid%bdry)
362 logical_val, .false.)
363 if (logical_val)
then
366 part_file =
file_t(trim(this%output_directory)//
'partitions.vtk')
367 call part_file%write(msh_part)
377 if (trim(string_val) .eq.
'double')
then
386 call this%output_controller%init(this%end_time)
389 path = trim(this%output_directory))
392 path = trim(this%output_directory))
398 if (trim(string_val) .eq.
'org')
then
400 call json_get(this%params,
'case.nsamples', real_val)
401 call this%output_controller%add(this%f_out, real_val,
'nsamples')
402 else if (trim(string_val) .eq.
'never')
then
406 call this%output_controller%add(this%f_out, 0.0_rp, string_val)
408 call json_get(this%params,
'case.fluid.output_value', real_val)
409 call this%output_controller%add(this%f_out, real_val, string_val)
417 if (logical_val)
then
421 path = this%output_directory, fmt = trim(string_val))
423 string_val,
"simulationtime")
426 call this%output_controller%add(this%f_chkp, real_val, string_val)
432 if (this%params%valid_path(
'case.job_timelimit'))
then
433 call json_get(this%params,
'case.job_timelimit', string_val)
443 type(
case_t),
intent(inout) :: this
445 if (
allocated(this%fluid))
then
446 call this%fluid%free()
447 deallocate(this%fluid)
450 if (
allocated(this%scalar))
then
451 call this%scalar%free()
452 deallocate(this%scalar)
457 call this%f_out%free()
459 call this%output_controller%free()
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_from_file(this, case_file)
Initialize a case from an input file case_file.
subroutine, public case_free(this)
Deallocate a case.
subroutine case_init_from_json(this, case_json)
Initialize a case from a JSON object describing a case.
subroutine case_init_common(this)
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.
Defines an output for a fluid.
Modular version of the Classic Nek5000 Pn/Pn formulation for fluids.
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
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.
Implements output_controller_t
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.
Centralized controller for a list of outputs.
Implements the logic to compute the time coefficients for the advection and diffusion operators in a ...