142 type(
case_t),
target,
intent(inout) :: this
144 logical :: scalar = .false.
145 type(
file_t) :: msh_file, bdry_file, part_file
147 logical :: found, logical_val
148 logical :: temperature_found = .false.
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)
181 call msh_file%read(this%msh)
189 if (
pe_size .gt. 1 .and. logical_val)
then
190 call neko_log%section(
'Load Balancing')
195 string_val = trim(string_val(1:scan(trim(string_val), &
196 '.', back = .true.) - 1)) //
'_lb.nmsh'
197 call msh_file%init(string_val)
198 call msh_file%write(this%msh)
204 call this%user%mesh_setup(this%msh, this%time)
209 call json_get(this%params,
'case.time', json_subdict)
210 call this%time%init(json_subdict)
220 call json_get(this%params,
'case.fluid.scheme', string_val)
221 call fluid_scheme_base_factory(this%fluid, trim(string_val))
223 call json_get(this%params,
'case.numerics.polynomial_order', lx)
226 this%chkp%tlag => this%time%tlag
227 this%chkp%dtlag => this%time%dtlag
228 call this%fluid%init(this%msh, lx, this%params, this%user, this%chkp)
242 if (this%params%valid_path(
'case.scalar'))
then
246 else if (this%params%valid_path(
'case.scalars'))
then
247 call this%params%info(
'case.scalars', n_children = n_scalars)
248 if (n_scalars > 0)
then
254 allocate(this%scalars)
255 call json_get(this%params,
'case.numerics', numerics_params)
256 if (this%params%valid_path(
'case.scalar'))
then
258 call json_get(this%params,
'case.scalar', scalar_params)
259 call this%scalars%init(this%msh, this%fluid%c_Xh, this%fluid%gs_Xh, &
260 scalar_params, numerics_params, this%user, this%chkp, this%fluid%ulag, &
261 this%fluid%vlag, this%fluid%wlag, this%fluid%ext_bdf, &
265 call json_get(this%params,
'case.scalars', json_subdict)
266 call this%scalars%init(n_scalars, this%msh, this%fluid%c_Xh, this%fluid%gs_Xh, &
267 json_subdict, numerics_params, this%user, this%chkp, this%fluid%ulag, &
268 this%fluid%vlag, this%fluid%wlag, this%fluid%ext_bdf, &
276 call json_get(this%params,
'case.fluid.initial_condition.type', &
278 call json_get(this%params,
'case.fluid.initial_condition', &
281 call neko_log%section(
"Fluid initial condition ")
283 if (this%params%valid_path(
'case.restart_file'))
then
284 call neko_log%message(
"Restart file specified, " // &
285 "initial conditions ignored")
286 else if (trim(string_val) .ne.
'user')
then
287 call set_flow_ic(this%fluid%u, this%fluid%v, this%fluid%w, &
288 this%fluid%p, this%fluid%c_Xh, this%fluid%gs_Xh, string_val, &
291 call json_get(this%params,
'case.fluid.scheme', string_val)
292 if (trim(string_val) .eq.
'compressible')
then
294 this%fluid%u, this%fluid%v, this%fluid%w, this%fluid%p, &
295 this%fluid%c_Xh, this%fluid%gs_Xh, &
296 this%user%initial_conditions, this%fluid%name)
298 call set_flow_ic(this%fluid%u, this%fluid%v, this%fluid%w, &
299 this%fluid%p, this%fluid%c_Xh, this%fluid%gs_Xh, &
300 this%user%initial_conditions, this%fluid%name)
307 call neko_log%section(
"Scalar initial condition ")
309 if (this%params%valid_path(
'case.restart_file'))
then
310 call neko_log%message(
"Restart file specified, " // &
311 "initial conditions ignored")
312 else if (this%params%valid_path(
'case.scalar'))
then
314 call json_get(this%params,
'case.scalar.initial_condition.type', &
317 'case.scalar.initial_condition', json_subdict)
319 if (trim(string_val) .ne.
'user')
then
320 if (trim(this%scalars%scalar_fields(1)%name) .eq.
'temperature')
then
322 this%scalars%scalar_fields(1)%c_Xh, &
323 this%scalars%scalar_fields(1)%gs_Xh, &
324 string_val, json_subdict, 0)
327 this%scalars%scalar_fields(1)%c_Xh, &
328 this%scalars%scalar_fields(1)%gs_Xh, &
329 string_val, json_subdict, 1)
333 this%scalars%scalar_fields(1)%s, &
334 this%scalars%scalar_fields(1)%c_Xh, &
335 this%scalars%scalar_fields(1)%gs_Xh, &
336 this%user%initial_conditions)
344 call json_get(scalar_params,
'initial_condition.type', string_val)
345 call json_get(scalar_params,
'initial_condition', &
348 if (trim(string_val) .ne.
'user')
then
349 if (trim(this%scalars%scalar_fields(i)%name) .eq.
'temperature')
then
351 this%scalars%scalar_fields(i)%c_Xh, &
352 this%scalars%scalar_fields(i)%gs_Xh, &
353 string_val, json_subdict, 0)
354 temperature_found = .true.
356 if (temperature_found)
then
359 this%scalars%scalar_fields(i)%c_Xh, &
360 this%scalars%scalar_fields(i)%gs_Xh, &
361 string_val, json_subdict, i - 1)
365 this%scalars%scalar_fields(i)%c_Xh, &
366 this%scalars%scalar_fields(i)%gs_Xh, &
367 string_val, json_subdict, i)
372 this%scalars%scalar_fields(i)%s, &
373 this%scalars%scalar_fields(i)%c_Xh, &
374 this%scalars%scalar_fields(i)%gs_Xh, &
375 this%user%initial_conditions)
384 select type (f => this%fluid)
394 call this%fluid%validate
397 call this%scalars%validate()
404 this%output_directory,
'')
406 output_dir_len = len(trim(this%output_directory))
407 if (output_dir_len .gt. 0)
then
408 if (this%output_directory(output_dir_len:output_dir_len) .ne.
"/")
then
409 this%output_directory = trim(this%output_directory)//
"/"
411 call execute_command_line(
'mkdir -p '//this%output_directory)
420 logical_val, .false.)
421 if (logical_val)
then
422 call msh_part%init(this%msh,
'MPI_Rank')
424 call part_file%init(trim(this%output_directory)//
'partitions.vtk')
425 call part_file%write(msh_part)
435 if (trim(string_val) .eq.
'double')
then
453 call this%output_controller%init(this%time%end_time)
455 call this%f_out%init(precision, this%fluid, this%scalars, name = name, &
456 path = trim(this%output_directory), &
457 fmt = trim(file_format), layout = layout)
459 call this%f_out%init(precision, this%fluid, name = name, &
460 path = trim(this%output_directory), &
461 fmt = trim(file_format), layout = layout)
467 if (trim(string_val) .eq.
'org')
then
469 call json_get(this%params,
'case.nsamples', real_val)
470 call this%output_controller%add(this%f_out, real_val,
'nsamples')
471 else if (trim(string_val) .eq.
'never')
then
475 call this%output_controller%add(this%f_out, 0.0_rp, string_val)
477 call json_get(this%params,
'case.fluid.output_value', real_val)
478 call this%output_controller%add(this%f_out, real_val, string_val)
486 if (logical_val)
then
491 call this%chkp_out%init(this%chkp, name = name,&
492 path = this%output_directory, fmt = trim(string_val))
494 string_val,
"simulationtime")
497 call this%output_controller%add(this%chkp_out, real_val, string_val, &
504 if (this%params%valid_path(
'case.job_timelimit'))
then
505 call json_get(this%params,
'case.job_timelimit', string_val)