143 type(
case_t),
target,
intent(inout) :: this
145 logical :: scalar = .false.
146 type(
file_t) :: msh_file, bdry_file, part_file
148 logical :: found, logical_val
149 integer :: integer_val
150 real(kind=
rp) :: real_val
151 character(len = :),
allocatable :: string_val, name, file_format
152 integer :: output_dir_len
153 integer :: precision, layout
154 type(json_file) :: scalar_params, numerics_params
155 type(json_file) :: json_subdict
156 integer :: n_scalars, i
161 call this%user%init()
164 call this%user%startup(this%params)
167 if (this%params%valid_path(
'case.no_defaults'))
then
176 if (trim(string_val) .eq.
'no mesh')
then
177 call neko_error(
'The mesh_file keyword could not be found in the .' // &
178 'case file. Often caused by incorrectly formatted json.')
180 call msh_file%init(string_val)
182 call msh_file%read(this%msh)
190 if (
pe_size .gt. 1 .and. logical_val)
then
191 call neko_log%section(
'Load Balancing')
196 string_val = trim(string_val(1:scan(trim(string_val), &
197 '.', back = .true.) - 1)) //
'_lb.nmsh'
198 call msh_file%init(string_val)
199 call msh_file%write(this%msh)
208 call this%time%init(json_subdict)
216 call this%user%mesh_setup(this%msh, this%time)
223 call json_get(this%params,
'case.fluid.scheme', string_val)
224 call fluid_scheme_base_factory(this%fluid, trim(string_val))
226 call json_get(this%params,
'case.numerics.polynomial_order', lx)
229 this%chkp%tlag => this%time%tlag
230 this%chkp%dtlag => this%time%dtlag
231 call this%fluid%init(this%msh, lx, this%params, this%user, this%chkp)
245 if (this%params%valid_path(
'case.scalar'))
then
249 else if (this%params%valid_path(
'case.scalars'))
then
250 call this%params%info(
'case.scalars', n_children = n_scalars)
251 if (n_scalars > 0)
then
257 allocate(this%scalars)
258 if (this%params%valid_path(
'case.scalar'))
then
261 call this%scalars%init(this%msh, this%fluid%c_Xh, this%fluid%gs_Xh, &
262 scalar_params, numerics_params, this%user, this%chkp, this%fluid%ulag, &
263 this%fluid%vlag, this%fluid%wlag, this%fluid%ext_bdf, &
268 call this%scalars%init(n_scalars, this%msh, this%fluid%c_Xh, this%fluid%gs_Xh, &
269 json_subdict, numerics_params, this%user, this%chkp, this%fluid%ulag, &
270 this%fluid%vlag, this%fluid%wlag, this%fluid%ext_bdf, &
278 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, &
290 call json_get(this%params,
'case.fluid.scheme', string_val)
291 if (trim(string_val) .eq.
'compressible')
then
293 this%fluid%u, this%fluid%v, this%fluid%w, this%fluid%p, &
294 this%fluid%c_Xh, this%fluid%gs_Xh, &
295 this%user%initial_conditions, this%fluid%name)
297 call set_flow_ic(this%fluid%u, this%fluid%v, this%fluid%w, &
298 this%fluid%p, this%fluid%c_Xh, this%fluid%gs_Xh, &
299 this%user%initial_conditions, this%fluid%name)
306 call neko_log%section(
"Scalar initial condition ")
308 if (this%params%valid_path(
'case.scalar'))
then
310 call json_get(this%params,
'case.scalar.initial_condition.type', &
313 'case.scalar.initial_condition', json_subdict)
315 if (trim(string_val) .ne.
'user')
then
317 this%scalars%scalar_fields(1)%c_Xh, &
318 this%scalars%scalar_fields(1)%gs_Xh, &
319 string_val, json_subdict)
322 this%scalars%scalar_fields(1)%s, &
323 this%scalars%scalar_fields(1)%c_Xh, &
324 this%scalars%scalar_fields(1)%gs_Xh, &
325 this%user%initial_conditions)
333 call json_get(scalar_params,
'initial_condition.type', string_val)
337 if (trim(string_val) .ne.
'user')
then
339 this%scalars%scalar_fields(i)%c_Xh, &
340 this%scalars%scalar_fields(i)%gs_Xh, &
341 string_val, json_subdict)
344 this%scalars%scalar_fields(i)%s, &
345 this%scalars%scalar_fields(i)%c_Xh, &
346 this%scalars%scalar_fields(i)%gs_Xh, &
347 this%user%initial_conditions)
356 select type (f => this%fluid)
366 call this%fluid%validate
369 call this%scalars%validate()
376 this%output_directory,
'')
378 output_dir_len = len(trim(this%output_directory))
379 if (output_dir_len .gt. 0)
then
380 if (this%output_directory(output_dir_len:output_dir_len) .ne.
"/")
then
381 this%output_directory = trim(this%output_directory)//
"/"
383 call execute_command_line(
'mkdir -p '//this%output_directory)
392 logical_val, .false.)
393 if (logical_val)
then
396 call part_file%init(trim(this%output_directory)//
'partitions.vtk')
397 call part_file%write(msh_part)
407 if (trim(string_val) .eq.
'double')
then
425 call this%output_controller%init(this%time%end_time)
427 call this%f_out%init(precision, this%fluid, this%scalars, name = name, &
428 path = trim(this%output_directory), &
429 fmt = trim(file_format), layout = layout)
431 call this%f_out%init(precision, this%fluid, name = name, &
432 path = trim(this%output_directory), &
433 fmt = trim(file_format), layout = layout)
439 if (trim(string_val) .eq.
'org')
then
441 call json_get(this%params,
'case.nsamples', real_val)
442 call this%output_controller%add(this%f_out, real_val,
'nsamples')
443 else if (trim(string_val) .eq.
'never')
then
447 call this%output_controller%add(this%f_out, 0.0_rp, string_val)
449 call json_get(this%params,
'case.fluid.output_value', real_val)
450 call this%output_controller%add(this%f_out, real_val, string_val)
458 if (logical_val)
then
463 call this%chkp_out%init(this%chkp, name = name,&
464 path = this%output_directory, fmt = trim(string_val))
466 string_val,
"simulationtime")
469 call this%output_controller%add(this%chkp_out, real_val, string_val, &
476 if (this%params%valid_path(
'case.job_timelimit'))
then
477 call json_get(this%params,
'case.job_timelimit', string_val)