43 use json_module,
only : json_file
52 use,
intrinsic :: iso_c_binding, only : c_ptr, c_null_ptr
60 character(len=:),
allocatable :: filter_type
66 real(kind=
rp),
allocatable :: fh(:,:), fht(:,:)
67 type(c_ptr) :: fh_d = c_null_ptr
68 type(c_ptr) :: fht_d = c_null_ptr
70 real(kind=
rp),
allocatable :: transfer(:)
75 procedure, pass(this) :: init_from_components => &
89 type(json_file),
intent(inout) :: json
90 type(
coef_t),
intent(in),
target :: coef
91 real(kind=
rp),
allocatable :: transfer(:)
92 character(len=:),
allocatable :: filter_type
95 filter_type,
"nonBoyd")
97 if (json%valid_path(
'transfer_function'))
then
98 call json_get(json,
'transfer_function', transfer)
101 if (
allocated(transfer))
then
102 call this%init_from_components(coef, filter_type, transfer)
104 call this%init_from_components(coef, filter_type)
108 if (
allocated(transfer))
then
112 if (
allocated(filter_type))
then
113 deallocate(filter_type)
125 type(
coef_t),
intent(in),
target :: coef
126 character(len=*),
intent(in) :: filter_type
127 real(kind=
rp),
intent(in),
optional :: transfer(:)
133 call this%init_base(coef)
137 this%filter_type = filter_type
139 allocate(this%fh(nx, nx))
140 allocate(this%fht(nx, nx))
141 allocate(this%transfer(nx))
143 call rzero(this%fh, nx*nx)
144 call rzero(this%fht, nx*nx)
145 call rone(this%transfer, nx)
147 if (
present(transfer))
then
148 if (
size(transfer) .eq. nx)
then
149 this%transfer = transfer
151 call neko_error(
"The transfer function of the elementwise " // &
152 "filter must correspond the order of the polynomial")
157 call device_map(this%fh, this%fh_d, this%nx * this%nx)
158 call device_map(this%fht, this%fht_d, this%nx * this%nx)
160 call device_cfill(this%fht_d, 0.0_rp, this%nx * this%nx)
174 if (
allocated(this%filter_type))
then
175 deallocate(this%filter_type)
178 if (
allocated(this%fh))
then
185 if (
allocated(this%fht))
then
192 if (
allocated(this%transfer))
then
193 deallocate(this%transfer)
196 this%filter_type =
""
200 call this%free_base()
209 this%nx, this%filter_type)
222 type(
field_t),
intent(inout) :: F_out
223 type(
field_t),
intent(in) :: F_in
226 call tnsr3d(f_out%x, this%nx, f_in%x, this%nx, this%fh, this%fht, &
227 this%fht, this%coef%msh%nelv)
239 integer,
intent(in) :: nx
240 real(kind=
rp),
intent(inout) :: fh(nx, nx), fht(nx, nx)
241 real(kind=
rp),
intent(in) :: transfer(nx)
242 real(kind=
rp) :: diag(nx, nx), rmult(nx), lj(nx), zpts(nx)
244 integer :: n, i, j, k
246 character(len=*),
intent(in) :: filter_type
248 call phi%init(nx, nx)
249 call pht%init(nx, nx)
251 call zwgll(zpts, rmult, nx)
257 select case (filter_type)
262 pht%x(k, j) = lj(k) - lj(k - 2)
269 call trsp(phi%x, nx, pht%x, nx)
277 diag(i, i) = transfer(i)
280 call mxm (diag, nx, pht%x, nx, fh, nx)
281 call mxm (phi%x, nx, fh, nx, pht%x, nx)
283 call copy (fh, pht%x, nx*nx)
284 call trsp (fht, nx, fh, nx)
Map a Fortran array to a device (allocate and associate)
Copy data between host and device (or device and device)
Synchronize a device or stream.
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_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.
subroutine build_1d_cpu(fh, fht, transfer, nx, filter_type)
Build the 1d filter for an element on the CPU. Suppose field x is filtered into x_hat by x_hat = fh*x...
subroutine elementwise_filter_init_from_components(this, coef, filter_type, transfer)
Actual Constructor.
subroutine elementwise_filter_init_from_json(this, json, coef)
Constructor.
subroutine elementwise_filter_free(this)
Destructor.
subroutine build_1d(this)
Build the 1d filter for an element.
subroutine elementwise_field_filter_3d(this, f_out, f_in)
Filter a 3D field.
Filter to be applied to a scalar field.
Utilities for retrieving parameters from the case files.
subroutine, public rone(a, n)
Set all elements to one.
subroutine, public copy(a, b, n)
Copy a vector .
subroutine, public rzero(a, n)
Zero a real vector.
Wrapper for all matrix-matrix product implementations.
subroutine, public mxm(a, n1, b, n2, c, n3)
Compute matrix-matrix product for contiguously packed matrices A,B, and C.
integer, parameter neko_bcknd_device
integer, parameter, public rp
Global precision used in computations.
LIBRARY ROUTINES FOR SPECTRAL METHODS.
subroutine zwgll(z, w, np)
Generate NP Gauss-Lobatto Legendre points (Z) and weights (W) associated with Jacobi polynomial P(N)(...
subroutine legendre_poly(l, x, n)
Evaluate Legendre polynomials of degrees 0-N at point x and store in array L.
subroutine, public trsp(a, lda, b, ldb)
Transpose of a rectangular tensor .
subroutine, public tnsr3d(v, nv, u, nu, a, bt, ct, nelv)
Tensor product performed on nelv elements.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Implements the elementwise filter for SEM.
Base abstract class for filter.