50 use json_module,
only : json_file
79 type(
field_t),
intent(inout) :: u
80 type(
field_t),
intent(inout) :: v
81 type(
field_t),
intent(inout) :: w
82 type(
field_t),
intent(inout) :: p
83 type(
coef_t),
intent(in) :: coef
84 type(
gs_t),
intent(inout) :: gs
85 character(len=*) :: type
86 type(json_file),
intent(inout) :: params
87 real(kind=
rp) :: delta
88 real(kind=
rp),
allocatable :: uinf(:)
89 real(kind=
rp),
allocatable :: zone_value(:)
90 character(len=:),
allocatable :: read_str
91 character(len=NEKO_EXPR_LEN),
allocatable :: expr_str(:)
97 if (trim(type) .eq.
'uniform')
then
105 else if (trim(type) .eq.
'expression')
then
107 call json_get(params,
'value', expr_str, filler =
'')
109 if (
allocated(expr_str))
deallocate(expr_str)
114 else if (trim(type) .eq.
'blasius')
then
117 call json_get(params,
'approximation', read_str)
125 else if (trim(type) .eq.
'point_zone')
then
128 call json_get(params,
'zone_name', read_str)
136 else if (trim(type) .eq.
'field')
then
139 character(len=NEKO_FNAME_LEN) :: fname, mesh_fname
140 logical :: interpolate
141 type(json_file) :: interp_subdict
143 call json_get(params,
'file_name', read_str)
144 fname = trim(read_str)
150 mesh_fname = trim(read_str)
155 mesh_fname, interp_subdict)
168 type(field_t),
target,
intent(inout) :: u
169 type(field_t),
target,
intent(inout) :: v
170 type(field_t),
target,
intent(inout) :: w
171 type(field_t),
target,
intent(inout) :: p
172 type(coef_t),
intent(in) :: coef
173 type(gs_t),
intent(inout) :: gs
174 procedure(user_initial_conditions_intf) :: user_proc
175 character(len=*),
intent(in) :: scheme_name
177 type(field_list_t) :: fields
180 call neko_log%message(
"Type: user")
183 call fields%assign_to_field(1, u)
184 call fields%assign_to_field(2, v)
185 call fields%assign_to_field(3, w)
186 call fields%assign_to_field(4, p)
188 call user_proc(scheme_name, fields)
197 user_proc, scheme_name)
198 type(field_t),
target,
intent(inout) :: rho
199 type(field_t),
target,
intent(inout) :: u
200 type(field_t),
target,
intent(inout) :: v
201 type(field_t),
target,
intent(inout) :: w
202 type(field_t),
target,
intent(inout) :: p
203 type(coef_t),
intent(in) :: coef
204 type(gs_t),
intent(inout) :: gs
205 procedure(user_initial_conditions_intf) :: user_proc
206 character(len=*),
intent(in) :: scheme_name
208 type(field_list_t) :: fields
211 call neko_log%message(
"Type: user (compressible flows)")
214 call fields%assign_to_field(1, rho)
215 call fields%assign_to_field(2, u)
216 call fields%assign_to_field(3, v)
217 call fields%assign_to_field(4, w)
218 call fields%assign_to_field(5, p)
219 call user_proc(scheme_name, fields)
225 if (neko_bcknd_device .eq. 1)
then
226 call device_memcpy(p%x, p%x_d, n, host_to_device, sync = .false.)
227 call device_memcpy(rho%x, rho%x_d, n, host_to_device, sync = .false.)
232 call gs%op(p%x, p%dof%size(), gs_op_add)
233 call gs%op(rho%x, rho%dof%size(), gs_op_add)
235 if (neko_bcknd_device .eq. 1)
then
236 call device_col2(rho%x_d, coef%mult_d, rho%dof%size())
237 call device_col2(p%x_d, coef%mult_d, p%dof%size())
239 call col2(rho%x, coef%mult, rho%dof%size())
240 call col2(p%x, coef%mult, p%dof%size())
246 type(field_t),
intent(inout) :: u
247 type(field_t),
intent(inout) :: v
248 type(field_t),
intent(inout) :: w
249 type(field_t),
intent(inout) :: p
250 type(coef_t),
intent(in) :: coef
251 type(gs_t),
intent(inout) :: gs
256 if (neko_bcknd_device .eq. 1)
then
257 call u%copy_from(host_to_device, sync = .false.)
258 call v%copy_from(host_to_device, sync = .false.)
259 call w%copy_from(host_to_device, sync = .false.)
262 call p%copy_from(host_to_device, sync = .true.)
266 call rotate_cyc(u, v, w, 1, coef)
267 call gs%op(u%x, u%dof%size(), gs_op_add)
268 call gs%op(v%x, v%dof%size(), gs_op_add)
269 call gs%op(w%x, w%dof%size(), gs_op_add)
270 call rotate_cyc(u, v, w, 0, coef)
272 if (neko_bcknd_device .eq. 1)
then
273 call device_col2(u%x_d, coef%mult_d, u%dof%size())
274 call device_col2(v%x_d, coef%mult_d, v%dof%size())
275 call device_col2(w%x_d, coef%mult_d, w%dof%size())
277 call col2(u%x, coef%mult, u%dof%size())
278 call col2(v%x, coef%mult, v%dof%size())
279 call col2(w%x, coef%mult, w%dof%size())
286 type(field_t),
intent(inout) :: u
287 type(field_t),
intent(inout) :: v
288 type(field_t),
intent(inout) :: w
289 real(kind=rp),
intent(in) :: uinf(3)
291 character(len=LOG_SIZE) :: log_buf
293 call neko_log%message(
"Type : uniform")
294 write (log_buf,
'(A, 3(ES12.6, A))')
"Value: [", &
295 (uinf(i),
", ", i = 1, 2), uinf(3),
"]"
296 call neko_log%message(log_buf)
302 if (neko_bcknd_device .eq. 1)
then
303 call cfill(u%x, uinf(1), n)
304 call cfill(v%x, uinf(2), n)
305 call cfill(w%x, uinf(3), n)
321 type(field_t),
target,
intent(inout) :: u
322 type(field_t),
target,
intent(inout) :: v
323 type(field_t),
target,
intent(inout) :: w
324 character(len=*),
intent(in) :: expr(:)
325 character(len=1),
parameter :: comp(3) = [
'u',
'v',
'w']
326 type(field_t),
pointer :: f
329 if (
size(expr) .ne. 3)
then
330 call neko_error(
'The expression initial condition takes exactly ' // &
331 'three expressions, one per velocity component')
334 call neko_log%message(
"Type : expression")
336 call neko_log%message(comp(i) //
" : " // trim(expr(i)))
351 call expression_eval_static(expr(i), f%x, n, &
352 u%dof%x, u%dof%y, u%dof%z,
'fluid initial condition')
362 type(field_t),
intent(inout) :: u
363 type(field_t),
intent(inout) :: v
364 type(field_t),
intent(inout) :: w
365 real(kind=rp),
intent(in) :: delta
366 real(kind=rp),
intent(in) :: uinf(3)
367 character(len=*),
intent(in) :: type
368 procedure(blasius_profile),
pointer :: bla => null()
370 character(len=LOG_SIZE) :: log_buf
372 call neko_log%message(
"Type : blasius")
373 write (log_buf,
'(A,ES12.6)')
"delta : ", delta
374 call neko_log%message(log_buf)
375 call neko_log%message(
"Approximation : " // trim(type))
376 write (log_buf,
'(A,"[",2(ES12.6,","),ES12.6,"]")')
"Value : ", &
377 uinf(1), uinf(2), uinf(3)
378 call neko_log%message(log_buf)
380 select case (trim(type))
382 bla => blasius_linear
384 bla => blasius_quadratic
388 bla => blasius_quartic
394 call neko_error(
'Invalid Blasius approximation')
397 if ((uinf(1) .gt. 0.0_rp) .and. abscmp(uinf(2), 0.0_rp) &
398 .and. abscmp(uinf(3), 0.0_rp))
then
399 do i = 1, u%dof%size()
400 u%x(i,1,1,1) = bla(u%dof%z(i,1,1,1), delta, uinf(1))
401 v%x(i,1,1,1) = 0.0_rp
402 w%x(i,1,1,1) = 0.0_rp
404 else if (abscmp(uinf(1), 0.0_rp) .and. (uinf(2) .gt. 0.0_rp) &
405 .and. abscmp(uinf(3), 0.0_rp))
then
406 do i = 1, u%dof%size()
407 u%x(i,1,1,1) = 0.0_rp
408 v%x(i,1,1,1) = bla(u%dof%x(i,1,1,1), delta, uinf(2))
409 w%x(i,1,1,1) = 0.0_rp
411 else if (abscmp(uinf(1), 0.0_rp) .and. abscmp(uinf(2), 0.0_rp) &
412 .and. (uinf(3) .gt. 0.0_rp))
then
413 do i = 1, u%dof%size()
414 u%x(i,1,1,1) = 0.0_rp
415 v%x(i,1,1,1) = 0.0_rp
416 w%x(i,1,1,1) = bla(u%dof%y(i,1,1,1), delta, uinf(3))
432 type(field_t),
intent(inout) :: u
433 type(field_t),
intent(inout) :: v
434 type(field_t),
intent(inout) :: w
435 real(kind=rp),
intent(in),
dimension(3) :: base_value
436 character(len=*),
intent(in) :: zone_name
437 real(kind=rp),
intent(in) :: zone_value(:)
438 character(len=LOG_SIZE) :: log_buf
441 class(point_zone_t),
pointer :: zone
444 call neko_log%message(
"Type : point_zone")
445 write (log_buf,
'(A,ES12.6)')
"Base value : ", base_value
446 call neko_log%message(log_buf)
447 call neko_log%message(
"Zone name : " // trim(zone_name))
448 write (log_buf,
'(A,"[",2(ES12.6,","),ES12.6," ]")')
"Value : ", &
449 zone_value(1), zone_value(2), zone_value(3)
450 call neko_log%message(log_buf)
455 zone => neko_point_zone_registry%get_point_zone(trim(zone_name))
457 call cfill_mask(u%x, zone_value(1),
size, zone%mask%get(), zone%size)
458 call cfill_mask(v%x, zone_value(2),
size, zone%mask%get(), zone%size)
459 call cfill_mask(w%x, zone_value(3),
size, zone%mask%get(), zone%size)
479 interpolate, mesh_file_name, global_interp_subdict)
480 type(field_t),
target,
intent(inout) :: u
481 type(field_t),
target,
intent(inout) :: v
482 type(field_t),
target,
intent(inout) :: w
483 type(field_t),
target,
intent(inout) :: p
484 character(len=*),
intent(inout) :: file_name
485 logical,
intent(in) :: interpolate
486 character(len=*),
intent(inout) :: mesh_file_name
487 type(json_file),
intent(inout) :: global_interp_subdict
489 type(field_t),
pointer :: us, vs, ws, ps
496 call import_fields(file_name, global_interp_subdict, mesh_file_name, &
497 u = us, v = vs, w = ws, p = ps, &
498 interpolate = interpolate)
500 nullify(us, vs, ws, ps)
504 call u%copy_from(device_to_host, sync = .false.)
505 call v%copy_from(device_to_host, sync = .false.)
506 call w%copy_from(device_to_host, sync = .false.)
507 call p%copy_from(device_to_host, sync = .true.)
Copy data between host and device (or device and device)
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.
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 intial 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 intial 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)
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.