51 use json_module,
only : json_file
80 type(
field_t),
intent(inout) :: u
81 type(
field_t),
intent(inout) :: v
82 type(
field_t),
intent(inout) :: w
83 type(
field_t),
intent(inout) :: p
84 type(
coef_t),
intent(in) :: coef
85 type(
gs_t),
intent(inout) :: gs
86 character(len=*) :: type
87 type(json_file),
intent(inout) :: params
88 real(kind=
rp) :: delta
89 real(kind=
rp),
allocatable :: uinf(:)
90 real(kind=
rp),
allocatable :: zone_value(:)
91 character(len=:),
allocatable :: read_str
92 character(len=NEKO_EXPR_LEN),
allocatable :: expr_str(:)
94 select case (trim(type))
102 call json_get(params,
'value', expr_str, filler =
'')
104 if (
allocated(expr_str))
deallocate(expr_str)
109 call json_get(params,
'approximation', read_str)
117 call json_get(params,
'zone_name', read_str)
125 character(len=NEKO_FNAME_LEN) :: fname, mesh_fname
126 logical :: interpolate
127 type(json_file) :: interp_subdict
129 call json_get(params,
'file_name', read_str)
130 fname = trim(read_str)
133 mesh_fname = trim(read_str)
138 mesh_fname, interp_subdict)
154 type(field_t),
target,
intent(inout) :: u
155 type(field_t),
target,
intent(inout) :: v
156 type(field_t),
target,
intent(inout) :: w
157 type(field_t),
target,
intent(inout) :: p
158 type(coef_t),
intent(in) :: coef
159 type(gs_t),
intent(inout) :: gs
160 procedure(user_initial_conditions_intf) :: user_proc
161 character(len=*),
intent(in) :: scheme_name
162 real(kind=rp) :: um, vm, wm, pm, init
163 type(field_list_t) :: fields
165 call neko_log%message(
"Type: user")
168 call fields%assign_to_field(1, u)
169 call fields%assign_to_field(2, v)
170 call fields%assign_to_field(3, w)
171 call fields%assign_to_field(4, p)
174 call field_cfill(u, init)
175 call field_cfill(v, init)
176 call field_cfill(w, init)
177 call field_cfill(p, init)
179 call user_proc(scheme_name, fields)
186 if (abscmp(um, init))
call neko_error(
'Initial condition did not set u')
187 if (abscmp(vm, init))
call neko_error(
'Initial condition did not set v')
188 if (abscmp(wm, init))
call neko_error(
'Initial condition did not set w')
189 if (abscmp(pm, init))
call neko_error(
'Initial condition did not set p')
201 user_proc, scheme_name)
202 type(field_t),
target,
intent(inout) :: rho
203 type(field_t),
target,
intent(inout) :: u
204 type(field_t),
target,
intent(inout) :: v
205 type(field_t),
target,
intent(inout) :: w
206 type(field_t),
target,
intent(inout) :: p
207 type(coef_t),
intent(in) :: coef
208 type(gs_t),
intent(inout) :: gs
209 procedure(user_initial_conditions_intf) :: user_proc
210 character(len=*),
intent(in) :: scheme_name
211 real(kind=rp) :: rhom, um, vm, wm, pm, init
212 type(field_list_t) :: fields
214 call neko_log%message(
"Type: user (compressible flows)")
217 call fields%assign_to_field(1, rho)
218 call fields%assign_to_field(2, u)
219 call fields%assign_to_field(3, v)
220 call fields%assign_to_field(4, w)
221 call fields%assign_to_field(5, p)
224 call field_cfill(rho, init)
225 call field_cfill(u, init)
226 call field_cfill(v, init)
227 call field_cfill(w, init)
228 call field_cfill(p, init)
230 call user_proc(scheme_name, fields)
232 rhom = field_glmin(rho)
238 if (abscmp(rhom, init))
call neko_error(
'Initial condition did not set rho')
239 if (abscmp(um, init))
call neko_error(
'Initial condition did not set u')
240 if (abscmp(vm, init))
call neko_error(
'Initial condition did not set v')
241 if (abscmp(wm, init))
call neko_error(
'Initial condition did not set w')
242 if (abscmp(pm, init))
call neko_error(
'Initial condition did not set p')
248 call gs%op(p%x, p%dof%size(), gs_op_add)
249 call gs%op(rho%x, rho%dof%size(), gs_op_add)
251 if (neko_bcknd_device .eq. 1)
then
252 call device_col2(rho%x_d, coef%mult_d, rho%dof%size())
253 call device_col2(p%x_d, coef%mult_d, p%dof%size())
255 call col2(rho%x, coef%mult, rho%dof%size())
256 call col2(p%x, coef%mult, p%dof%size())
265 type(field_t),
intent(inout) :: u
266 type(field_t),
intent(inout) :: v
267 type(field_t),
intent(inout) :: w
268 type(field_t),
intent(inout) :: p
269 type(coef_t),
intent(in) :: coef
270 type(gs_t),
intent(inout) :: gs
273 call rotate_cyc(u, v, w, 1, coef)
274 call gs%op(u%x, u%dof%size(), gs_op_add)
275 call gs%op(v%x, v%dof%size(), gs_op_add)
276 call gs%op(w%x, w%dof%size(), gs_op_add)
277 call rotate_cyc(u, v, w, 0, coef)
279 if (neko_bcknd_device .eq. 1)
then
280 call device_col2(u%x_d, coef%mult_d, u%dof%size())
281 call device_col2(v%x_d, coef%mult_d, v%dof%size())
282 call device_col2(w%x_d, coef%mult_d, w%dof%size())
284 call col2(u%x, coef%mult, u%dof%size())
285 call col2(v%x, coef%mult, v%dof%size())
286 call col2(w%x, coef%mult, w%dof%size())
293 type(field_t),
intent(inout) :: u
294 type(field_t),
intent(inout) :: v
295 type(field_t),
intent(inout) :: w
296 real(kind=rp),
intent(in) :: uinf(3)
298 character(len=LOG_SIZE) :: log_buf
300 call neko_log%message(
"Type : uniform")
301 write (log_buf,
'(A, 3(ES12.6, A))')
"Value: [", &
302 (uinf(i),
", ", i = 1, 2), uinf(3),
"]"
303 call neko_log%message(log_buf)
305 call field_cfill(u, uinf(1))
306 call field_cfill(v, uinf(2))
307 call field_cfill(w, uinf(3))
322 type(field_t),
target,
intent(inout) :: u
323 type(field_t),
target,
intent(inout) :: v
324 type(field_t),
target,
intent(inout) :: w
325 character(len=*),
intent(in) :: expr(:)
326 character(len=1),
parameter :: comp(3) = [
'u',
'v',
'w']
327 type(field_t),
pointer :: f
330 if (
size(expr) .ne. 3)
then
331 call neko_error(
'The expression initial condition takes exactly ' // &
332 'three expressions, one per velocity component')
335 call neko_log%message(
"Type : expression")
337 call neko_log%message(comp(i) //
" : " // trim(expr(i)))
352 call expression_eval_static(expr(i), f%x, n, &
353 f%dof%x%x, f%dof%y%x, f%dof%z%x,
'fluid initial condition')
356 call u%copy_from(host_to_device, sync = .false.)
357 call v%copy_from(host_to_device, sync = .false.)
358 call w%copy_from(host_to_device, sync = .true.)
364 type(field_t),
intent(inout) :: u
365 type(field_t),
intent(inout) :: v
366 type(field_t),
intent(inout) :: w
367 real(kind=rp),
intent(in) :: delta
368 real(kind=rp),
intent(in) :: uinf(3)
369 character(len=*),
intent(in) :: type
370 procedure(blasius_profile),
pointer :: bla => null()
372 character(len=LOG_SIZE) :: log_buf
374 call neko_log%message(
"Type : blasius")
375 write (log_buf,
'(A,ES12.6)')
"delta : ", delta
376 call neko_log%message(log_buf)
377 call neko_log%message(
"Approximation : " // trim(type))
378 write (log_buf,
'(A,"[",2(ES12.6,","),ES12.6,"]")')
"Value : ", &
379 uinf(1), uinf(2), uinf(3)
380 call neko_log%message(log_buf)
382 select case (trim(type))
384 bla => blasius_linear
386 bla => blasius_quadratic
390 bla => blasius_quartic
396 call neko_error(
'Invalid Blasius approximation')
399 if ((uinf(1) .gt. 0.0_rp) .and. abscmp(uinf(2), 0.0_rp) &
400 .and. abscmp(uinf(3), 0.0_rp))
then
401 do i = 1, u%dof%size()
402 u%x(i,1,1,1) = bla(u%dof%z%x(i,1,1,1), delta, uinf(1))
403 v%x(i,1,1,1) = 0.0_rp
404 w%x(i,1,1,1) = 0.0_rp
406 else if (abscmp(uinf(1), 0.0_rp) .and. (uinf(2) .gt. 0.0_rp) &
407 .and. abscmp(uinf(3), 0.0_rp))
then
408 do i = 1, u%dof%size()
409 u%x(i,1,1,1) = 0.0_rp
410 v%x(i,1,1,1) = bla(u%dof%x%x(i,1,1,1), delta, uinf(2))
411 w%x(i,1,1,1) = 0.0_rp
413 else if (abscmp(uinf(1), 0.0_rp) .and. abscmp(uinf(2), 0.0_rp) &
414 .and. (uinf(3) .gt. 0.0_rp))
then
415 do i = 1, u%dof%size()
416 u%x(i,1,1,1) = 0.0_rp
417 v%x(i,1,1,1) = 0.0_rp
418 w%x(i,1,1,1) = bla(u%dof%y%x(i,1,1,1), delta, uinf(3))
422 call u%copy_from(host_to_device, sync = .false.)
423 call v%copy_from(host_to_device, sync = .false.)
424 call w%copy_from(host_to_device, sync = .true.)
438 type(field_t),
intent(inout) :: u
439 type(field_t),
intent(inout) :: v
440 type(field_t),
intent(inout) :: w
441 real(kind=rp),
intent(in),
dimension(3) :: base_value
442 character(len=*),
intent(in) :: zone_name
443 real(kind=rp),
intent(in) :: zone_value(:)
444 character(len=LOG_SIZE) :: log_buf
447 class(point_zone_t),
pointer :: zone
450 call neko_log%message(
"Type : point_zone")
451 write (log_buf,
'(A,ES12.6)')
"Base value : ", base_value
452 call neko_log%message(log_buf)
453 call neko_log%message(
"Zone name : " // trim(zone_name))
454 write (log_buf,
'(A,"[",2(ES12.6,","),ES12.6," ]")')
"Value : ", &
455 zone_value(1), zone_value(2), zone_value(3)
456 call neko_log%message(log_buf)
459 zone => neko_point_zone_registry%get_point_zone(trim(zone_name))
461 call cfill(u%x, base_value(1), size)
462 call cfill(v%x, base_value(2), size)
463 call cfill(w%x, base_value(3), size)
464 call cfill_mask(u%x, zone_value(1),
size, zone%mask%get(), zone%size)
465 call cfill_mask(v%x, zone_value(2),
size, zone%mask%get(), zone%size)
466 call cfill_mask(w%x, zone_value(3),
size, zone%mask%get(), zone%size)
468 call u%copy_from(host_to_device, sync = .false.)
469 call v%copy_from(host_to_device, sync = .false.)
470 call w%copy_from(host_to_device, sync = .true.)
490 interpolate, mesh_file_name, global_interp_subdict)
491 type(field_t),
target,
intent(inout) :: u
492 type(field_t),
target,
intent(inout) :: v
493 type(field_t),
target,
intent(inout) :: w
494 type(field_t),
target,
intent(inout) :: p
495 character(len=*),
intent(inout) :: file_name
496 logical,
intent(in) :: interpolate
497 character(len=*),
intent(inout) :: mesh_file_name
498 type(json_file),
intent(inout) :: global_interp_subdict
500 type(field_t),
pointer :: us, vs, ws, ps
507 if (trim(mesh_file_name) .eq.
'none')
then
508 call import_fields(file_name, global_interp_subdict, &
509 u = us, v = vs, w = ws, p = ps, &
510 interpolate = interpolate)
512 call import_fields(file_name, global_interp_subdict, mesh_file_name, &
513 u = us, v = vs, w = ws, p = ps, &
514 interpolate = interpolate)
517 nullify(us, vs, ws, ps)
Synchronize a device or stream.
Abstract interface for computing a Blasius flow profile.
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.
Apply cyclic boundary condition to a vector field.
Abstract interface for user defined initial conditions.
subroutine, public device_col2(a_d, b_d, n, strm)
Vector multiplication .
Device abstraction, common interface for various accelerators.
integer, parameter, public host_to_device
integer, parameter, public device_to_host
Evaluation of mathematical expressions given as strings in the case file.
integer, parameter, public neko_expr_len
Maximum length of an expression string read from the case file.
subroutine, public expression_eval_static(str, res, n, x, y, z, usage)
Compile an expression and evaluate it in a set of points, in a context where there is no time state.
real(kind=rp) function, public field_glmin(a, n)
Global minimum of all elements in a field .
subroutine, public field_cfill(a, c, n)
Set all elements to a constant c .
Module for file I/O operations.
Simple module to handle fld file series. Provides an interface to the different fields sotred in a fl...
subroutine set_flow_ic_usr(u, v, w, p, coef, gs, user_proc, scheme_name)
Set initial flow condition (user defined)
subroutine, public set_flow_ic_fld(u, v, w, p, file_name, interpolate, mesh_file_name, global_interp_subdict)
Set the initial condition of the flow based on a field. @detail The fields are read from an fld file....
subroutine set_flow_ic_point_zone(u, v, w, base_value, zone_name, zone_value)
Set the initial condition of the flow based on a point zone.
subroutine set_flow_ic_int(u, v, w, p, coef, gs, type, params)
Set initial flow condition (builtin)
subroutine set_compressible_flow_ic_usr(rho, u, v, w, p, coef, gs, user_proc, scheme_name)
Set initial flow condition (user defined) for compressible flows.
subroutine set_flow_ic_uniform(u, v, w, uinf)
Uniform initial condition.
subroutine set_flow_ic_common(u, v, w, p, coef, gs)
Make the initial velocity continuous across elements.
subroutine set_flow_ic_expression(u, v, w, expr)
Set the initial condition from one mathematical expression per velocity component.
subroutine set_flow_ic_blasius(u, v, w, delta, uinf, type)
Set a Blasius profile as initial condition.
real(kind=rp) function, public blasius_quadratic(y, delta, u)
Quadratic approximate Blasius Profile .
real(kind=rp) function, public blasius_quartic(y, delta, u)
Quartic approximate Blasius Profile .
real(kind=rp) function, public blasius_sin(y, delta, u)
Sinusoidal approximate Blasius Profile .
real(kind=rp) function, public blasius_cubic(y, delta, u)
Cubic approximate Blasius Profile .
real(kind=rp) function, public blasius_tanh(y, delta, u)
Hyperbolic tangent approximate Blasius Profile from O. Savas (2012) where is the 99 percent thickne...
real(kind=rp) function, public blasius_linear(y, delta, u)
Linear approximate Blasius profile .
Implements global_interpolation given a dofmap.
Importation of fields from fld files.
Routines to interpolate between different spaces.
Utilities for retrieving parameters from the case files.
subroutine, public json_get_subdict_or_empty(json, key, output)
Extract a sub-object from a json object and returns an empty object if the key is missing.
type(log_t), public neko_log
Global log stream.
integer, parameter, public log_size
subroutine, public cfill(a, c, n)
Set all elements to a constant c .
subroutine, public col2(a, b, n)
Vector multiplication .
subroutine, public cfill_mask(a, c, n, mask, n_mask)
Fill a constant to a masked vector. .
integer, parameter neko_bcknd_device
integer, parameter, public rp
Global precision used in computations.
type(point_zone_registry_t), target, public neko_point_zone_registry
Global point_zone registry.
Defines a function space.
integer, parameter, public gll
Interfaces for user interaction with NEKO.
integer function, public extract_fld_file_index(fld_filename, default_index)
Extracts the index of a field file. For example, "myfield.f00045" will return 45. If the suffix of th...
integer, parameter, public neko_fname_len
subroutine, public neko_warning(warning_msg)
Reports a warning to standard output.
subroutine, public filename_chsuffix(fname, new_fname, new_suffix)
Change a filename's suffix.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
field_list_t, To be able to group fields together
A wrapper around a polymorphic generic_file_t that handles its init. This is essentially a factory fo...
Interface for NEKTON fld files.
Implements global interpolation for arbitrary points in the domain.
Interpolation between two space::space_t.
Base abstract type for point zones.
The function space for the SEM solution fields.