49 use json_module,
only : json_file
73 type(
field_t),
intent(inout) :: u
74 type(
field_t),
intent(inout) :: v
75 type(
field_t),
intent(inout) :: w
76 type(
field_t),
intent(inout) :: p
77 type(
coef_t),
intent(in) :: coef
78 type(
gs_t),
intent(inout) :: gs
79 character(len=*) :: type
80 type(json_file),
intent(inout) :: params
81 real(kind=
rp) :: delta, tol
82 real(kind=
rp),
allocatable :: uinf(:)
83 real(kind=
rp),
allocatable :: zone_value(:)
84 character(len=:),
allocatable :: read_str
85 character(len=NEKO_FNAME_LEN) :: fname, mesh_fname
86 logical :: interpolate
92 if (trim(type) .eq.
'uniform')
then
100 else if (trim(type) .eq.
'blasius')
then
102 call json_get(params,
'delta', delta)
103 call json_get(params,
'approximation', read_str)
104 call json_get(params,
'freestream_velocity', uinf)
111 else if (trim(type) .eq.
'point_zone')
then
113 call json_get(params,
'base_value', uinf)
114 call json_get(params,
'zone_name', read_str)
115 call json_get(params,
'zone_value', zone_value)
122 else if (trim(type) .eq.
'field')
then
124 call json_get(params,
'file_name', read_str)
125 fname = trim(read_str)
130 mesh_fname = trim(read_str)
144 type(
field_t),
intent(inout) :: u
145 type(
field_t),
intent(inout) :: v
146 type(
field_t),
intent(inout) :: w
147 type(
field_t),
intent(inout) :: p
148 type(
coef_t),
intent(in) :: coef
149 type(
gs_t),
intent(inout) :: gs
150 procedure(
useric) :: usr_ic
151 type(json_file),
intent(inout) :: params
155 call usr_ic(u, v, w, p, params)
164 usr_ic_compressible, params)
165 type(
field_t),
intent(inout) :: rho
166 type(
field_t),
intent(inout) :: u
167 type(
field_t),
intent(inout) :: v
168 type(
field_t),
intent(inout) :: w
169 type(
field_t),
intent(inout) :: p
170 type(
coef_t),
intent(in) :: coef
171 type(
gs_t),
intent(inout) :: gs
173 type(json_file),
intent(inout) :: params
177 call neko_log%message(
"Type: user (compressible flows)")
178 call usr_ic_compressible(rho, u, v, w, p, params)
198 type(
field_t),
intent(inout) :: u
199 type(
field_t),
intent(inout) :: v
200 type(
field_t),
intent(inout) :: w
201 type(
field_t),
intent(inout) :: p
202 type(
coef_t),
intent(in) :: coef
203 type(
gs_t),
intent(inout) :: gs
218 call gs%op(u%x, u%dof%size(), gs_op_add)
219 call gs%op(v%x, v%dof%size(), gs_op_add)
220 call gs%op(w%x, w%dof%size(), gs_op_add)
227 call col2(u%x, coef%mult, u%dof%size())
228 call col2(v%x, coef%mult, v%dof%size())
229 call col2(w%x, coef%mult, w%dof%size())
236 type(
field_t),
intent(inout) :: u
237 type(
field_t),
intent(inout) :: v
238 type(
field_t),
intent(inout) :: w
239 real(kind=
rp),
intent(in) :: uinf(3)
241 character(len=LOG_SIZE) :: log_buf
243 call neko_log%message(
"Type : uniform")
244 write (log_buf,
'(A, 3(ES12.6, A))')
"Value: [", (uinf(i),
", ", i=1, 2), &
253 call cfill(u%x, uinf(1), n)
254 call cfill(v%x, uinf(2), n)
255 call cfill(w%x, uinf(3), n)
263 type(
field_t),
intent(inout) :: u
264 type(
field_t),
intent(inout) :: v
265 type(
field_t),
intent(inout) :: w
266 real(kind=
rp),
intent(in) :: delta
267 real(kind=
rp),
intent(in) :: uinf(3)
268 character(len=*),
intent(in) :: type
271 character(len=LOG_SIZE) :: log_buf
273 call neko_log%message(
"Type : blasius")
274 write (log_buf,
'(A,ES12.6)')
"delta : ", delta
276 call neko_log%message(
"Approximation : " // trim(type))
277 write (log_buf,
'(A,"[",2(ES12.6,","),ES12.6,"]")')
"Value : ", &
278 uinf(1), uinf(2), uinf(3)
281 select case (trim(type))
293 call neko_error(
'Invalid Blasius approximation')
296 if ((uinf(1) .gt. 0.0_rp) .and. (uinf(2) .eq. 0.0_rp) &
297 .and. (uinf(3) .eq. 0.0_rp))
then
298 do i = 1, u%dof%size()
299 u%x(i,1,1,1) = bla(u%dof%z(i,1,1,1), delta, uinf(1))
300 v%x(i,1,1,1) = 0.0_rp
301 w%x(i,1,1,1) = 0.0_rp
303 else if ((uinf(1) .eq. 0.0_rp) .and. (uinf(2) .gt. 0.0_rp) &
304 .and. (uinf(3) .eq. 0.0_rp))
then
305 do i = 1, u%dof%size()
306 u%x(i,1,1,1) = 0.0_rp
307 v%x(i,1,1,1) = bla(u%dof%x(i,1,1,1), delta, uinf(2))
308 w%x(i,1,1,1) = 0.0_rp
310 else if ((uinf(1) .eq. 0.0_rp) .and. (uinf(2) .eq. 0.0_rp) &
311 .and. (uinf(3) .gt. 0.0_rp))
then
312 do i = 1, u%dof%size()
313 u%x(i,1,1,1) = 0.0_rp
314 v%x(i,1,1,1) = 0.0_rp
315 w%x(i,1,1,1) = bla(u%dof%y(i,1,1,1), delta, uinf(3))
331 type(
field_t),
intent(inout) :: u
332 type(
field_t),
intent(inout) :: v
333 type(
field_t),
intent(inout) :: w
334 real(kind=
rp),
intent(in),
dimension(3) :: base_value
335 character(len=*),
intent(in) :: zone_name
336 real(kind=
rp),
intent(in) :: zone_value(:)
337 character(len=LOG_SIZE) :: log_buf
343 call neko_log%message(
"Type : point_zone")
344 write (log_buf,
'(A,ES12.6)')
"Base value : ", base_value
346 call neko_log%message(
"Zone name : " // trim(zone_name))
347 write (log_buf,
'(A,"[",2(ES12.6,","),ES12.6," ]")')
"Value : ", &
348 zone_value(1), zone_value(2), zone_value(3)
356 call cfill_mask(u%x, zone_value(1),
size, zone%mask, zone%size)
357 call cfill_mask(v%x, zone_value(2),
size, zone%mask, zone%size)
358 call cfill_mask(w%x, zone_value(3),
size, zone%mask, zone%size)
380 interpolate, tolerance, mesh_file_name)
381 type(
field_t),
intent(inout) :: u
382 type(
field_t),
intent(inout) :: v
383 type(
field_t),
intent(inout) :: w
384 type(
field_t),
intent(inout) :: p
385 character(len=*),
intent(in) :: file_name
386 logical,
intent(in) :: interpolate
387 real(kind=
rp),
intent(in) :: tolerance
388 character(len=*),
intent(inout) :: mesh_file_name
390 character(len=LOG_SIZE) :: log_buf
391 integer :: sample_idx, sample_mesh_idx
392 integer :: last_index
395 logical :: mesh_mismatch
406 call neko_log%message(
"Type : field")
407 call neko_log%message(
"File name : " // trim(file_name))
408 write (log_buf,
'(A,L1)')
"Interpolation : ", interpolate
410 if (interpolate)
then
416 if (sample_idx .eq. -1) &
417 call neko_error(
"Invalid file name for the initial condition. The&
418 & file format must be e.g. 'mean0.f00001'")
424 f =
file_t(trim(file_name))
426 if (interpolate)
then
429 if (mesh_file_name .eq.
"none")
then
430 mesh_file_name = trim(file_name)
431 sample_mesh_idx = sample_idx
437 if (sample_mesh_idx .eq. -1)
then
438 call neko_error(
"Invalid file name for the initial condition. &
439 &The file format must be e.g. 'mean0.f00001'")
442 write (log_buf,
'(A,ES12.6)')
"Tolerance : ", tolerance
444 write (log_buf,
'(A,A)')
"Mesh file : ", &
451 if (sample_mesh_idx .ne. sample_idx)
then
452 call f%set_counter(sample_mesh_idx)
453 call f%read(fld_data)
459 call f%set_counter(sample_idx)
460 call f%read(fld_data)
468 mesh_mismatch = (fld_data%glb_nelv .ne. u%msh%glb_nelv .or. &
469 fld_data%gdim .ne. u%msh%gdim)
471 if (mesh_mismatch .and. .not. interpolate)
then
472 call neko_error(
"The fld file must match the current mesh! &
473 &Use 'interpolate': 'true' to enable interpolation.")
474 else if (.not. mesh_mismatch .and. interpolate)
then
475 call neko_log%warning(
"You have activated interpolation but you might &
476 &still be using the same mesh.")
480 if (interpolate)
then
483 select type (ft => f%file_type)
485 if (.not. ft%dp_precision)
then
486 call neko_warning(
"The coordinates read from the field file are &
487 &in single precision.")
488 call neko_log%message(
"It is recommended to use a mesh in double &
489 &precision for better interpolation results.")
490 call neko_log%message(
"If the interpolation does not work, you&
491 &can try to increase the tolerance.")
497 global_interp = fld_data%generate_interpolator(u%dof, u%msh, &
501 call global_interp%evaluate(u%x, fld_data%u%x)
502 call global_interp%evaluate(v%x, fld_data%v%x)
503 call global_interp%evaluate(w%x, fld_data%w%x)
504 call global_interp%evaluate(p%x, fld_data%p%x)
506 call global_interp%free
511 call prev_xh%init(
gll, fld_data%lx, fld_data%ly, fld_data%lz)
512 call space_interp%init(u%Xh, prev_xh)
515 call space_interp%map_host(u%x, fld_data%u%x, fld_data%nelv, u%Xh)
516 call space_interp%map_host(v%x, fld_data%v%x, fld_data%nelv, u%Xh)
517 call space_interp%map_host(w%x, fld_data%w%x, fld_data%nelv, u%Xh)
518 call space_interp%map_host(p%x, fld_data%p%x, fld_data%nelv, u%Xh)
520 call space_interp%free
Copy data between host and device (or device and device)
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.
Abstract interface for user defined initial conditions.
Abstract interface for user defined initial conditions.
subroutine, public device_col2(a_d, b_d, n)
Vector multiplication .
subroutine, public device_cfill_mask(a_d, c, size, mask_d, mask_size)
Fill a constant to a masked vector. .
subroutine, public device_cfill(a_d, c, n)
Set all elements to a constant c .
Device abstraction, common interface for various accelerators.
integer, parameter, public host_to_device
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, usr_ic, params)
Set intial flow condition (user defined)
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_flow_ic_fld(u, v, w, p, file_name, interpolate, tolerance, mesh_file_name)
Set the initial condition of the flow based on a field. @detail The fields are read from an fld file....
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_compressible_flow_ic_usr(rho, u, v, w, p, coef, gs, usr_ic_compressible, params)
Set intial flow condition (user defined) for compressible flows.
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_linear(y, delta, u)
Linear approximate Blasius profile .
Implements global_interpolation given a dofmap.
Routines to interpolate between different spaces.
Utilities for retrieving parameters from the case files.
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, size, mask, mask_size)
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.
subroutine, public filename_suffix(fname, suffix)
Extract a filename's suffix.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
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.