49 use json_module,
only : json_file
76 type(
field_t),
intent(inout) :: u
77 type(
field_t),
intent(inout) :: v
78 type(
field_t),
intent(inout) :: w
79 type(
field_t),
intent(inout) :: p
80 type(
coef_t),
intent(in) :: coef
81 type(
gs_t),
intent(inout) :: gs
82 character(len=*) :: type
83 type(json_file),
intent(inout) :: params
84 real(kind=
rp) :: delta, tol
85 real(kind=
rp),
allocatable :: uinf(:)
86 real(kind=
rp),
allocatable :: zone_value(:)
87 character(len=:),
allocatable :: read_str
88 character(len=NEKO_FNAME_LEN) :: fname, mesh_fname
89 logical :: interpolate
95 if (trim(type) .eq.
'uniform')
then
103 else if (trim(type) .eq.
'blasius')
then
106 call json_get(params,
'approximation', read_str)
114 else if (trim(type) .eq.
'point_zone')
then
117 call json_get(params,
'zone_name', read_str)
125 else if (trim(type) .eq.
'field')
then
127 call json_get(params,
'file_name', read_str)
128 fname = trim(read_str)
134 mesh_fname = trim(read_str)
148 type(
field_t),
target,
intent(inout) :: u
149 type(
field_t),
target,
intent(inout) :: v
150 type(
field_t),
target,
intent(inout) :: w
151 type(
field_t),
target,
intent(inout) :: p
152 type(
coef_t),
intent(in) :: coef
153 type(
gs_t),
intent(inout) :: gs
155 character(len=*),
intent(in) :: scheme_name
163 call fields%assign_to_field(1, u)
164 call fields%assign_to_field(2, v)
165 call fields%assign_to_field(3, w)
166 call fields%assign_to_field(4, p)
168 call user_proc(scheme_name, fields)
177 user_proc, scheme_name)
178 type(
field_t),
target,
intent(inout) :: rho
179 type(
field_t),
target,
intent(inout) :: u
180 type(
field_t),
target,
intent(inout) :: v
181 type(
field_t),
target,
intent(inout) :: w
182 type(
field_t),
target,
intent(inout) :: p
183 type(
coef_t),
intent(in) :: coef
184 type(
gs_t),
intent(inout) :: gs
186 character(len=*),
intent(in) :: scheme_name
191 call neko_log%message(
"Type: user (compressible flows)")
194 call fields%assign_to_field(1, rho)
195 call fields%assign_to_field(2, u)
196 call fields%assign_to_field(3, v)
197 call fields%assign_to_field(4, w)
198 call fields%assign_to_field(5, p)
199 call user_proc(scheme_name, fields)
212 call gs%op(p%x, p%dof%size(), gs_op_add)
213 call gs%op(rho%x, rho%dof%size(), gs_op_add)
216 call device_col2(rho%x_d, coef%mult_d, rho%dof%size())
219 call col2(rho%x, coef%mult, rho%dof%size())
220 call col2(p%x, coef%mult, p%dof%size())
226 type(
field_t),
intent(inout) :: u
227 type(
field_t),
intent(inout) :: v
228 type(
field_t),
intent(inout) :: w
229 type(
field_t),
intent(inout) :: p
230 type(
coef_t),
intent(in) :: coef
231 type(
gs_t),
intent(inout) :: gs
247 call gs%op(u%x, u%dof%size(), gs_op_add)
248 call gs%op(v%x, v%dof%size(), gs_op_add)
249 call gs%op(w%x, w%dof%size(), gs_op_add)
257 call col2(u%x, coef%mult, u%dof%size())
258 call col2(v%x, coef%mult, v%dof%size())
259 call col2(w%x, coef%mult, w%dof%size())
266 type(
field_t),
intent(inout) :: u
267 type(
field_t),
intent(inout) :: v
268 type(
field_t),
intent(inout) :: w
269 real(kind=
rp),
intent(in) :: uinf(3)
271 character(len=LOG_SIZE) :: log_buf
273 call neko_log%message(
"Type : uniform")
274 write (log_buf,
'(A, 3(ES12.6, A))')
"Value: [", &
275 (uinf(i),
", ", i = 1, 2), uinf(3),
"]"
283 call cfill(u%x, uinf(1), n)
284 call cfill(v%x, uinf(2), n)
285 call cfill(w%x, uinf(3), n)
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) :: delta
297 real(kind=
rp),
intent(in) :: uinf(3)
298 character(len=*),
intent(in) :: type
301 character(len=LOG_SIZE) :: log_buf
303 call neko_log%message(
"Type : blasius")
304 write (log_buf,
'(A,ES12.6)')
"delta : ", delta
306 call neko_log%message(
"Approximation : " // trim(type))
307 write (log_buf,
'(A,"[",2(ES12.6,","),ES12.6,"]")')
"Value : ", &
308 uinf(1), uinf(2), uinf(3)
311 select case (trim(type))
325 call neko_error(
'Invalid Blasius approximation')
328 if ((uinf(1) .gt. 0.0_rp) .and.
abscmp(uinf(2), 0.0_rp) &
329 .and.
abscmp(uinf(3), 0.0_rp))
then
330 do i = 1, u%dof%size()
331 u%x(i,1,1,1) = bla(u%dof%z(i,1,1,1), delta, uinf(1))
332 v%x(i,1,1,1) = 0.0_rp
333 w%x(i,1,1,1) = 0.0_rp
335 else if (
abscmp(uinf(1), 0.0_rp) .and. (uinf(2) .gt. 0.0_rp) &
336 .and.
abscmp(uinf(3), 0.0_rp))
then
337 do i = 1, u%dof%size()
338 u%x(i,1,1,1) = 0.0_rp
339 v%x(i,1,1,1) = bla(u%dof%x(i,1,1,1), delta, uinf(2))
340 w%x(i,1,1,1) = 0.0_rp
342 else if (
abscmp(uinf(1), 0.0_rp) .and.
abscmp(uinf(2), 0.0_rp) &
343 .and. (uinf(3) .gt. 0.0_rp))
then
344 do i = 1, u%dof%size()
345 u%x(i,1,1,1) = 0.0_rp
346 v%x(i,1,1,1) = 0.0_rp
347 w%x(i,1,1,1) = bla(u%dof%y(i,1,1,1), delta, uinf(3))
363 type(
field_t),
intent(inout) :: u
364 type(
field_t),
intent(inout) :: v
365 type(
field_t),
intent(inout) :: w
366 real(kind=
rp),
intent(in),
dimension(3) :: base_value
367 character(len=*),
intent(in) :: zone_name
368 real(kind=
rp),
intent(in) :: zone_value(:)
369 character(len=LOG_SIZE) :: log_buf
375 call neko_log%message(
"Type : point_zone")
376 write (log_buf,
'(A,ES12.6)')
"Base value : ", base_value
378 call neko_log%message(
"Zone name : " // trim(zone_name))
379 write (log_buf,
'(A,"[",2(ES12.6,","),ES12.6," ]")')
"Value : ", &
380 zone_value(1), zone_value(2), zone_value(3)
388 call cfill_mask(u%x, zone_value(1),
size, zone%mask%get(), zone%size)
389 call cfill_mask(v%x, zone_value(2),
size, zone%mask%get(), zone%size)
390 call cfill_mask(w%x, zone_value(3),
size, zone%mask%get(), zone%size)
412 interpolate, tolerance, mesh_file_name)
413 type(
field_t),
intent(inout) :: u
414 type(
field_t),
intent(inout) :: v
415 type(
field_t),
intent(inout) :: w
416 type(
field_t),
intent(inout) :: p
417 character(len=*),
intent(in) :: file_name
418 logical,
intent(in) :: interpolate
419 real(kind=
rp),
intent(in) :: tolerance
420 character(len=*),
intent(inout) :: mesh_file_name
422 character(len=LOG_SIZE) :: log_buf
423 integer :: sample_idx, sample_mesh_idx
424 integer :: last_index
427 logical :: mesh_mismatch
438 call neko_log%message(
"Type : field")
439 call neko_log%message(
"File name : " // trim(file_name))
440 write (log_buf,
'(A,L1)')
"Interpolation : ", interpolate
442 if (interpolate)
then
448 if (sample_idx .eq. -1) &
449 call neko_error(
"Invalid file name for the initial condition. The&
450 & file format must be e.g. 'mean0.f00001'")
456 call f%init(trim(file_name))
458 if (interpolate)
then
461 if (mesh_file_name .eq.
"none")
then
462 mesh_file_name = trim(file_name)
463 sample_mesh_idx = sample_idx
469 if (sample_mesh_idx .eq. -1)
then
470 call neko_error(
"Invalid file name for the initial condition. &
471 &The file format must be e.g. 'mean0.f00001'")
474 write (log_buf,
'(A,ES12.6)')
"Tolerance : ", tolerance
476 write (log_buf,
'(A,A)')
"Mesh file : ", &
483 if (sample_mesh_idx .ne. sample_idx)
then
484 call f%set_counter(sample_mesh_idx)
485 call f%read(fld_data)
491 call f%set_counter(sample_idx)
492 call f%read(fld_data)
500 mesh_mismatch = (fld_data%glb_nelv .ne. u%msh%glb_nelv .or. &
501 fld_data%gdim .ne. u%msh%gdim)
503 if (mesh_mismatch .and. .not. interpolate)
then
504 call neko_error(
"The fld file must match the current mesh! &
505 &Use 'interpolate': 'true' to enable interpolation.")
506 else if (.not. mesh_mismatch .and. interpolate)
then
507 call neko_log%warning(
"You have activated interpolation but you might &
508 &still be using the same mesh.")
512 if (interpolate)
then
515 select type (ft => f%file_type)
517 if (.not. ft%dp_precision)
then
518 call neko_warning(
"The coordinates read from the field file are &
519 &in single precision.")
520 call neko_log%message(
"It is recommended to use a mesh in double &
521 &precision for better interpolation results.")
522 call neko_log%message(
"If the interpolation does not work, you&
523 &can try to increase the tolerance.")
530 call device_memcpy(fld_data%x%x, fld_data%x%x_d, fld_data%x%size(), &
532 call device_memcpy(fld_data%y%x, fld_data%y%x_d, fld_data%y%size(), &
534 call device_memcpy(fld_data%z%x, fld_data%z%x_d, fld_data%z%size(), &
539 call fld_data%generate_interpolator(global_interp, u%dof, u%msh, &
547 call global_interp%evaluate(u%x(:,1,1,1), fld_data%u%x, .false.)
548 call global_interp%evaluate(v%x(:,1,1,1), fld_data%v%x, .false.)
549 call global_interp%evaluate(w%x(:,1,1,1), fld_data%w%x, .false.)
550 call global_interp%evaluate(p%x(:,1,1,1), fld_data%p%x, .false.)
556 call global_interp%free
561 call prev_xh%init(
gll, fld_data%lx, fld_data%ly, fld_data%lz)
562 call space_interp%init(u%Xh, prev_xh)
565 call space_interp%map_host(u%x, fld_data%u%x, fld_data%nelv, u%Xh)
566 call space_interp%map_host(v%x, fld_data%v%x, fld_data%nelv, u%Xh)
567 call space_interp%map_host(w%x, fld_data%w%x, fld_data%nelv, u%Xh)
568 call space_interp%map_host(p%x, fld_data%p%x, fld_data%nelv, u%Xh)
570 call space_interp%free
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.
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
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 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, public 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_common(u, v, w, p, coef, gs)
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.
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, 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.