89 type(
case_t),
target,
intent(inout) :: this
90 character(len=*),
intent(in) :: case_file
91 integer :: ierr, integer_val
92 character(len=:),
allocatable :: json_buffer
96 inquire(
file = trim(case_file), exist = exist)
98 call neko_error(
'The case file '//trim(case_file)//
' does not exist.')
102 call neko_log%message(
'Reading case file ' // trim(case_file), &
106 call this%params%load_file(filename = trim(case_file))
107 call this%params%print_to_string(json_buffer)
108 integer_val = len(json_buffer)
111 call mpi_bcast(integer_val, 1, mpi_integer, 0,
neko_comm, ierr)
112 if (
pe_rank .ne. 0)
allocate(
character(len = integer_val) :: json_buffer)
113 call mpi_bcast(json_buffer, integer_val, mpi_character, 0,
neko_comm, ierr)
114 call this%params%load_from_string(json_buffer)
116 deallocate(json_buffer)
138 type(
case_t),
target,
intent(inout) :: this
140 logical :: scalar = .false.
141 type(
file_t) :: msh_file, bdry_file, part_file
143 logical :: found, logical_val
144 integer :: integer_val
145 real(kind=
rp) :: real_val
146 character(len = :),
allocatable :: string_val
147 integer :: output_dir_len
155 if (trim(string_val) .eq.
'no mesh')
then
156 call neko_error(
'The mesh_file keyword could not be found in the .' // &
157 'case file. Often caused by incorrectly formatted json.')
159 msh_file =
file_t(string_val)
161 call msh_file%read(this%msh)
169 if (
pe_size .gt. 1 .and. logical_val)
then
170 call neko_log%section(
'Load Balancing')
179 call this%params%get(
'case.variable_timestep', logical_val, found)
180 if (.not. logical_val)
then
181 call json_get(this%params,
'case.timestep', this%dt)
190 call json_get(this%params,
'case.end_time', this%end_time)
201 call this%usr%user_mesh_setup(this%msh)
206 call json_get(this%params,
'case.numerics.time_order', integer_val)
207 call this%ext_bdf%init(integer_val)
212 call json_get(this%params,
'case.fluid.scheme', string_val)
213 call fluid_scheme_factory(this%fluid, trim(string_val))
215 call json_get(this%params,
'case.numerics.polynomial_order', lx)
217 this%fluid%chkp%tlag => this%tlag
218 this%fluid%chkp%dtlag => this%dtlag
219 call this%fluid%init(this%msh, lx, this%params, this%usr, this%ext_bdf)
220 select type (f => this%fluid)
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 (this%params%valid_path(
'case.scalar'))
then
246 allocate(this%scalar)
247 this%scalar%chkp%tlag => this%tlag
248 this%scalar%chkp%dtlag => this%dtlag
249 call this%scalar%init(this%msh, this%fluid%c_Xh, this%fluid%gs_Xh, &
250 this%params, this%usr, this%fluid%ulag, this%fluid%vlag, &
251 this%fluid%wlag, this%ext_bdf, this%fluid%rho)
253 call this%fluid%chkp%add_scalar(this%scalar%s)
255 this%fluid%chkp%abs1 => this%scalar%abx1
256 this%fluid%chkp%abs2 => this%scalar%abx2
257 this%fluid%chkp%slag => this%scalar%slag
263 if (this%params%valid_path(
'case.fluid.inflow_condition'))
then
264 call json_get(this%params,
'case.fluid.inflow_condition.type',&
266 if (trim(string_val) .eq.
'user')
then
267 call this%fluid%set_usr_inflow(this%usr%fluid_user_if)
273 call this%scalar%set_user_bc(this%usr%scalar_user_bc)
279 call json_get(this%params,
'case.fluid.initial_condition.type',&
282 call neko_log%section(
"Fluid initial condition ")
284 if (trim(string_val) .ne.
'user')
then
285 call set_flow_ic(this%fluid%u, this%fluid%v, this%fluid%w, &
286 this%fluid%p, this%fluid%c_Xh, this%fluid%gs_Xh, string_val, &
290 call set_flow_ic(this%fluid%u, this%fluid%v, this%fluid%w, this%fluid%p,&
291 this%fluid%c_Xh, this%fluid%gs_Xh, this%usr%fluid_user_ic, &
299 call json_get(this%params,
'case.scalar.initial_condition.type', &
302 call neko_log%section(
"Scalar initial condition ")
304 if (trim(string_val) .ne.
'user')
then
306 this%scalar%c_Xh, this%scalar%gs_Xh, string_val, this%params)
309 this%scalar%c_Xh, this%scalar%gs_Xh, this%usr%scalar_user_ic, &
318 select type (f => this%fluid)
328 call this%fluid%validate
331 call this%scalar%slag%set(this%scalar%s)
332 call this%scalar%validate
339 this%output_directory,
'')
341 output_dir_len = len(trim(this%output_directory))
342 if (output_dir_len .gt. 0)
then
343 if (this%output_directory(output_dir_len:output_dir_len) .ne.
"/")
then
344 this%output_directory = trim(this%output_directory)//
"/"
346 call execute_command_line(
'mkdir -p '//this%output_directory)
355 logical_val, .false.)
356 if (logical_val)
then
357 bdry_file =
file_t(trim(this%output_directory)//
'bdry.fld')
358 call bdry_file%write(this%fluid%bdry)
365 logical_val, .false.)
366 if (logical_val)
then
369 part_file =
file_t(trim(this%output_directory)//
'partitions.vtk')
370 call part_file%write(msh_part)
380 if (trim(string_val) .eq.
'double')
then
389 call this%output_controller%init(this%end_time)
392 path = trim(this%output_directory))
395 path = trim(this%output_directory))
401 if (trim(string_val) .eq.
'org')
then
403 call json_get(this%params,
'case.nsamples', real_val)
404 call this%output_controller%add(this%f_out, real_val,
'nsamples')
405 else if (trim(string_val) .eq.
'never')
then
409 call this%output_controller%add(this%f_out, 0.0_rp, string_val)
411 call json_get(this%params,
'case.fluid.output_value', real_val)
412 call this%output_controller%add(this%f_out, real_val, string_val)
420 if (logical_val)
then
424 path = this%output_directory, fmt = trim(string_val))
426 string_val,
"simulationtime")
429 call this%output_controller%add(this%f_chkp, real_val, string_val)
435 if (this%params%valid_path(
'case.job_timelimit'))
then
436 call json_get(this%params,
'case.job_timelimit', string_val)