36 use json_module,
only : json_file
70 real(kind=
rp) :: c_avisc_entropy
71 real(kind=
rp) :: c_avisc_low
79 type(
field_t),
pointer :: max_wave_speed => null()
80 type(
mesh_t),
pointer :: msh => null()
82 type(
gs_t),
pointer :: gs => null()
88 procedure, pass(this),
private :: compute_residual => &
90 procedure, pass(this),
private :: compute_viscosity => &
92 procedure, pass(this),
private :: smooth_viscosity => &
94 procedure, pass(this),
private :: apply_element_max => &
96 procedure, pass(this),
private :: low_order_viscosity => &
106 type(json_file),
intent(inout) :: json
107 type(
coef_t),
intent(in),
target :: coef
108 type(
dofmap_t),
intent(in),
target :: dof
109 type(
field_t),
intent(in),
target :: reg_coeff
111 call this%init_base(json, coef, dof, reg_coeff)
115 this%c_avisc_entropy, 1.0_rp)
117 call this%entropy_residual%init(dof,
'entropy_residual')
124 nullify(this%max_wave_speed)
134 call this%free_base()
135 call this%entropy_residual%free()
136 call this%S_lag%free()
143 nullify(this%max_wave_speed)
153 integer,
intent(in) :: tstep
154 real(kind=
rp),
intent(in) :: dt
156 call this%compute_residual(tstep, dt, time%dtlag)
157 call this%compute_viscosity(tstep)
163 integer,
intent(in) :: tstep
164 real(kind=
rp),
intent(in) :: dt
165 real(kind=
rp),
intent(in) :: dt_lag(10)
167 type(
field_t),
pointer :: us_field, vs_field, ws_field, div_field
168 integer :: temp_indices(4)
169 real(kind=
rp) :: bdf_coeffs(4)
171 real(kind=
rp) :: dt_local(10)
173 if (tstep .le. 3)
then
183 call bdf_scheme%compute_coeffs(bdf_coeffs, dt_local, 3)
187 this%entropy_residual%x_d, &
188 this%S%x_d, this%S_lag%lf(1)%x_d, &
189 this%S_lag%lf(2)%x_d, this%S_lag%lf(3)%x_d, &
193 this%entropy_residual%x, &
194 this%S%x, this%S_lag%lf(1)%x, &
195 this%S_lag%lf(2)%x, this%S_lag%lf(3)%x, &
206 call device_col3(us_field%x_d, this%u%x_d, this%S%x_d, n)
207 call device_col3(vs_field%x_d, this%v%x_d, this%S%x_d, n)
208 call device_col3(ws_field%x_d, this%w%x_d, this%S%x_d, n)
211 ws_field%x, this%u%x, this%v%x, this%w%x, this%S%x, n)
214 call div(div_field%x, us_field%x, vs_field%x, ws_field%x, this%coef)
217 call device_memcpy(this%entropy_residual%x, this%entropy_residual%x_d, &
226 call device_memcpy(this%entropy_residual%x, this%entropy_residual%x_d, &
236 integer,
intent(in) :: tstep
237 integer :: n, temp_indices(1)
238 real(kind=
rp) :: s_mean, n_s
239 type(
field_t),
pointer :: temp_field
243 if (tstep .le. 3)
then
262 call absval(temp_field%x, n)
266 n_s =
glmax(temp_field%x, n)
270 if (n_s < 1.0e-12_rp)
then
277 this%reg_coeff%x_d, this%entropy_residual%x_d, &
278 this%h%x_d, this%c_avisc_entropy, n_s, n)
281 this%reg_coeff%x, this%entropy_residual%x, &
282 this%h%x, this%c_avisc_entropy, n_s, n)
288 this%reg_coeff%x_d, this%h%x_d, this%max_wave_speed%x_d, &
292 this%reg_coeff%x, this%h%x, this%max_wave_speed%x, &
296 call this%apply_element_max()
298 call this%smooth_viscosity()
307 type(
field_t),
pointer :: temp_field, mult_field
308 integer :: temp_indices(2)
317 call field_copy(temp_field, this%reg_coeff, n)
325 this%reg_coeff%x_d, temp_field%x_d, mult_field%x_d, n)
328 this%reg_coeff%x, temp_field%x, mult_field%x, n)
343 this%reg_coeff%x_d, lx, this%msh%nelv)
346 this%reg_coeff%x, lx, this%msh%nelv)
354 type(
field_t),
target,
intent(inout) :: s
355 type(
field_t),
target,
intent(in) :: u, v, w, h, max_wave_speed
356 type(
mesh_t),
target,
intent(in) :: msh
357 type(
space_t),
target,
intent(in) :: xh
358 type(
gs_t),
target,
intent(in) :: gs
365 this%max_wave_speed => max_wave_speed
370 call this%S_lag%init(s, 3)
377 call this%S_lag%update()
382 integer,
intent(in) :: n
383 real(kind=
rp),
intent(out) :: us(n), vs(n), ws(n)
384 real(kind=
rp),
intent(in) :: u(n), v(n), w(n), s(n)
401 integer,
intent(in) :: n
402 real(kind=
rp),
intent(inout) :: entropy_residual(n)
403 real(kind=
rp),
intent(in) :: div_field(n)
412 entropy_residual(i) = abs(entropy_residual(i) + div_field(i))
420 integer,
intent(in) :: i
421 real(kind=
rp) :: visc
423 visc = this%c_avisc_low * this%h%x(i,1,1,1) * this%max_wave_speed%x(i,1,1,1)
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...
Compute the divergence of a vector field.
Backward-differencing scheme for time integration.
real(kind=rp) function, public device_glsum(a_d, n, strm)
Sum a vector of length n.
subroutine, public device_absval(a_d, n, strm)
subroutine, public device_col3(a_d, b_d, c_d, n, strm)
Vector multiplication with 3 vectors .
Device abstraction, common interface for various accelerators.
integer, parameter, public host_to_device
integer, parameter, public device_to_host
Defines a mapping of the degrees of freedom.
CPU backend for entropy viscosity regularization.
subroutine, public entropy_viscosity_compute_viscosity_cpu(reg_coeff, entropy_residual, h, c_avisc_entropy, n_s, n)
Compute viscosity from entropy residual on CPU.
subroutine, public entropy_viscosity_compute_residual_cpu(entropy_residual, s, s_lag1, s_lag2, s_lag3, bdf_coeffs, dt, n)
Compute entropy residual on CPU.
subroutine, public entropy_viscosity_smooth_divide_cpu(reg_coeff, temp_field, mult_field, n)
Divide by multiplicity for smoothing on CPU.
subroutine, public entropy_viscosity_clamp_to_low_order_cpu(reg_coeff, h, max_wave_speed, c_avisc_low, n)
Clamp regularization coefficient to low-order viscosity on CPU.
subroutine, public entropy_viscosity_apply_element_max_cpu(reg_coeff, lx, nelv)
Apply element-wise maximum on CPU.
Device backend for entropy viscosity regularization.
subroutine, public entropy_viscosity_smooth_divide_device(reg_coeff_d, temp_field_d, mult_field_d, n)
Divide by multiplicity for smoothing on device.
subroutine, public entropy_viscosity_clamp_to_low_order_device(reg_coeff_d, h_d, max_wave_speed_d, c_avisc_low, n)
Clamp regularization coefficient to low-order viscosity on device.
subroutine, public entropy_viscosity_apply_element_max_device(reg_coeff_d, lx, nelv)
Apply element-wise maximum on device.
subroutine, public entropy_viscosity_compute_residual_device(entropy_residual_d, s_d, s_lag1_d, s_lag2_d, s_lag3_d, bdf_coeffs, dt, n)
Compute entropy residual on device.
subroutine, public entropy_viscosity_compute_viscosity_device(reg_coeff_d, entropy_residual_d, h_d, c_avisc_entropy, n_s, n)
Compute viscosity from entropy residual on device.
subroutine entropy_viscosity_apply_element_max(this)
subroutine entropy_viscosity_abs_add_cpu(entropy_residual, div_field, n)
subroutine entropy_viscosity_col3_vector_cpu(us, vs, ws, u, v, w, s, n)
subroutine entropy_viscosity_update_lag(this)
subroutine entropy_viscosity_smooth_viscosity(this)
Cross-element smoothing via gather-scatter averaging. Averages viscosity values at shared nodes betwe...
subroutine entropy_viscosity_compute_viscosity(this, tstep)
subroutine entropy_viscosity_compute_residual(this, tstep, dt, dt_lag)
subroutine entropy_viscosity_compute(this, time, tstep, dt)
subroutine entropy_viscosity_init(this, json, coef, dof, reg_coeff)
subroutine entropy_viscosity_free(this)
pure real(kind=rp) function entropy_viscosity_low_order(this, i)
Compute low-order viscosity at point i: c_avisc_low * h * max_wave_speed.
subroutine, public entropy_viscosity_set_fields(this, s, u, v, w, h, max_wave_speed, msh, xh, gs)
subroutine, public field_cadd(a, s, n)
Add a scalar to vector .
subroutine, public field_cfill(a, c, n)
Set all elements to a constant c .
real(kind=rp) function, public field_glsum(a, n)
subroutine, public field_copy(a, b, n)
Copy a vector .
Contains the field_serties_t type.
Defines Gather-scatter operations.
integer, parameter, public gs_op_add
Utilities for retrieving parameters from the case files.
subroutine, public absval(a, n)
Take the absolute value of an array.
real(kind=rp) function, public glmax(a, n)
Max of a vector of length n.
integer, parameter neko_bcknd_device
integer, parameter, public rp
Global precision used in computations.
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.
Defines a function space.
Module with things related to the simulation time.
Implicit backward-differencing scheme for time integration.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Stores a series (sequence) of fields, logically connected to a base field, and arranged according to ...
The function space for the SEM solution fields.
A struct that contains all info about the time, expand as needed.