146 type(
case_t),
target,
intent(inout) :: this
148 logical :: scalar = .false.
149 type(
file_t) :: msh_file, bdry_file, part_file
151 logical :: found, logical_val
152 logical :: temperature_found = .false.
153 integer :: integer_val, var_type
154 real(kind=
rp) :: real_val
155 real(kind=
rp),
allocatable :: real_vals(:)
157 character(len = :),
allocatable :: string_val, name, file_format
158 integer :: output_dir_len
159 integer :: precision, layout
160 type(json_file) :: scalar_params, numerics_params
161 type(json_file) :: json_subdict
162 integer :: n_scalars, i
167 call this%user%init()
170 call this%user%startup(this%params)
173 if (this%params%valid_path(
'case.no_defaults'))
then
181 if (this%params%valid_path(
'case.constants'))
then
182 call this%params%info(
'case.constants', &
183 n_children = integer_val)
184 do i = 1, integer_val
186 'case.constants', i, json_subdict)
187 call json_get(json_subdict,
'name', string_val)
189 call json_subdict%info(
'value', found = found, var_type = var_type)
191 select case (var_type)
193 call json_get(json_subdict,
'value', integer_val)
197 call json_get(json_subdict,
'value', real_val)
201 call json_get(json_subdict,
'value', real_vals)
207 call neko_error(
'case_init_common: Unsupported constant ' // &
208 'type in case.constants for entry '//trim(string_val)//
'.')
218 if (trim(string_val) .eq.
'no mesh')
then
219 call neko_error(
'The mesh_file keyword could not be found in the .' // &
220 'case file. Often caused by incorrectly formatted json.')
222 call msh_file%init(string_val)
223 call msh_file%read(this%msh)
231 if (
pe_size .gt. 1 .and. logical_val)
then
232 call neko_log%section(
'Load Balancing')
237 string_val = trim(string_val(1:scan(trim(string_val), &
238 '.', back = .true.) - 1)) //
'_lb.nmsh'
239 call msh_file%init(string_val)
240 call msh_file%write(this%msh)
246 call this%user%mesh_setup(this%msh, this%time)
251 call json_get(this%params,
'case.time', json_subdict)
252 call this%time%init(json_subdict)
262 call json_get(this%params,
'case.fluid.scheme', string_val)
263 call fluid_scheme_base_factory(this%fluid, trim(string_val))
268 call this%chkp%init()
269 this%chkp%tlag => this%time%tlag
270 this%chkp%dtlag => this%time%dtlag
271 call this%fluid%init(this%msh, lx, this%params, this%user, this%chkp)
285 if (this%params%valid_path(
'case.scalar'))
then
289 else if (this%params%valid_path(
'case.scalars'))
then
290 call this%params%info(
'case.scalars', n_children = n_scalars)
291 if (n_scalars > 0)
then
297 allocate(this%scalars)
298 call json_get(this%params,
'case.numerics', numerics_params)
299 if (this%params%valid_path(
'case.scalar'))
then
301 call json_get(this%params,
'case.scalar', scalar_params)
302 call this%scalars%init(this%msh, this%fluid%c_Xh, this%fluid%gs_Xh, &
303 scalar_params, numerics_params, this%user, this%chkp, &
304 this%fluid%ulag, this%fluid%vlag, this%fluid%wlag, &
305 this%fluid%ext_bdf, this%fluid%rho)
308 call json_get(this%params,
'case.scalars', json_subdict)
309 call this%scalars%init(n_scalars, this%msh, this%fluid%c_Xh, &
310 this%fluid%gs_Xh, json_subdict, numerics_params, this%user, &
311 this%chkp, this%fluid%ulag, this%fluid%vlag, this%fluid%wlag, &
312 this%fluid%ext_bdf, this%fluid%rho)
319 call json_get(this%params,
'case.fluid.initial_condition.type', &
321 call json_get(this%params,
'case.fluid.initial_condition', &
324 call neko_log%section(
"Fluid initial condition ")
326 if (this%params%valid_path(
'case.restart_file'))
then
327 call neko_log%message(
"Restart file specified, " // &
328 "initial conditions ignored")
329 else if (trim(string_val) .ne.
'user')
then
330 call set_flow_ic(this%fluid%u, this%fluid%v, this%fluid%w, &
331 this%fluid%p, this%fluid%c_Xh, this%fluid%gs_Xh, string_val, &
334 call json_get(this%params,
'case.fluid.scheme', string_val)
335 if (trim(string_val) .eq.
'compressible')
then
337 this%fluid%u, this%fluid%v, this%fluid%w, this%fluid%p, &
338 this%fluid%c_Xh, this%fluid%gs_Xh, &
339 this%user%initial_conditions, this%fluid%name)
341 call set_flow_ic(this%fluid%u, this%fluid%v, this%fluid%w, &
342 this%fluid%p, this%fluid%c_Xh, this%fluid%gs_Xh, &
343 this%user%initial_conditions, this%fluid%name)
350 call neko_log%section(
"Scalar initial condition ")
352 if (this%params%valid_path(
'case.restart_file'))
then
353 call neko_log%message(
"Restart file specified, " // &
354 "initial conditions ignored")
355 else if (this%params%valid_path(
'case.scalar'))
then
357 call json_get(this%params,
'case.scalar.initial_condition.type', &
360 'case.scalar.initial_condition', json_subdict)
362 if (trim(string_val) .ne.
'user')
then
363 if (trim(this%scalars%scalar_fields(1)%name) .eq.
'temperature')
then
365 this%scalars%scalar_fields(1)%c_Xh, &
366 this%scalars%scalar_fields(1)%gs_Xh, &
367 string_val, json_subdict, 0)
370 this%scalars%scalar_fields(1)%c_Xh, &
371 this%scalars%scalar_fields(1)%gs_Xh, &
372 string_val, json_subdict, 1)
376 this%scalars%scalar_fields(1)%s, &
377 this%scalars%scalar_fields(1)%c_Xh, &
378 this%scalars%scalar_fields(1)%gs_Xh, &
379 this%user%initial_conditions)
387 call json_get(scalar_params,
'initial_condition.type', string_val)
388 call json_get(scalar_params,
'initial_condition', &
391 if (trim(string_val) .ne.
'user')
then
392 if (trim(this%scalars%scalar_fields(i)%name) .eq.
'temperature')
then
394 this%scalars%scalar_fields(i)%c_Xh, &
395 this%scalars%scalar_fields(i)%gs_Xh, &
396 string_val, json_subdict, 0)
397 temperature_found = .true.
399 if (temperature_found)
then
402 this%scalars%scalar_fields(i)%c_Xh, &
403 this%scalars%scalar_fields(i)%gs_Xh, &
404 string_val, json_subdict, i - 1)
408 this%scalars%scalar_fields(i)%c_Xh, &
409 this%scalars%scalar_fields(i)%gs_Xh, &
410 string_val, json_subdict, i)
415 this%scalars%scalar_fields(i)%s, &
416 this%scalars%scalar_fields(i)%c_Xh, &
417 this%scalars%scalar_fields(i)%gs_Xh, &
418 this%user%initial_conditions)
427 select type (f => this%fluid)
437 call this%fluid%validate
440 call this%scalars%validate()
447 this%output_directory,
'')
449 output_dir_len = len(trim(this%output_directory))
450 if (output_dir_len .gt. 0)
then
451 if (this%output_directory(output_dir_len:output_dir_len) .ne.
"/")
then
452 this%output_directory = trim(this%output_directory)//
"/"
454 call execute_command_line(
'mkdir -p '//this%output_directory)
463 logical_val, .false.)
464 if (logical_val)
then
465 call msh_part%init(this%msh,
'MPI_Rank')
467 call part_file%init(trim(this%output_directory)//
'partitions.vtk')
468 call part_file%write(msh_part)
478 if (trim(string_val) .eq.
'double')
then
498 'case.fluid.output_mesh_in_all_files', &
499 logical_val, .false.)
500 call this%output_controller%init(this%time%end_time)
502 call this%f_out%init(precision, this%fluid, this%scalars, name = name, &
503 path = trim(this%output_directory), &
504 fmt = trim(file_format), layout = layout, &
505 always_write_mesh = logical_val)
507 call this%f_out%init(precision, this%fluid, name = name, &
508 path = trim(this%output_directory), &
509 fmt = trim(file_format), layout = layout, &
510 always_write_mesh = logical_val)
516 if (trim(string_val) .eq.
'org')
then
518 call json_get(this%params,
'case.nsamples', integer_val)
519 real_val =
real(integer_val, kind=
rp)
520 call this%output_controller%add(this%f_out, real_val,
'nsamples')
521 else if (trim(string_val) .eq.
'never')
then
522 call this%output_controller%add(this%f_out, 0.0_rp,
'never')
523 else if (trim(string_val) .eq.
'tsteps' .or. &
524 trim(string_val) .eq.
'nsamples')
then
525 call json_get(this%params,
'case.fluid.output_value', integer_val)
526 real_val =
real(integer_val, kind=
rp)
527 call this%output_controller%add(this%f_out, real_val, string_val)
528 else if (trim(string_val) .eq.
'simulationtime')
then
530 call this%output_controller%add(this%f_out, real_val, string_val)
532 call neko_log%error(
'Unknown output control type for the fluid: ' // &
541 if (logical_val)
then
546 call this%chkp_out%init(this%chkp, name = name,&
547 path = this%output_directory, fmt = trim(string_val))
549 string_val,
"simulationtime")
551 'case.checkpoint_value', real_val, 1e10_rp)
552 call this%output_controller%add(this%chkp_out, real_val, string_val, &
559 if (this%params%valid_path(
'case.job_timelimit'))
then
560 call json_get(this%params,
'case.job_timelimit', string_val)
566 call scalar_params%destroy()
567 call numerics_params%destroy()
568 call json_subdict%destroy()