37 use json_module,
only : json_file
73 character(len=1024) :: bf_rgstry_pref
75 logical :: baseflow_set = .false.
78 logical :: baseflow_is_ic = .false.
81 type(
field_t),
pointer :: fringe => null()
83 real(kind=
rp) :: amplitudes(3)
85 character(len=1024) :: fringe_registry_name
87 logical :: dump_fields = .false.
89 character(NEKO_FNAME_LEN) :: dump_fname
91 logical :: check = .true.
96 procedure, pass(this) :: init_constant => &
99 procedure, pass(this) :: init_user => &
102 procedure, pass(this) :: init_field => &
105 procedure, pass(this) :: init_common => &
118 type(json_file),
intent(inout) :: json
120 type(
coef_t),
intent(in),
target :: coef
121 character(len=*),
intent(in) :: variable_name
123 real(kind=
rp),
allocatable :: amplitudes(:)
124 character(len=:),
allocatable :: baseflow_method
125 character(len=:),
allocatable :: read_str, fringe_registry_name, &
126 bf_registry_pref, dump_fname
127 character(len=NEKO_FNAME_LEN) :: fname, mesh_fname
128 logical :: interpolate, dump_fields
129 real(kind=
rp),
allocatable :: constant_value(:)
130 real(kind=
rp) :: start_time, end_time, tolerance
133 type(json_file) :: baseflow_subdict
142 fringe_registry_name,
"sponge_fringe")
144 call json_get(json,
"amplitudes", amplitudes)
145 if (
size(amplitudes) .ne. 3)
then
146 call neko_error(
"(SPONGE) Expected 3 elements for 'amplitudes'")
155 call json_get(baseflow_subdict,
"method", baseflow_method)
157 bf_registry_pref,
"sponge_bf")
159 select case (trim(baseflow_method))
171 call json_get(baseflow_subdict,
'file_name', read_str)
172 fname = trim(read_str)
179 mesh_fname = trim(read_str)
181 call this%init_field(fields, coef, start_time, end_time, amplitudes, &
182 fringe_registry_name, bf_registry_pref, dump_fields, dump_fname, &
183 fname, interpolate, tolerance, mesh_fname)
188 call json_get(baseflow_subdict,
"value", constant_value)
189 if (
size(constant_value) .lt. 3)
then
190 call neko_error(
"(SPONGE) Expected 3 elements for 'value'")
193 call this%init_constant(fields, coef, start_time, end_time, &
194 amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, &
195 dump_fname, constant_value)
200 call this%init_user(fields, coef, start_time, end_time, amplitudes, &
201 fringe_registry_name, bf_registry_pref, dump_fields, dump_fname)
204 call neko_error(
"(SPONGE) " // trim(baseflow_method) // &
205 " is not a valid method")
214 amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, &
215 dump_fname, constant_values)
218 type(
coef_t),
intent(in),
target :: coef
219 real(kind=
rp),
intent(in) :: start_time, end_time
220 real(kind=
rp),
intent(in) :: amplitudes(:)
221 character(len=*),
intent(in) :: fringe_registry_name, dump_fname, &
223 logical,
intent(in) :: dump_fields
224 real(kind=
rp),
intent(in) :: constant_values(:)
230 amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, &
236 call neko_log%message(
"Initializing bf fields", &
240 trim(bf_registry_pref) //
"_u")
242 trim(bf_registry_pref) //
"_v")
244 trim(bf_registry_pref) //
"_w")
246 this%u_bf =>
neko_registry%get_field(trim(bf_registry_pref) //
"_u")
247 this%v_bf =>
neko_registry%get_field(trim(bf_registry_pref) //
"_v")
248 this%w_bf =>
neko_registry%get_field(trim(bf_registry_pref) //
"_w")
253 this%u_bf = constant_values(1)
254 this%v_bf = constant_values(2)
255 this%w_bf = constant_values(3)
257 this%baseflow_set = .true.
263 amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, &
264 dump_fname, file_name, interpolate, tolerance, mesh_file_name)
267 type(
coef_t),
intent(in),
target :: coef
268 real(kind=
rp),
intent(in) :: start_time, end_time
269 real(kind=
rp),
intent(in) :: amplitudes(:)
270 character(len=*),
intent(in) :: fringe_registry_name, dump_fname, &
272 logical,
intent(in) :: dump_fields
273 character(len=*),
intent(in) :: file_name
274 logical,
intent(in) :: interpolate
275 real(kind=
rp),
intent(in) :: tolerance
276 character(len=*),
intent(inout) :: mesh_file_name
285 amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, &
291 call neko_log%message(
"Initializing bf fields", &
295 trim(bf_registry_pref) //
"_u")
297 trim(bf_registry_pref) //
"_v")
299 trim(bf_registry_pref) //
"_w")
301 this%u_bf =>
neko_registry%get_field(trim(bf_registry_pref) //
"_u")
302 this%v_bf =>
neko_registry%get_field(trim(bf_registry_pref) //
"_v")
303 this%w_bf =>
neko_registry%get_field(trim(bf_registry_pref) //
"_w")
314 call wk%init(this%u%dof)
317 file_name, interpolate, tolerance, mesh_file_name)
322 call device_memcpy(this%u_bf%x, this%u_bf%x_d, this%u_bf%size(), &
324 call device_memcpy(this%v_bf%x, this%v_bf%x_d, this%v_bf%size(), &
326 call device_memcpy(this%w_bf%x, this%w_bf%x_d, this%w_bf%size(), &
330 this%baseflow_set = .true.
336 amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, &
340 type(
coef_t),
intent(in),
target :: coef
341 real(kind=
rp),
intent(in) :: start_time, end_time
342 real(kind=
rp),
intent(in) :: amplitudes(:)
343 character(len=*),
intent(in) :: fringe_registry_name, dump_fname, &
345 logical,
intent(in) :: dump_fields
351 amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, &
358 amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, &
362 type(
coef_t),
intent(in),
target :: coef
363 real(kind=
rp),
intent(in) :: start_time, end_time
364 real(kind=
rp),
intent(in) :: amplitudes(:)
365 character(len=*),
intent(in) :: fringe_registry_name, dump_fname, &
367 logical,
intent(in) :: dump_fields
372 call this%init_base(fields, coef, start_time, end_time)
374 this%amplitudes(1) = amplitudes(1)
375 this%amplitudes(2) = amplitudes(2)
376 this%amplitudes(3) = amplitudes(3)
378 this%fringe_registry_name = trim(fringe_registry_name)
379 this%bf_rgstry_pref = trim(bf_registry_pref)
380 this%dump_fields = dump_fields
381 this%dump_fname = trim(dump_fname)
385 call neko_log%message(
"Pointing at fields u,v,w", &
397 call this%free_base()
407 this%fringe_registry_name =
""
408 this%bf_rgstry_pref =
""
409 this%baseflow_set = .false.
429 integer :: i, nfields
430 type(
field_t),
pointer :: fu, fv, fw
432 type(json_file) :: json_subdict
433 character(len=:),
allocatable :: string_val
435 character(len=1024) :: u_name, v_name, w_name
445 u_name = trim(this%bf_rgstry_pref) //
"_u"
446 v_name = trim(this%bf_rgstry_pref) //
"_v"
447 w_name = trim(this%bf_rgstry_pref) //
"_w"
450 this%baseflow_set =
neko_registry%field_exists(trim(u_name)) &
454 if (.not. this%baseflow_set)
then
455 call neko_error(
"SPONGE: No baseflow set (searching for " // &
456 trim(this%bf_rgstry_pref) //
"_u)")
461 trim(this%fringe_registry_name)))
then
462 call neko_error(
"SPONGE: No fringe field set (" // &
463 this%fringe_registry_name //
" not found)")
483 if (this%dump_fields)
then
484 call fout%init(
sp, trim(this%dump_fname), 4)
485 call fout%fields%assign_to_ptr(1, this%fringe)
486 call fout%fields%assign_to_field(2, this%u_bf)
487 call fout%fields%assign_to_field(3, this%v_bf)
488 call fout%fields%assign_to_field(4, this%w_bf)
489 call fout%sample(time%t)
499 fu => this%fields%get(1)
500 fv => this%fields%get(2)
501 fw => this%fields%get(3)
507 call device_sub3(wk%x_d, this%u_bf%x_d, this%u%x_d, this%u%size())
509 call device_col2(wk%x_d, this%fringe%x_d, this%fringe%size())
514 call device_sub3(wk%x_d, this%v_bf%x_d, this%v%x_d, this%v%size())
515 call device_col2(wk%x_d, this%fringe%x_d, this%fringe%size())
519 call device_sub3(wk%x_d, this%w_bf%x_d, this%w%x_d, this%w%size())
520 call device_col2(wk%x_d, this%fringe%x_d, this%fringe%size())
524 call sub3(wk%x, this%u_bf%x, this%u%x, this%u%size())
525 call col2(wk%x, this%fringe%x, this%fringe%size())
526 call add2s2(fu%x, wk%x, this%amplitudes(1), fu%dof%size())
528 call sub3(wk%x, this%v_bf%x, this%v%x, this%v%size())
529 call col2(wk%x, this%fringe%x, this%fringe%size())
530 call add2s2(fv%x, wk%x, this%amplitudes(2), fv%dof%size())
532 call sub3(wk%x, this%w_bf%x, this%w%x, this%w%size())
533 call col2(wk%x, this%fringe%x, this%fringe%size())
534 call add2s2(fw%x, wk%x, this%amplitudes(3), fw%dof%size())
Copy data between host and device (or device and device)
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.
Defines a simulation case.
integer, public pe_rank
MPI rank.
subroutine, public device_sub3(a_d, b_d, c_d, n, strm)
Vector subtraction .
subroutine, public device_add2s2(a_d, b_d, c1, n, strm)
Vector addition with scalar multiplication (multiplication on first argument)
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
Module for file I/O operations.
Implements fld_file_output_t.
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....
Utilities for retrieving parameters from the case files.
integer, parameter, public neko_log_debug
Debug log level.
type(log_t), public neko_log
Global log stream.
subroutine, public sub3(a, b, c, n)
Vector subtraction .
subroutine, public col2(a, b, n)
Vector multiplication .
subroutine, public add2s2(a, b, c1, n)
Vector addition with scalar multiplication (multiplication on second argument)
integer, parameter neko_bcknd_device
integer, parameter, public dp
integer, parameter, public sp
integer, parameter, public rp
Global precision used in computations.
Defines a registry for storing solution fields.
type(registry_t), target, public neko_registry
Global field registry.
Defines a registry for storing and requesting temporary objects This can be used when you have a func...
type(scratch_registry_t), target, public neko_scratch_registry
Global scratch registry.
Contains the simcomp_executor_t type.
type(simcomp_executor_t), target, public neko_simcomps
Global variable for the simulation component driver.
Implements the source_term_t type and a wrapper source_term_wrapper_t.
Implements the sponge_t type.
subroutine sponge_init_field(this, fields, coef, start_time, end_time, amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, dump_fname, file_name, interpolate, tolerance, mesh_file_name)
Initialize a sponge with a baseflow imported from a field file.
subroutine sponge_init_from_json(this, json, fields, coef, variable_name)
Constructor from json.
subroutine sponge_init_user(this, fields, coef, start_time, end_time, amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, dump_fname)
Initialize a sponge with a baseflow set by the user.
subroutine sponge_free(this)
Destructor.
subroutine sponge_compute(this, time)
Compute the sponge field. The sponge is applied according to the following definition: f_x = amp_x * ...
subroutine sponge_init_constant(this, fields, coef, start_time, end_time, amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, dump_fname, constant_values)
Initialize a sponge with a constant baseflow.
subroutine sponge_init_common(this, fields, coef, start_time, end_time, amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, dump_fname)
Common constructor.
Module with things related to the simulation time.
integer, parameter, public neko_fname_len
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...
A simple output saving a list of fields to a .fld file.
Base abstract type for source terms.
A struct that contains all info about the time, expand as needed.