44 use,
intrinsic :: iso_c_binding
48 integer,
public,
parameter ::
gl = 0,
gll = 1,
gj = 2
72 real(kind=
rp),
allocatable :: zg(:,:)
74 real(kind=
rp),
allocatable :: dr_inv(:)
75 real(kind=
rp),
allocatable :: ds_inv(:)
76 real(kind=
rp),
allocatable :: dt_inv(:)
78 real(kind=
rp),
allocatable :: wx(:)
79 real(kind=
rp),
allocatable :: wy(:)
80 real(kind=
rp),
allocatable :: wz(:)
82 real(kind=
rp),
allocatable :: w3(:,:,:)
85 real(kind=
rp),
allocatable :: dx(:,:)
87 real(kind=
rp),
allocatable :: dy(:,:)
89 real(kind=
rp),
allocatable :: dz(:,:)
92 real(kind=
rp),
allocatable :: dxt(:,:)
94 real(kind=
rp),
allocatable :: dyt(:,:)
96 real(kind=
rp),
allocatable :: dzt(:,:)
99 real(kind=
rp),
allocatable :: v(:,:)
100 real(kind=
rp),
allocatable :: vt(:,:)
101 real(kind=
rp),
allocatable :: vinv(:,:)
102 real(kind=
rp),
allocatable :: vinvt(:,:)
104 real(kind=
rp),
allocatable :: w(:,:)
109 type(c_ptr) :: dr_inv_d = c_null_ptr
110 type(c_ptr) :: ds_inv_d = c_null_ptr
111 type(c_ptr) :: dt_inv_d = c_null_ptr
112 type(c_ptr) :: dxt_d = c_null_ptr
113 type(c_ptr) :: dyt_d = c_null_ptr
114 type(c_ptr) :: dzt_d = c_null_ptr
115 type(c_ptr) :: dx_d = c_null_ptr
116 type(c_ptr) :: dy_d = c_null_ptr
117 type(c_ptr) :: dz_d = c_null_ptr
118 type(c_ptr) :: wx_d = c_null_ptr
119 type(c_ptr) :: wy_d = c_null_ptr
120 type(c_ptr) :: wz_d = c_null_ptr
121 type(c_ptr) :: zg_d = c_null_ptr
122 type(c_ptr) :: w3_d = c_null_ptr
123 type(c_ptr) :: v_d = c_null_ptr
124 type(c_ptr) :: vt_d = c_null_ptr
125 type(c_ptr) :: vinv_d = c_null_ptr
126 type(c_ptr) :: vinvt_d = c_null_ptr
127 type(c_ptr) :: w_d = c_null_ptr
134 interface operator(.eq.)
136 end interface operator(.eq.)
138 interface operator(.ne.)
140 end interface operator(.ne.)
142 public ::
operator(.eq.),
operator(.ne.)
148 class(
space_t),
intent(inout) :: s
149 integer,
intent(in) :: t
150 integer,
intent(in) :: lx
151 integer,
intent(in) :: ly
152 integer,
optional,
intent(in) :: lz
153 integer :: ix, iy, iz
160 if (
present(lz))
then
163 if (lx .ne. ly .or. lx .ne. lz)
then
164 call neko_error(
"Unsupported polynomial dimension")
169 call neko_error(
"Unsupported polynomial dimension")
176 s%lxyz = s%lx*s%ly*s%lz
178 allocate(s%zg(lx, 3))
184 allocate(s%dr_inv(s%lx))
185 allocate(s%ds_inv(s%ly))
186 allocate(s%dt_inv(s%lz))
188 allocate(s%w3(s%lx, s%ly, s%lz))
190 allocate(s%dx(s%lx, s%lx))
191 allocate(s%dy(s%ly, s%ly))
192 allocate(s%dz(s%lz, s%lz))
194 allocate(s%dxt(s%lx, s%lx))
195 allocate(s%dyt(s%ly, s%ly))
196 allocate(s%dzt(s%lz, s%lz))
198 allocate(s%v(s%lx, s%lx))
199 allocate(s%vt(s%lx, s%lx))
200 allocate(s%vinv(s%lx, s%lx))
201 allocate(s%vinvt(s%lx, s%lx))
202 allocate(s%w(s%lx, s%lx))
206 call zwgll(s%zg(1,1), s%wx, s%lx)
207 call zwgll(s%zg(1,2), s%wy, s%ly)
208 if (s%lz .gt. 1)
then
209 call zwgll(s%zg(1,3), s%wz, s%lz)
214 else if (t .eq.
gl)
then
215 call zwgl(s%zg(1,1), s%wx, s%lx)
216 call zwgl(s%zg(1,2), s%wy, s%ly)
217 if (s%lz .gt. 1)
then
218 call zwgl(s%zg(1,3), s%wz, s%lz)
230 s%w3(ix, iy, iz) = s%wx(ix) * s%wy(iy) * s%wz(iz)
236 call dgll(s%dx, s%dxt, s%zg(1,1), s%lx, s%lx)
237 call dgll(s%dy, s%dyt, s%zg(1,2), s%ly, s%ly)
238 if (s%lz .gt. 1)
then
239 call dgll(s%dz, s%dzt, s%zg(1,3), s%lz, s%lz)
244 else if (t .eq.
gl)
then
245 call setup_intp(s%dx, s%dxt, s%zg(1,1), s%zg(1,1), s%lx, s%lx,1)
246 call setup_intp(s%dy, s%dyt, s%zg(1,2), s%zg(1,2), s%ly, s%ly,1)
247 if (s%lz .gt. 1)
then
248 call setup_intp(s%dz, s%dzt, s%zg(1,3), s%zg(1,3), s%lz, s%lz, 1)
259 if (s%lz .gt. 1)
then
310 class(
space_t),
intent(inout) :: s
312 if (
allocated(s%zg))
then
316 if (
allocated(s%wx))
then
320 if (
allocated(s%wy))
then
324 if (
allocated(s%wz))
then
328 if (
allocated(s%w3))
then
332 if (
allocated(s%dx))
then
336 if (
allocated(s%dy))
then
340 if (
allocated(s%dz))
then
344 if (
allocated(s%dxt))
then
348 if (
allocated(s%dyt))
then
352 if (
allocated(s%dzt))
then
356 if (
allocated(s%dr_inv))
then
360 if (
allocated(s%ds_inv))
then
364 if (
allocated(s%dt_inv))
then
368 if(
allocated(s%v))
then
372 if(
allocated(s%vt))
then
376 if(
allocated(s%vinv))
then
380 if(
allocated(s%vinvt))
then
384 if(
allocated(s%w))
then
392 if (c_associated(s%dr_inv_d))
then
396 if (c_associated(s%ds_inv_d))
then
400 if (c_associated(s%dt_inv_d))
then
404 if (c_associated(s%dxt_d))
then
408 if (c_associated(s%dyt_d))
then
412 if (c_associated(s%dzt_d))
then
416 if (c_associated(s%dx_d))
then
420 if (c_associated(s%dy_d))
then
424 if (c_associated(s%dz_d))
then
428 if (c_associated(s%wx_d))
then
432 if (c_associated(s%wy_d))
then
436 if (c_associated(s%wz_d))
then
440 if (c_associated(s%w3_d))
then
444 if (c_associated(s%zg_d))
then
448 if (c_associated(s%v_d))
then
452 if (c_associated(s%vt_d))
then
456 if (c_associated(s%vinv_d))
then
460 if (c_associated(s%vinvt_d))
then
464 if (c_associated(s%w_d))
then
473 type(
space_t),
intent(in) :: xh
474 type(
space_t),
intent(in) :: yh
477 if ( (xh%lx .eq. yh%lx) .and. &
478 (xh%ly .eq. yh%ly) .and. &
479 (xh%lz .eq. yh%lz) )
then
490 type(
space_t),
intent(in) :: xh
491 type(
space_t),
intent(in) :: yh
494 if ( (xh%lx .eq. yh%lx) .and. &
495 (xh%ly .eq. yh%ly) .and. &
496 (xh%lz .eq. yh%lz) )
then
505 integer,
intent(in) :: lx
506 real(kind=
rp),
intent(inout) :: dx(lx), x(lx)
510 dx(i) = 0.5*(x(i+1) - x(i-1))
512 dx(lx) = x(lx) - x(lx-1)
514 dx(i) = 1.0_rp / dx(i)
522 type(
space_t),
intent(inout) :: Xh
524 real(kind=
rp) :: l(0:xh%lx-1)
525 real(kind=
rp) :: delta(xh%lx)
526 integer :: i, kj, j, j2, kk
528 associate(v=> xh%v, vt => xh%vt, &
529 vinv => xh%vinv, vinvt => xh%vinvt, w => xh%w)
537 l(j2) = ( (2*j2-1) * xh%zg(j,1) * l(j2-1) &
538 - (j2-1) * l(j2-2) ) / j2
551 delta(i) = 2.0_rp / (2*(i-1)+1)
554 delta(xh%lx) = 2.0_rp / (xh%lx-1)
558 delta(i) = sqrt(1.0_rp / delta(i))
563 v(i,j) = v(i,j) * delta(j)
568 call copy(vt, v, xh%lx * xh%lx)
569 call trsp1(vt, xh%lx)
585 call mxm(vt, xh%lx, w, xh%lx, vinv, xh%lx)
588 call copy(vinvt, vinv, xh%lx * xh%lx)
589 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)
Device abstraction, common interface for various accelerators.
integer, parameter, public host_to_device
subroutine, public device_free(x_d)
Deallocate memory on the 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_hip
integer, parameter neko_bcknd_device
integer, parameter neko_bcknd_opencl
integer, parameter neko_bcknd_cuda
integer, parameter, public rp
Global precision used in computations.
Defines a function space.
pure logical function space_ne(Xh, Yh)
Check if .
subroutine space_generate_transformation_matrices(Xh)
Generate spectral tranform matrices.
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
LIBRARY ROUTINES FOR SPECTRAL METHODS.
subroutine zwgll(Z, W, NP)
subroutine dgll(D, DT, Z, NZ, NZD)
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.