37 use json_module,
only : json_file
76 character(len=1024) :: bf_rgstry_pref
78 logical :: baseflow_set = .false.
81 logical :: baseflow_is_ic = .false.
84 type(
field_t),
pointer :: fringe => null()
86 real(kind=
rp) :: amplitudes(3)
88 character(len=1024) :: fringe_registry_name
90 logical :: dump_fields = .false.
92 character(NEKO_FNAME_LEN) :: dump_fname
94 logical :: check = .true.
99 procedure, pass(this) :: init_constant => &
102 procedure, pass(this) :: init_user => &
105 procedure, pass(this) :: init_field => &
108 procedure, pass(this) :: init_noop => &
111 procedure, pass(this) :: init_common => &
124 type(json_file),
intent(inout) :: json
126 type(
coef_t),
intent(in),
target :: coef
127 character(len=*),
intent(in) :: variable_name
129 real(kind=
rp),
allocatable :: amplitudes(:)
130 character(len=:),
allocatable :: baseflow_method
131 character(len=:),
allocatable :: read_str, fringe_registry_name, &
132 bf_registry_pref, dump_fname
133 character(len=NEKO_FNAME_LEN) :: fname, mesh_fname
134 logical :: interpolate, dump_fields
135 real(kind=
rp),
allocatable :: constant_value(:)
136 real(kind=
rp) :: start_time, end_time, tolerance
139 type(json_file) :: baseflow_subdict
148 fringe_registry_name,
"sponge_fringe")
151 if (
size(amplitudes) .ne. 3)
then
152 call neko_error(
"(SPONGE) Expected 3 elements for 'amplitudes'")
161 call json_get(baseflow_subdict,
"method", baseflow_method)
163 bf_registry_pref,
"sponge_bf")
165 select case (trim(baseflow_method))
177 call json_get(baseflow_subdict,
'file_name', read_str)
178 fname = trim(read_str)
183 mesh_fname = trim(read_str)
186 type(json_file) :: interp_subdict
190 call this%init_field(fields, coef, start_time, end_time, amplitudes, &
191 fringe_registry_name, bf_registry_pref, dump_fields, dump_fname, &
192 fname, interpolate, mesh_fname, interp_subdict)
199 if (
size(constant_value) .lt. 3)
then
200 call neko_error(
"(SPONGE) Expected 3 elements for 'value'")
203 call this%init_constant(fields, coef, start_time, end_time, &
204 amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, &
205 dump_fname, constant_value)
210 call this%init_user(fields, coef, start_time, end_time, amplitudes, &
211 fringe_registry_name, bf_registry_pref, dump_fields, dump_fname)
216 call this%init_noop(fields, coef, start_time, end_time, &
217 amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, &
221 call neko_error(
"(SPONGE) " // trim(baseflow_method) // &
222 " is not a valid method")
232 amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, &
235 type(field_list_t),
intent(in),
target :: fields
236 type(coef_t),
intent(in),
target :: coef
237 real(kind=rp),
intent(in) :: start_time, end_time
238 real(kind=rp),
intent(in) :: amplitudes(:)
239 character(len=*),
intent(in) :: fringe_registry_name, dump_fname, &
241 logical,
intent(in) :: dump_fields
242 character(len=LOG_SIZE) :: log_buf
249 amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, &
255 this%u_bf => neko_registry%get_field(trim(bf_registry_pref) //
"_u")
256 this%v_bf => neko_registry%get_field(trim(bf_registry_pref) //
"_v")
257 this%w_bf => neko_registry%get_field(trim(bf_registry_pref) //
"_w")
259 call neko_log%message(
"Baseflow : from existing sponge", lvl = neko_log_info)
261 this%baseflow_set = .true.
268 amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, &
269 dump_fname, constant_values)
271 type(field_list_t),
intent(in),
target :: fields
272 type(coef_t),
intent(in),
target :: coef
273 real(kind=rp),
intent(in) :: start_time, end_time
274 real(kind=rp),
intent(in) :: amplitudes(:)
275 character(len=*),
intent(in) :: fringe_registry_name, dump_fname, &
277 logical,
intent(in) :: dump_fields
278 real(kind=rp),
intent(in) :: constant_values(:)
279 character(len=LOG_SIZE) :: log_buf
286 amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, &
292 call neko_registry%add_field(this%u%dof, &
293 trim(bf_registry_pref) //
"_u")
294 call neko_registry%add_field(this%v%dof, &
295 trim(bf_registry_pref) //
"_v")
296 call neko_registry%add_field(this%w%dof, &
297 trim(bf_registry_pref) //
"_w")
299 this%u_bf => neko_registry%get_field(trim(bf_registry_pref) //
"_u")
300 this%v_bf => neko_registry%get_field(trim(bf_registry_pref) //
"_v")
301 this%w_bf => neko_registry%get_field(trim(bf_registry_pref) //
"_w")
306 this%u_bf = constant_values(1)
307 this%v_bf = constant_values(2)
308 this%w_bf = constant_values(3)
310 call neko_log%message(
"Baseflow : constant", lvl = neko_log_info)
311 write (log_buf,
'(A, 3(ES12.6, A))')
"Value : [", &
312 (constant_values(i),
", ", i = 1, 2), constant_values(3),
"]"
313 call neko_log%message(log_buf, lvl = neko_log_info)
315 this%baseflow_set = .true.
321 amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, &
322 dump_fname, file_name, interpolate, mesh_file_name, interp_subdict)
324 type(field_list_t),
intent(in),
target :: fields
325 type(coef_t),
intent(in),
target :: coef
326 real(kind=rp),
intent(in) :: start_time, end_time
327 real(kind=rp),
intent(in) :: amplitudes(:)
328 character(len=*),
intent(in) :: fringe_registry_name, dump_fname, &
330 logical,
intent(in) :: dump_fields
331 character(len=*),
intent(in) :: file_name
332 logical,
intent(in) :: interpolate
333 character(len=*),
intent(inout) :: mesh_file_name
334 type(json_file),
intent(inout) :: interp_subdict
343 amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, &
346 call neko_log%message(
"Baseflow : field", lvl = neko_log_info)
351 call neko_registry%add_field(this%u%dof, &
352 trim(bf_registry_pref) //
"_u")
353 call neko_registry%add_field(this%v%dof, &
354 trim(bf_registry_pref) //
"_v")
355 call neko_registry%add_field(this%w%dof, &
356 trim(bf_registry_pref) //
"_w")
358 this%u_bf => neko_registry%get_field(trim(bf_registry_pref) //
"_u")
359 this%v_bf => neko_registry%get_field(trim(bf_registry_pref) //
"_v")
360 this%w_bf => neko_registry%get_field(trim(bf_registry_pref) //
"_w")
365 if (trim(mesh_file_name) .eq.
'none')
then
366 call import_fields(file_name, interp_subdict, &
367 u = this%u_bf, v = this%v_bf, w = this%w_bf, &
368 interpolate = interpolate)
370 call import_fields(file_name, interp_subdict, mesh_file_name, &
371 u = this%u_bf, v = this%v_bf, w = this%w_bf, &
372 interpolate = interpolate)
375 this%baseflow_set = .true.
381 amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, &
384 type(field_list_t),
intent(in),
target :: fields
385 type(coef_t),
intent(in),
target :: coef
386 real(kind=rp),
intent(in) :: start_time, end_time
387 real(kind=rp),
intent(in) :: amplitudes(:)
388 character(len=*),
intent(in) :: fringe_registry_name, dump_fname, &
390 logical,
intent(in) :: dump_fields
396 amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, &
399 call neko_log%message(
"Baseflow : user", lvl = neko_log_info)
405 amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, &
408 type(field_list_t),
intent(in),
target :: fields
409 type(coef_t),
intent(in),
target :: coef
410 real(kind=rp),
intent(in) :: start_time, end_time
411 real(kind=rp),
intent(in) :: amplitudes(:)
412 character(len=*),
intent(in) :: fringe_registry_name, dump_fname, &
414 logical,
intent(in) :: dump_fields
416 character(len=LOG_SIZE) :: log_buf
420 call neko_log%message(
"Initializing sponge", lvl = neko_log_debug)
423 call this%init_base(fields, coef, start_time, end_time)
425 this%amplitudes(1) = amplitudes(1)
426 this%amplitudes(2) = amplitudes(2)
427 this%amplitudes(3) = amplitudes(3)
429 write (log_buf,
'(A, 3(ES12.6, A))')
"Amplitudes : [", &
430 (amplitudes(i),
", ", i = 1, 2), amplitudes(3),
"]"
431 call neko_log%message(log_buf, lvl=neko_log_info)
433 this%fringe_registry_name = trim(fringe_registry_name)
434 this%bf_rgstry_pref = trim(bf_registry_pref)
435 this%dump_fields = dump_fields
436 this%dump_fname = trim(dump_fname)
438 call neko_log%message(
"Fringe name : " // trim(fringe_registry_name), &
440 call neko_log%message(
"Baseflow prefix: " // trim(bf_registry_pref), &
443 write (log_buf,
"(A,L1)")
"Dump fields : ", this%dump_fields
444 call neko_log%message(log_buf, lvl=neko_log_info)
446 this%u => neko_registry%get_field_by_name(
"u")
447 this%v => neko_registry%get_field_by_name(
"v")
448 this%w => neko_registry%get_field_by_name(
"w")
456 call this%free_base()
466 this%fringe_registry_name =
""
467 this%bf_rgstry_pref =
""
468 this%baseflow_set = .false.
486 type(time_state_t),
intent(in) :: time
488 integer :: i, nfields
489 type(field_t),
pointer :: fu, fv, fw
491 type(json_file) :: json_subdict
492 character(len=:),
allocatable :: string_val
494 character(len=1024) :: u_name, v_name, w_name
495 type(fld_file_output_t) :: fout
497 type(field_t),
pointer :: wk
504 u_name = trim(this%bf_rgstry_pref) //
"_u"
505 v_name = trim(this%bf_rgstry_pref) //
"_v"
506 w_name = trim(this%bf_rgstry_pref) //
"_w"
509 this%baseflow_set = neko_registry%field_exists(trim(u_name)) &
510 .and. neko_registry%field_exists(trim(v_name)) .and. &
511 neko_registry%field_exists(trim(w_name))
513 if (.not. this%baseflow_set)
then
514 call neko_error(
"SPONGE: No baseflow set (searching for " // &
515 trim(this%bf_rgstry_pref) //
"_u)")
519 if (.not. neko_registry%field_exists( &
520 trim(this%fringe_registry_name)))
then
521 call neko_error(
"SPONGE: No fringe field set (" // &
522 trim(this%fringe_registry_name) //
" not found)")
528 neko_registry%get_field(trim(this%fringe_registry_name))
532 this%u_bf => neko_registry%get_field(trim(u_name))
533 this%v_bf => neko_registry%get_field(trim(v_name))
534 this%w_bf => neko_registry%get_field(trim(w_name))
542 if (this%dump_fields)
then
543 call fout%init(sp, trim(this%dump_fname), 4)
544 call fout%fields%assign_to_ptr(1, this%fringe)
545 call fout%fields%assign_to_field(2, this%u_bf)
546 call fout%fields%assign_to_field(3, this%v_bf)
547 call fout%fields%assign_to_field(4, this%w_bf)
548 call fout%sample(time%t)
556 if (neko_bcknd_device .eq. 1)
then
557 call sponge_source_term_compute_device(this%fields, &
558 this%u, this%v, this%w, this%u_bf, this%v_bf, this%w_bf, &
560 this%amplitudes(1), this%amplitudes(2), this%amplitudes(3))
562 call sponge_source_term_compute_cpu(this%fields, &
563 this%u, this%v, this%w, this%u_bf, this%v_bf, this%w_bf, &
565 this%amplitudes(1), this%amplitudes(2), this%amplitudes(3))
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.
Importation of fields from fld files.
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.
integer, parameter, public neko_log_debug
Debug.
type(log_t), public neko_log
Global log stream.
integer, parameter, public log_size
integer, parameter, public neko_log_info
Default.
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 cpu kernel for the sponge_source_term_t type.
subroutine, public sponge_source_term_compute_cpu(fields, u, v, w, u_bf, v_bf, w_bf, fringe, a_x, a_y, a_z)
Computes the generic sponge source term on the cpu.
Implements the device kernel for the sponge_source_term_t type.
subroutine, public sponge_source_term_compute_device(fields, u, v, w, u_bf, v_bf, w_bf, fringe, a_x, a_y, a_z)
Computes the sponge source term on the device.
Implements the sponge_t type.
subroutine sponge_init_noop(this, fields, coef, start_time, end_time, amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, dump_fname)
Initialize a sponge that reuses an already existing baseflow in the registry.
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_field(this, fields, coef, start_time, end_time, amplitudes, fringe_registry_name, bf_registry_pref, dump_fields, dump_fname, file_name, interpolate, mesh_file_name, interp_subdict)
Initialize a sponge with a baseflow imported from a field file.
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.