46 use,
intrinsic :: iso_c_binding
50 integer,
public,
parameter ::
gl = 0,
gll = 1,
gj = 2
74 real(kind=
rp),
allocatable :: zg(:,:)
76 real(kind=
rp),
allocatable :: dr_inv(:)
77 real(kind=
rp),
allocatable :: ds_inv(:)
78 real(kind=
rp),
allocatable :: dt_inv(:)
80 real(kind=
rp),
allocatable :: wx(:)
81 real(kind=
rp),
allocatable :: wy(:)
82 real(kind=
rp),
allocatable :: wz(:)
84 real(kind=
rp),
allocatable :: w3(:,:,:)
87 real(kind=
rp),
allocatable :: dx(:,:)
89 real(kind=
rp),
allocatable :: dy(:,:)
91 real(kind=
rp),
allocatable :: dz(:,:)
94 real(kind=
rp),
allocatable :: dxt(:,:)
96 real(kind=
rp),
allocatable :: dyt(:,:)
98 real(kind=
rp),
allocatable :: dzt(:,:)
101 real(kind=
rp),
allocatable :: v(:,:)
102 real(kind=
rp),
allocatable :: vt(:,:)
103 real(kind=
rp),
allocatable :: vinv(:,:)
104 real(kind=
rp),
allocatable :: vinvt(:,:)
106 real(kind=
rp),
allocatable :: w(:,:)
111 type(c_ptr) :: dr_inv_d = c_null_ptr
112 type(c_ptr) :: ds_inv_d = c_null_ptr
113 type(c_ptr) :: dt_inv_d = c_null_ptr
114 type(c_ptr) :: dxt_d = c_null_ptr
115 type(c_ptr) :: dyt_d = c_null_ptr
116 type(c_ptr) :: dzt_d = c_null_ptr
117 type(c_ptr) :: dx_d = c_null_ptr
118 type(c_ptr) :: dy_d = c_null_ptr
119 type(c_ptr) :: dz_d = c_null_ptr
120 type(c_ptr) :: wx_d = c_null_ptr
121 type(c_ptr) :: wy_d = c_null_ptr
122 type(c_ptr) :: wz_d = c_null_ptr
123 type(c_ptr) :: zg_d = c_null_ptr
124 type(c_ptr) :: w3_d = c_null_ptr
125 type(c_ptr) :: v_d = c_null_ptr
126 type(c_ptr) :: vt_d = c_null_ptr
127 type(c_ptr) :: vinv_d = c_null_ptr
128 type(c_ptr) :: vinvt_d = c_null_ptr
129 type(c_ptr) :: w_d = c_null_ptr
136 interface operator(.eq.)
138 end interface operator(.eq.)
140 interface operator(.ne.)
142 end interface operator(.ne.)
144 public ::
operator(.eq.),
operator(.ne.)
150 class(
space_t),
intent(inout) :: s
151 integer,
intent(in) :: t
152 integer,
intent(in) :: lx
153 integer,
intent(in) :: ly
154 integer,
optional,
intent(in) :: lz
155 integer :: ix, iy, iz
162 if (
present(lz))
then
165 if (lx .ne. ly .or. lx .ne. lz)
then
166 call neko_error(
"Unsupported polynomial dimension")
171 call neko_error(
"Unsupported polynomial dimension")
178 s%lxyz = s%lx*s%ly*s%lz
180 allocate(s%zg(lx, 3))
186 allocate(s%dr_inv(s%lx))
187 allocate(s%ds_inv(s%ly))
188 allocate(s%dt_inv(s%lz))
190 allocate(s%w3(s%lx, s%ly, s%lz))
192 allocate(s%dx(s%lx, s%lx))
193 allocate(s%dy(s%ly, s%ly))
194 allocate(s%dz(s%lz, s%lz))
196 allocate(s%dxt(s%lx, s%lx))
197 allocate(s%dyt(s%ly, s%ly))
198 allocate(s%dzt(s%lz, s%lz))
200 allocate(s%v(s%lx, s%lx))
201 allocate(s%vt(s%lx, s%lx))
202 allocate(s%vinv(s%lx, s%lx))
203 allocate(s%vinvt(s%lx, s%lx))
204 allocate(s%w(s%lx, s%lx))
208 call zwgll(s%zg(1,1), s%wx, s%lx)
209 call zwgll(s%zg(1,2), s%wy, s%ly)
210 if (s%lz .gt. 1)
then
211 call zwgll(s%zg(1,3), s%wz, s%lz)
216 else if (t .eq.
gl)
then
217 call zwgl(s%zg(1,1), s%wx, s%lx)
218 call zwgl(s%zg(1,2), s%wy, s%ly)
219 if (s%lz .gt. 1)
then
220 call zwgl(s%zg(1,3), s%wz, s%lz)
232 s%w3(ix, iy, iz) = s%wx(ix) * s%wy(iy) * s%wz(iz)
238 call dgll(s%dx, s%dxt, s%zg(1,1), s%lx, s%lx)
239 call dgll(s%dy, s%dyt, s%zg(1,2), s%ly, s%ly)
240 if (s%lz .gt. 1)
then
241 call dgll(s%dz, s%dzt, s%zg(1,3), s%lz, s%lz)
246 else if (t .eq.
gl)
then
247 call setup_intp(s%dx, s%dxt, s%zg(1,1), s%zg(1,1), s%lx, s%lx,1)
248 call setup_intp(s%dy, s%dyt, s%zg(1,2), s%zg(1,2), s%ly, s%ly,1)
249 if (s%lz .gt. 1)
then
250 call setup_intp(s%dz, s%dzt, s%zg(1,3), s%zg(1,3), s%lz, s%lz, 1)
261 if (s%lz .gt. 1)
then
324 class(
space_t),
intent(inout) :: s
326 if (
allocated(s%zg))
then
331 if (
allocated(s%wx))
then
336 if (
allocated(s%wy))
then
341 if (
allocated(s%wz))
then
346 if (
allocated(s%w3))
then
351 if (
allocated(s%dx))
then
356 if (
allocated(s%dy))
then
361 if (
allocated(s%dz))
then
366 if (
allocated(s%dxt))
then
371 if (
allocated(s%dyt))
then
376 if (
allocated(s%dzt))
then
381 if (
allocated(s%dr_inv))
then
386 if (
allocated(s%ds_inv))
then
391 if (
allocated(s%dt_inv))
then
396 if (
allocated(s%v))
then
401 if (
allocated(s%vt))
then
406 if (
allocated(s%vinv))
then
411 if (
allocated(s%vinvt))
then
416 if (
allocated(s%w))
then
426 type(
space_t),
intent(in) :: xh
427 type(
space_t),
intent(in) :: yh
430 if ( (xh%lx .eq. yh%lx) .and. &
431 (xh%ly .eq. yh%ly) .and. &
432 (xh%lz .eq. yh%lz) )
then
443 type(
space_t),
intent(in) :: xh
444 type(
space_t),
intent(in) :: yh
447 if ( (xh%lx .eq. yh%lx) .and. &
448 (xh%ly .eq. yh%ly) .and. &
449 (xh%lz .eq. yh%lz) )
then
458 integer,
intent(in) :: lx
459 real(kind=
rp),
intent(inout) :: dx(lx), x(lx)
463 dx(i) = 0.5*(x(i+1) - x(i-1))
465 dx(lx) = x(lx) - x(lx-1)
467 dx(i) = 1.0_rp / dx(i)
475 type(
space_t),
intent(inout) :: Xh
477 real(kind=
rp) :: l(0:xh%lx-1)
478 real(kind=
rp) :: delta(xh%lx)
479 integer :: i, kj, j, kk
481 logical :: scaled = .false.
483 associate(v=> xh%v, vt => xh%vt, &
484 vinv => xh%vinv, vinvt => xh%vinvt, w => xh%w)
503 delta(i) = 2.0_rp / (2*(i-1)+1)
506 delta(xh%lx) = 2.0_rp / (xh%lx-1)
510 delta(i) = sqrt(1.0_rp / delta(i))
515 v(i,j) = v(i,j) * delta(j)
520 call copy(vt, v, xh%lx * xh%lx)
521 call trsp1(vt, xh%lx)
537 call mxm(vt, xh%lx, w, xh%lx, vinv, xh%lx)
540 call copy(vinvt, vinv, xh%lx * xh%lx)
541 call trsp1(vinvt, xh%lx)
543 call copy(vt, v, xh%lxy)
544 call trsp1(vt, xh%lx)
545 call m%init(xh%lx, xh%lx)
546 call copy(m%x, v, xh%lxy)
547 call m%inverse_on_host()
548 call copy(vinv, m%x, xh%lxy)
549 call copy(vinvt, vinv, xh%lx * xh%lx)
550 call trsp1(vinvt, xh%lx)
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)
Device abstraction, common interface for various accelerators.
integer, parameter, public host_to_device
Fast diagonalization methods from NEKTON.
subroutine, public setup_intp(jh, jht, z_to, z_from, n_to, n_from, derivative)
Compute interpolation weights for points z_to using values at points z_from.
subroutine, public copy(a, b, n)
Copy a 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.
Defines a function space.
pure logical function space_ne(xh, yh)
Check if .
pure logical function space_eq(xh, yh)
Check if .
integer, parameter, public gll
subroutine space_compute_dist(dx, x, lx)
integer, parameter, public gj
subroutine space_free(s)
Deallocate a space s.
subroutine space_init(s, t, lx, ly, lz)
Initialize a function space s with given polynomial dimensions.
integer, parameter, public gl
subroutine space_generate_transformation_matrices(xh)
Generate spectral tranform matrices.
LIBRARY ROUTINES FOR SPECTRAL METHODS.
subroutine dgll(d, dt, z, nz, nzd)
Compute the derivative matrix D and its transpose DT associated with the Nth order Lagrangian interpo...
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 zwgl(z, w, np)
Generate NP Gauss Legendre points Z and weights W associated with Jacobi polynomial ....
subroutine, public trsp1(a, n)
In-place transpose of a square tensor.
The function space for the SEM solution fields.