49 use json_module,
only : json_file
72 type(
field_t),
intent(inout) :: u
73 type(
field_t),
intent(inout) :: v
74 type(
field_t),
intent(inout) :: w
75 type(
field_t),
intent(inout) :: p
76 type(
coef_t),
intent(in) :: coef
77 type(
gs_t),
intent(inout) :: gs
78 character(len=*) :: type
79 type(json_file),
intent(inout) :: params
80 real(kind=
rp) :: delta, tol
81 real(kind=
rp),
allocatable :: uinf(:)
82 real(kind=
rp),
allocatable :: zone_value(:)
83 character(len=:),
allocatable :: read_str
84 character(len=NEKO_FNAME_LEN) :: fname, mesh_fname
85 logical :: interpolate
91 if (trim(type) .eq.
'uniform')
then
93 call json_get(params,
'case.fluid.initial_condition.value', uinf)
99 else if (trim(type) .eq.
'blasius')
then
101 call json_get(params,
'case.fluid.blasius.delta', delta)
102 call json_get(params,
'case.fluid.blasius.approximation', &
104 call json_get(params,
'case.fluid.blasius.freestream_velocity', uinf)
111 else if (trim(type) .eq.
'point_zone')
then
113 call json_get(params,
'case.fluid.initial_condition.base_value', uinf)
114 call json_get(params,
'case.fluid.initial_condition.zone_name', &
116 call json_get(params,
'case.fluid.initial_condition.zone_value', &
124 else if (trim(type) .eq.
'field')
then
126 call json_get(params,
'case.fluid.initial_condition.file_name', &
128 fname = trim(read_str)
130 'case.fluid.initial_condition.interpolate', interpolate, &
133 'case.fluid.initial_condition.tolerance', tol, 0.000001_rp)
135 'case.fluid.initial_condition.mesh_file_name', read_str, &
137 mesh_fname = trim(read_str)
151 type(
field_t),
intent(inout) :: u
152 type(
field_t),
intent(inout) :: v
153 type(
field_t),
intent(inout) :: w
154 type(
field_t),
intent(inout) :: p
155 type(
coef_t),
intent(in) :: coef
156 type(
gs_t),
intent(inout) :: gs
157 procedure(
useric) :: usr_ic
158 type(json_file),
intent(inout) :: params
162 call usr_ic(u, v, w, p, params)
169 type(
field_t),
intent(inout) :: u
170 type(
field_t),
intent(inout) :: v
171 type(
field_t),
intent(inout) :: w
172 type(
field_t),
intent(inout) :: p
173 type(
coef_t),
intent(in) :: coef
174 type(
gs_t),
intent(inout) :: gs
189 call gs%op(u%x, u%dof%size(), gs_op_add)
190 call gs%op(v%x, v%dof%size(), gs_op_add)
191 call gs%op(w%x, w%dof%size(), gs_op_add)
198 call col2(u%x, coef%mult, u%dof%size())
199 call col2(v%x, coef%mult, v%dof%size())
200 call col2(w%x, coef%mult, w%dof%size())
207 type(
field_t),
intent(inout) :: u
208 type(
field_t),
intent(inout) :: v
209 type(
field_t),
intent(inout) :: w
210 real(kind=
rp),
intent(in) :: uinf(3)
212 character(len=LOG_SIZE) :: log_buf
214 call neko_log%message(
"Type : uniform")
215 write (log_buf,
'(A, 3(ES12.6, A))')
"Value: [", (uinf(i),
", ", i=1, 2), &
224 call cfill(u%x, uinf(1), n)
225 call cfill(v%x, uinf(2), n)
226 call cfill(w%x, uinf(3), n)
234 type(
field_t),
intent(inout) :: u
235 type(
field_t),
intent(inout) :: v
236 type(
field_t),
intent(inout) :: w
237 real(kind=
rp),
intent(in) :: delta
238 real(kind=
rp),
intent(in) :: uinf(3)
239 character(len=*),
intent(in) :: type
242 character(len=LOG_SIZE) :: log_buf
244 call neko_log%message(
"Type : blasius")
245 write (log_buf,
'(A,ES12.6)')
"delta : ", delta
247 call neko_log%message(
"Approximation : " // trim(type))
248 write (log_buf,
'(A,"[",2(ES12.6,","),ES12.6,"]")')
"Value : ", &
249 uinf(1), uinf(2), uinf(3)
252 select case (trim(type))
264 call neko_error(
'Invalid Blasius approximation')
267 if ((uinf(1) .gt. 0.0_rp) .and. (uinf(2) .eq. 0.0_rp) &
268 .and. (uinf(3) .eq. 0.0_rp))
then
269 do i = 1, u%dof%size()
270 u%x(i,1,1,1) = bla(u%dof%z(i,1,1,1), delta, uinf(1))
271 v%x(i,1,1,1) = 0.0_rp
272 w%x(i,1,1,1) = 0.0_rp
274 else if ((uinf(1) .eq. 0.0_rp) .and. (uinf(2) .gt. 0.0_rp) &
275 .and. (uinf(3) .eq. 0.0_rp))
then
276 do i = 1, u%dof%size()
277 u%x(i,1,1,1) = 0.0_rp
278 v%x(i,1,1,1) = bla(u%dof%x(i,1,1,1), delta, uinf(2))
279 w%x(i,1,1,1) = 0.0_rp
281 else if ((uinf(1) .eq. 0.0_rp) .and. (uinf(2) .eq. 0.0_rp) &
282 .and. (uinf(3) .gt. 0.0_rp))
then
283 do i = 1, u%dof%size()
284 u%x(i,1,1,1) = 0.0_rp
285 v%x(i,1,1,1) = 0.0_rp
286 w%x(i,1,1,1) = bla(u%dof%y(i,1,1,1), delta, uinf(3))
302 type(
field_t),
intent(inout) :: u
303 type(
field_t),
intent(inout) :: v
304 type(
field_t),
intent(inout) :: w
305 real(kind=
rp),
intent(in),
dimension(3) :: base_value
306 character(len=*),
intent(in) :: zone_name
307 real(kind=
rp),
intent(in) :: zone_value(:)
308 character(len=LOG_SIZE) :: log_buf
314 call neko_log%message(
"Type : point_zone")
315 write (log_buf,
'(A,ES12.6)')
"Base value : ", base_value
317 call neko_log%message(
"Zone name : " // trim(zone_name))
318 write (log_buf,
'(A,"[",2(ES12.6,","),ES12.6," ]")')
"Value : ", &
319 zone_value(1), zone_value(2), zone_value(3)
327 call cfill_mask(u%x, zone_value(1),
size, zone%mask, zone%size)
328 call cfill_mask(v%x, zone_value(2),
size, zone%mask, zone%size)
329 call cfill_mask(w%x, zone_value(3),
size, zone%mask, zone%size)
351 interpolate, tolerance, mesh_file_name)
352 type(
field_t),
intent(inout) :: u
353 type(
field_t),
intent(inout) :: v
354 type(
field_t),
intent(inout) :: w
355 type(
field_t),
intent(inout) :: p
356 character(len=*),
intent(in) :: file_name
357 logical,
intent(in) :: interpolate
358 real(kind=
rp),
intent(in) :: tolerance
359 character(len=*),
intent(inout) :: mesh_file_name
361 character(len=LOG_SIZE) :: log_buf
362 integer :: sample_idx, sample_mesh_idx
363 integer :: last_index
366 logical :: mesh_mismatch
377 call neko_log%message(
"Type : field")
378 call neko_log%message(
"File name : " // trim(file_name))
379 write (log_buf,
'(A,L1)')
"Interpolation : ", interpolate
381 if (interpolate)
then
387 if (sample_idx .eq. -1) &
388 call neko_error(
"Invalid file name for the initial condition. The&
389 & file format must be e.g. 'mean0.f00001'")
395 f =
file_t(trim(file_name))
397 if (interpolate)
then
400 if (mesh_file_name .eq.
"none")
then
401 mesh_file_name = trim(file_name)
402 sample_mesh_idx = sample_idx
408 if (sample_mesh_idx .eq. -1) &
409 call neko_error(
"Invalid file name for the initial condition. &
410&The file format must be e.g. 'mean0.f00001'")
412 write (log_buf,
'(A,ES12.6)')
"Tolerance : ", tolerance
414 write (log_buf,
'(A,A)')
"Mesh file : ", &
421 if (sample_mesh_idx .ne. sample_idx)
then
422 call f%set_counter(sample_mesh_idx)
423 call f%read(fld_data)
429 call f%set_counter(sample_idx)
430 call f%read(fld_data)
438 mesh_mismatch = (fld_data%glb_nelv .ne. u%msh%glb_nelv .or. &
439 fld_data%gdim .ne. u%msh%gdim)
441 if (mesh_mismatch .and. .not. interpolate)
then
442 call neko_error(
"The fld file must match the current mesh! &
443&Use 'interpolate': 'true' to enable interpolation.")
444 else if (.not. mesh_mismatch .and. interpolate)
then
445 call neko_log%warning(
"You have activated interpolation but you might &
446&still be using the same mesh.")
450 if (interpolate)
then
453 select type (ft => f%file_type)
455 if (.not. ft%dp_precision)
then
456 call neko_warning(
"The coordinates read from the field file are &
457&in single precision.")
458 call neko_log%message(
"It is recommended to use a mesh in double &
459&precision for better interpolation results.")
460 call neko_log%message(
"If the interpolation does not work, you&
461&can try to increase the tolerance.")
467 global_interp = fld_data%generate_interpolator(u%dof, u%msh, &
471 call global_interp%evaluate(u%x, fld_data%u%x)
472 call global_interp%evaluate(v%x, fld_data%v%x)
473 call global_interp%evaluate(w%x, fld_data%w%x)
474 call global_interp%evaluate(p%x, fld_data%p%x)
476 call global_interp%free
481 call prev_xh%init(
gll, fld_data%lx, fld_data%ly, fld_data%lz)
482 call space_interp%init(u%Xh, prev_xh)
485 call space_interp%map_host(u%x, fld_data%u%x, fld_data%nelv, u%Xh)
486 call space_interp%map_host(v%x, fld_data%v%x, fld_data%nelv, u%Xh)
487 call space_interp%map_host(w%x, fld_data%w%x, fld_data%nelv, u%Xh)
488 call space_interp%map_host(p%x, fld_data%p%x, fld_data%nelv, u%Xh)
490 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.
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_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.