39 use json_module,
only : json_file
45 use,
intrinsic :: iso_c_binding, only : c_ptr, c_null_ptr
51 "rst",
"rs",
"rt",
"st",
"r",
"s",
"t"]
65 character(len=:),
allocatable :: direction
67 character(len=:),
allocatable :: kernel_type
69 type(
coef_t),
pointer :: coef => null()
71 real(kind=
rp),
allocatable :: h1(:,:,:,:)
72 type(c_ptr) :: h1_d = c_null_ptr
74 real(kind=
rp),
allocatable :: ident(:,:)
75 type(c_ptr) :: ident_d = c_null_ptr
77 character(len=:),
allocatable :: nue_field_name
80 logical :: tvar_h1 = .false.
95 class(
svv_t),
intent(inout) :: this
96 type(json_file),
intent(inout) :: json
97 type(
coef_t),
intent(in),
target :: coef
98 type(
field_t),
intent(in) :: rho
99 real(kind=
rp),
allocatable :: transfer(:)
100 real(kind=
rp) :: nu_val, power_coef
101 character(len=:),
allocatable :: nu_type, direction, formulation
111 if (trim(formulation) .ne.
"one-sided")
then
112 call neko_error(
"This SVV operator only supports the one-sided " // &
117 this%direction = trim(direction)
123 allocate(transfer(lx))
125 call json_get(json,
"svv.kernel.type", this%kernel_type)
126 select case (trim(this%kernel_type))
129 if (power_coef .eq. 0.0_rp)
then
133 transfer(i) = 1.0_rp - ((i - 1.0_rp) / (lx - 1.0_rp)) ** &
134 ((lx - 1.0_rp) * power_coef)
142 call this%filter%init_from_components(coef,
"nonBoyd", transfer)
145 allocate(this%ident(lx, lx))
148 this%ident(i, i) = 1.0_rp
151 allocate(this%h1(lx, lx, lx, coef%msh%nelv))
153 call device_map(this%ident, this%ident_d, lx * lx)
156 call device_map(this%h1, this%h1_d, coef%dof%size())
159 call rzero(this%h1, coef%dof%size())
162 call json_get(json,
"svv.nu.type", nu_type)
163 select case (trim(nu_type))
168 call device_col2(this%h1_d, rho%x_d, coef%dof%size())
170 call cfill(this%h1, nu_val, coef%dof%size())
171 call col2(this%h1, rho%x, coef%dof%size())
175 this%tvar_h1, .true.)
176 call json_get(json,
"svv.nu.field_name", this%nue_field_name)
180 else if (.not. this%tvar_h1)
then
181 call neko_error(
"The static SVV viscosity field `" // &
182 this%nue_field_name //
"` does not exist")
185 call neko_error(
"Invalid svv.nu.type: " // trim(nu_type))
188 if (
allocated(nu_type))
deallocate(nu_type)
189 if (
allocated(direction))
deallocate(direction)
190 if (
allocated(formulation))
deallocate(formulation)
198 class(
svv_t),
intent(inout) :: this
199 type(
field_t),
intent(in) :: rho
200 integer,
intent(in) :: tstep
202 if (.not. this%tvar_h1)
return
203 if (.not.
associated(this%nue))
then
204 if (.not.
neko_registry%field_exists(this%nue_field_name))
then
205 call neko_error(
"The SVV viscosity field `" // &
206 this%nue_field_name //
"` does not exist at time step " // &
218 class(
svv_t),
intent(inout) :: this
219 type(
field_t),
intent(in) :: rho
222 call device_copy(this%h1_d, this%nue%x_d, this%coef%dof%size())
223 call device_col2(this%h1_d, rho%x_d, this%coef%dof%size())
225 call copy(this%h1, this%nue%x, this%coef%dof%size())
226 call col2(this%h1, rho%x, this%coef%dof%size())
233 class(
svv_t),
intent(inout) :: this
235 call this%filter%free()
236 if (
allocated(this%h1))
then
242 if (
allocated(this%ident))
then
246 deallocate(this%ident)
248 if (
allocated(this%direction))
deallocate(this%direction)
249 if (
allocated(this%kernel_type))
deallocate(this%kernel_type)
250 if (
allocated(this%nue_field_name))
deallocate(this%nue_field_name)
253 this%h1_d = c_null_ptr
254 this%ident_d = c_null_ptr
255 this%tvar_h1 = .false.
261 integer,
intent(in) :: value
262 character(len=32) :: string
263 write(string,
'(I0)')
value
Map a Fortran array to a device (allocate and associate)
Copy data between host and device (or device and device)
Unmap a Fortran array from a device (deassociate and free)
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.
subroutine, public device_rzero(a_d, n, strm)
Zero a real vector.
subroutine, public device_copy(a_d, b_d, n, strm)
Copy a vector .
subroutine, public device_col2(a_d, b_d, n, strm)
Vector multiplication .
subroutine, public device_cfill(a_d, c, n, strm)
Set all elements to a constant c .
Device abstraction, common interface for various accelerators.
integer, parameter, public host_to_device
Implements elementwise_filter_t.
Filter to be applied to a scalar field.
Utilities for retrieving parameters from the case files.
subroutine, public cfill(a, c, n)
Set all elements to a constant c .
subroutine, public col2(a, b, n)
Vector multiplication .
subroutine, public copy(a, b, n)
Copy a vector .
subroutine, public rzero(a, n)
Zero a real vector.
integer, parameter neko_bcknd_device
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.
Data and filter construction for spectral vanishing viscosity.
subroutine svv_free(this)
Release all resources owned by an SVV object.
subroutine svv_update_h1(this, rho, tstep)
Update a time-varying, field-valued SVV viscosity.
character(len=9), dimension(1), parameter known_formulations
subroutine svv_copy_viscosity(this, rho)
Copy the configured viscosity field and multiply it by density.
subroutine svv_init_from_json(this, json, coef, rho)
Construct an SVV object from case parameters.
character(len=5), dimension(1), parameter known_kernel_types
character(len=5), dimension(2), parameter known_nu_types
character(len=3), dimension(7), parameter known_directions
character(len=32) function to_string(value)
Convert an integer to a compact string.
subroutine, public neko_type_error(base_type, wrong_type, known_types)
Reports an error allocating a type for a particular base pointer class.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Implements the elementwise filter for SEM.
Spectral vanishing viscosity configuration and coefficients.