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
97 inquire(
file = trim(case_file), exist = exist)
99 call neko_error(
'The case file '//trim(case_file)//
' does not exist.')
103 call neko_log%message(
'Reading case file ' // trim(case_file), &
107 call this%params%load_file(filename = trim(case_file))
108 call this%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 this%params%load_from_string(json_buffer)
117 deallocate(json_buffer)
125 type(
case_t),
target,
intent(inout) :: this
126 type(json_file),
intent(in) :: case_json
131 this%params = case_json
139 type(
case_t),
target,
intent(inout) :: this
141 logical :: scalar = .false.
142 type(
file_t) :: msh_file, bdry_file, part_file
144 logical :: found, logical_val
145 integer :: integer_val
146 real(kind=
rp) :: real_val
147 character(len = :),
allocatable :: string_val
148 integer :: output_dir_len
156 if (trim(string_val) .eq.
'no mesh')
then
157 call neko_error(
'The mesh_file keyword could not be found in the .' // &
158 'case file. Often caused by incorrectly formatted json.')
160 msh_file =
file_t(string_val)
162 call msh_file%read(this%msh)
170 if (
pe_size .gt. 1 .and. logical_val)
then
171 call neko_log%section(
'Load Balancing')
180 call this%params%get(
'case.variable_timestep', logical_val, found)
181 if (.not. logical_val)
then
182 call json_get(this%params,
'case.timestep', this%dt)
191 call json_get(this%params,
'case.end_time', this%end_time)
202 call this%usr%user_mesh_setup(this%msh)
207 call json_get(this%params,
'case.numerics.time_order', integer_val)
208 call this%ext_bdf%init(integer_val)
213 call json_get(this%params,
'case.fluid.scheme', string_val)
214 call fluid_scheme_factory(this%fluid, trim(string_val))
216 call json_get(this%params,
'case.numerics.polynomial_order', lx)
218 this%fluid%chkp%tlag => this%tlag
219 this%fluid%chkp%dtlag => this%dtlag
220 call this%fluid%init(this%msh, lx, this%params, this%usr, this%ext_bdf)
221 select type (f => this%fluid)
223 f%chkp%abx1 => f%abx1
224 f%chkp%abx2 => f%abx2
225 f%chkp%aby1 => f%aby1
226 f%chkp%aby2 => f%aby2
227 f%chkp%abz1 => f%abz1
228 f%chkp%abz2 => f%abz2
241 if (this%params%valid_path(
'case.scalar'))
then
247 allocate(this%scalar)
248 this%scalar%chkp%tlag => this%tlag
249 this%scalar%chkp%dtlag => this%dtlag
250 call this%scalar%init(this%msh, this%fluid%c_Xh, this%fluid%gs_Xh, &
251 this%params, this%usr, this%fluid%ulag, this%fluid%vlag, &
252 this%fluid%wlag, this%ext_bdf, this%fluid%rho)
254 call this%fluid%chkp%add_scalar(this%scalar%s)
256 this%fluid%chkp%abs1 => this%scalar%abx1
257 this%fluid%chkp%abs2 => this%scalar%abx2
258 this%fluid%chkp%slag => this%scalar%slag
264 if (this%params%valid_path(
'case.fluid.inflow_condition'))
then
265 call json_get(this%params,
'case.fluid.inflow_condition.type',&
267 if (trim(string_val) .eq.
'user')
then
268 call this%fluid%set_usr_inflow(this%usr%fluid_user_if)
274 call this%scalar%set_user_bc(this%usr%scalar_user_bc)
280 call json_get(this%params,
'case.fluid.initial_condition.type',&
283 call neko_log%section(
"Fluid initial condition ")
285 if (trim(string_val) .ne.
'user')
then
286 call set_flow_ic(this%fluid%u, this%fluid%v, this%fluid%w, &
287 this%fluid%p, this%fluid%c_Xh, this%fluid%gs_Xh, string_val, &
291 call set_flow_ic(this%fluid%u, this%fluid%v, this%fluid%w, this%fluid%p,&
292 this%fluid%c_Xh, this%fluid%gs_Xh, this%usr%fluid_user_ic, &
300 call json_get(this%params,
'case.scalar.initial_condition.type', &
303 call neko_log%section(
"Scalar initial condition ")
305 if (trim(string_val) .ne.
'user')
then
307 this%scalar%c_Xh, this%scalar%gs_Xh, string_val, this%params)
310 this%scalar%c_Xh, this%scalar%gs_Xh, this%usr%scalar_user_ic, &
319 select type (f => this%fluid)
329 call this%fluid%validate
332 call this%scalar%slag%set(this%scalar%s)
333 call this%scalar%validate
340 this%output_directory,
'')
342 output_dir_len = len(trim(this%output_directory))
343 if (output_dir_len .gt. 0)
then
344 if (this%output_directory(output_dir_len:output_dir_len) .ne.
"/")
then
345 this%output_directory = trim(this%output_directory)//
"/"
347 call execute_command_line(
'mkdir -p '//this%output_directory)
356 logical_val, .false.)
357 if (logical_val)
then
358 bdry_file =
file_t(trim(this%output_directory)//
'bdry.fld')
359 call bdry_file%write(this%fluid%bdry)
366 logical_val, .false.)
367 if (logical_val)
then
370 part_file =
file_t(trim(this%output_directory)//
'partitions.vtk')
371 call part_file%write(msh_part)
381 if (trim(string_val) .eq.
'double')
then
390 call this%output_controller%init(this%end_time)
393 path = trim(this%output_directory))
396 path = trim(this%output_directory))
402 if (trim(string_val) .eq.
'org')
then
404 call json_get(this%params,
'case.nsamples', real_val)
405 call this%output_controller%add(this%f_out, real_val,
'nsamples')
406 else if (trim(string_val) .eq.
'never')
then
410 call this%output_controller%add(this%f_out, 0.0_rp, string_val)
412 call json_get(this%params,
'case.fluid.output_value', real_val)
413 call this%output_controller%add(this%f_out, real_val, string_val)
421 if (logical_val)
then
425 path = this%output_directory, fmt = trim(string_val))
427 string_val,
"simulationtime")
430 call this%output_controller%add(this%f_chkp, real_val, string_val)
436 if (this%params%valid_path(
'case.job_timelimit'))
then
437 call json_get(this%params,
'case.job_timelimit', string_val)
447 type(
case_t),
intent(inout) :: this
449 if (
allocated(this%fluid))
then
450 call this%fluid%free()
451 deallocate(this%fluid)
454 if (
allocated(this%scalar))
then
455 call this%scalar%free()
456 deallocate(this%scalar)
461 call this%f_out%free()
463 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 ...