47 use,
intrinsic :: iso_c_binding, only: c_ptr, c_null_ptr
63 real(kind=
rp),
allocatable :: temp(:), tbf(:)
65 real(kind=
rp),
allocatable :: tx(:), ty(:), tz(:)
66 real(kind=
rp),
allocatable :: vr(:), vs(:), vt(:)
68 type(c_ptr) :: temp_d = c_null_ptr
70 type(c_ptr) :: tbf_d = c_null_ptr
72 type(c_ptr) :: tx_d = c_null_ptr
74 type(c_ptr) :: ty_d = c_null_ptr
76 type(c_ptr) :: tz_d = c_null_ptr
78 type(c_ptr) :: vr_d = c_null_ptr
80 type(c_ptr) :: vs_d = c_null_ptr
82 type(c_ptr) :: vt_d = c_null_ptr
104 integer,
intent(in) :: lxd
105 type(
coef_t),
intent(inout),
target :: coef
106 integer :: nel, n_GL, n
108 call this%Xh_GL%init(
gl, lxd, lxd, lxd)
109 this%Xh_GLL => coef%Xh
110 this%coef_GLL => coef
111 call this%GLL_to_GL%init(this%Xh_GL, this%Xh_GLL)
113 call this%coef_GL%init(this%Xh_GL, coef%msh)
116 n_gl = nel*this%Xh_GL%lxyz
118 call this%GLL_to_GL%map(this%coef_GL%drdx, coef%drdx, nel, this%Xh_GL)
119 call this%GLL_to_GL%map(this%coef_GL%dsdx, coef%dsdx, nel, this%Xh_GL)
120 call this%GLL_to_GL%map(this%coef_GL%dtdx, coef%dtdx, nel, this%Xh_GL)
121 call this%GLL_to_GL%map(this%coef_GL%drdy, coef%drdy, nel, this%Xh_GL)
122 call this%GLL_to_GL%map(this%coef_GL%dsdy, coef%dsdy, nel, this%Xh_GL)
123 call this%GLL_to_GL%map(this%coef_GL%dtdy, coef%dtdy, nel, this%Xh_GL)
124 call this%GLL_to_GL%map(this%coef_GL%drdz, coef%drdz, nel, this%Xh_GL)
125 call this%GLL_to_GL%map(this%coef_GL%dsdz, coef%dsdz, nel, this%Xh_GL)
126 call this%GLL_to_GL%map(this%coef_GL%dtdz, coef%dtdz, nel, this%Xh_GL)
130 allocate(this%temp(n_gl))
131 allocate(this%tbf(n_gl))
132 allocate(this%tx(n_gl))
133 allocate(this%ty(n_gl))
134 allocate(this%tz(n_gl))
135 allocate(this%vr(n_gl))
136 allocate(this%vs(n_gl))
137 allocate(this%vt(n_gl))
174 type(
space_t),
intent(inout) :: Xh
175 type(
coef_t),
intent(inout) :: coef
176 type(
field_t),
intent(inout) :: vx, vy, vz
177 type(
field_t),
intent(inout) :: fx, fy, fz
178 integer,
intent(in) :: n
179 real(kind=
rp),
intent(in),
optional :: dt
181 real(kind=
rp),
dimension(this%Xh_GL%lxyz) :: tx, ty, tz
182 real(kind=
rp),
dimension(this%Xh_GL%lxyz) :: tfx, tfy, tfz
183 real(kind=
rp),
dimension(this%Xh_GL%lxyz) :: vr, vs, vt
184 real(kind=
rp),
dimension(this%Xh_GLL%lxyz) :: tempx, tempy, tempz
185 integer :: e, i, idx, nel, n_GL
188 n_gl = nel * this%Xh_GL%lxyz
191 associate(c_gl => this%coef_GL)
193 call this%GLL_to_GL%map(this%tx, vx%x, nel, this%Xh_GL)
194 call this%GLL_to_GL%map(this%ty, vy%x, nel, this%Xh_GL)
195 call this%GLL_to_GL%map(this%tz, vz%x, nel, this%Xh_GL)
197 call opgrad(this%vr, this%vs, this%vt, this%tx, c_gl)
198 call device_vdot3(this%tbf_d, this%vr_d, this%vs_d, this%vt_d, &
199 this%tx_d, this%ty_d, this%tz_d, n_gl)
200 call this%GLL_to_GL%map(this%temp, this%tbf, nel, this%Xh_GLL)
204 call opgrad(this%vr, this%vs, this%vt, this%ty, c_gl)
205 call device_vdot3(this%tbf_d, this%vr_d, this%vs_d, this%vt_d, &
206 this%tx_d, this%ty_d, this%tz_d, n_gl)
207 call this%GLL_to_GL%map(this%temp, this%tbf, nel, this%Xh_GLL)
210 call opgrad(this%vr, this%vs, this%vt, this%tz, c_gl)
211 call device_vdot3(this%tbf_d, this%vr_d, this%vs_d, this%vt_d, &
212 this%tx_d, this%ty_d, this%tz_d, n_gl)
213 call this%GLL_to_GL%map(this%temp, this%tbf, nel, this%Xh_GLL)
218 call this%GLL_to_GL%map(this%tx, vx%x, nel, this%Xh_GL)
219 call this%GLL_to_GL%map(this%ty, vy%x, nel, this%Xh_GL)
220 call this%GLL_to_GL%map(this%tz, vz%x, nel, this%Xh_GL)
222 call opgrad(this%vr, this%vs, this%vt, this%tx, c_gl)
223 call vdot3(this%tbf, this%vr, this%vs, this%vt, &
224 this%tx, this%ty, this%tz, n_gl)
225 call this%GLL_to_GL%map(this%temp, this%tbf, nel, this%Xh_GLL)
226 call sub2(fx%x, this%temp, n)
229 call opgrad(this%vr, this%vs, this%vt, this%ty, c_gl)
230 call vdot3(this%tbf, this%vr, this%vs, this%vt, &
231 this%tx, this%ty, this%tz, n_gl)
232 call this%GLL_to_GL%map(this%temp, this%tbf, nel, this%Xh_GLL)
233 call sub2(fy%x, this%temp, n)
235 call opgrad(this%vr, this%vs, this%vt, this%tz, c_gl)
236 call vdot3(this%tbf, this%vr, this%vs, this%vt, &
237 this%tx, this%ty, this%tz, n_gl)
238 call this%GLL_to_GL%map(this%temp, this%tbf, nel, this%Xh_GLL)
239 call sub2(fz%x, this%temp, n)
243 do e = 1, coef%msh%nelv
244 call this%GLL_to_GL%map(tx, vx%x(1,1,1,e), 1, this%Xh_GL)
245 call this%GLL_to_GL%map(ty, vy%x(1,1,1,e), 1, this%Xh_GL)
246 call this%GLL_to_GL%map(tz, vz%x(1,1,1,e), 1, this%Xh_GL)
248 call opgrad(vr, vs, vt, tx, c_gl, e, e)
249 do i = 1, this%Xh_GL%lxyz
250 tfx(i) = tx(i)*vr(i) + ty(i)*vs(i) + tz(i)*vt(i)
253 call opgrad(vr, vs, vt, ty, c_gl, e, e)
254 do i = 1, this%Xh_GL%lxyz
255 tfy(i) = tx(i)*vr(i) + ty(i)*vs(i) + tz(i)*vt(i)
258 call opgrad(vr, vs, vt, tz, c_gl, e, e)
259 do i = 1, this%Xh_GL%lxyz
260 tfz(i) = tx(i)*vr(i) + ty(i)*vs(i) + tz(i)*vt(i)
263 call this%GLL_to_GL%map(tempx, tfx, 1, this%Xh_GLL)
264 call this%GLL_to_GL%map(tempy, tfy, 1, this%Xh_GLL)
265 call this%GLL_to_GL%map(tempz, tfz, 1, this%Xh_GLL)
267 idx = (e-1)*this%Xh_GLL%lxyz+1
268 do concurrent(i = 0:this%Xh_GLL%lxyz-1)
269 fx%x(i+idx,1,1,1) = fx%x(i+idx,1,1,1) - tempx(i+1)
270 fy%x(i+idx,1,1,1) = fy%x(i+idx,1,1,1) - tempy(i+1)
271 fz%x(i+idx,1,1,1) = fz%x(i+idx,1,1,1) - tempz(i+1)
294 type(field_t),
intent(inout) :: vx, vy, vz
295 type(field_t),
intent(inout) :: s
296 type(field_t),
intent(inout) :: fs
297 type(space_t),
intent(inout) :: Xh
298 type(coef_t),
intent(inout) :: coef
299 integer,
intent(in) :: n
300 real(kind=rp),
intent(in),
optional :: dt
302 real(kind=rp),
dimension(this%Xh_GL%lxyz) :: vx_gl, vy_gl, vz_gl, s_gl
303 real(kind=rp),
dimension(this%Xh_GL%lxyz) :: dsdx, dsdy, dsdz
304 real(kind=rp),
dimension(this%Xh_GL%lxyz) :: f_gl
305 integer :: e, i, idx, nel, n_GL
306 real(kind=rp),
dimension(this%Xh_GLL%lxyz) :: temp
309 n_gl = nel * this%Xh_GL%lxyz
311 associate(c_gl => this%coef_GL)
312 if (neko_bcknd_device .eq. 1)
then
315 call this%GLL_to_GL%map(this%tx, vx%x, nel, this%Xh_GL)
316 call this%GLL_to_GL%map(this%ty, vy%x, nel, this%Xh_GL)
317 call this%GLL_to_GL%map(this%tz, vz%x, nel, this%Xh_GL)
320 call this%GLL_to_GL%map(this%temp, s%x, nel, this%Xh_GL)
323 call opgrad(this%vr, this%vs, this%vt, this%temp, c_gl)
326 call device_vdot3(this%tbf_d, this%vr_d, this%vs_d, this%vt_d, &
327 this%tx_d, this%ty_d, this%tz_d, n_gl)
330 call this%GLL_to_GL%map(this%temp, this%tbf, nel, this%Xh_GLL)
333 call device_sub2(fs%x_d, this%temp_d, n)
335 else if ((neko_bcknd_sx .eq. 1) .or. (neko_bcknd_xsmm .eq. 1))
then
338 call this%GLL_to_GL%map(this%tx, vx%x, nel, this%Xh_GL)
339 call this%GLL_to_GL%map(this%ty, vy%x, nel, this%Xh_GL)
340 call this%GLL_to_GL%map(this%tz, vz%x, nel, this%Xh_GL)
343 call this%GLL_to_GL%map(this%temp, s%x, nel, this%Xh_GL)
346 call opgrad(this%vr, this%vs, this%vt, this%temp, c_gl)
349 call vdot3(this%tbf, this%vr, this%vs, this%vt, &
350 this%tx, this%ty, this%tz, n_gl)
353 call this%GLL_to_GL%map(this%temp, this%tbf, nel, this%Xh_GLL)
356 call sub2(fs%x, this%temp, n)
359 do e = 1, coef%msh%nelv
361 call this%GLL_to_GL%map(vx_gl, vx%x(1,1,1,e), 1, this%Xh_GL)
362 call this%GLL_to_GL%map(vy_gl, vy%x(1,1,1,e), 1, this%Xh_GL)
363 call this%GLL_to_GL%map(vz_gl, vz%x(1,1,1,e), 1, this%Xh_GL)
366 call this%GLL_to_GL%map(s_gl, s%x(1,1,1,e), 1, this%Xh_GL)
369 call opgrad(dsdx, dsdy, dsdz, s_gl, c_gl, e, e)
372 do i = 1, this%Xh_GL%lxyz
373 f_gl(i) = vx_gl(i)*dsdx(i) + vy_gl(i)*dsdy(i) + vz_gl(i)*dsdz(i)
377 call this%GLL_to_GL%map(temp, f_gl, 1, this%Xh_GLL)
379 idx = (e-1)*this%Xh_GLL%lxyz + 1
381 call sub2(fs%x(idx, 1, 1, 1), temp, this%Xh_GLL%lxyz)
Return the device pointer for an associated Fortran array.
Map a Fortran array to a device (allocate and associate)
Subroutines to add advection terms to the RHS of a transport equation.
subroutine compute_advection_dealias(this, vx, vy, vz, fx, fy, fz, Xh, coef, n, dt)
Add the advection term for the fluid, i.e. , to the RHS.
subroutine init_dealias(this, lxd, coef)
Constructor.
subroutine compute_scalar_advection_dealias(this, vx, vy, vz, s, fs, Xh, coef, n, dt)
Add the advection term for a scalar, i.e. , to the RHS.
subroutine free_dealias(this)
Destructor.
Subroutines to add advection terms to the RHS of a transport equation.
subroutine, public device_vdot3(dot_d, u1_d, u2_d, u3_d, v1_d, v2_d, v3_d, n)
Compute a dot product (3-d version) assuming vector components etc.
subroutine, public device_sub2(a_d, b_d, n)
Vector substraction .
Device abstraction, common interface for various accelerators.
Routines to interpolate between different spaces.
subroutine, public vdot3(dot, u1, u2, u3, v1, v2, v3, n)
Compute a dot product (3-d version) assuming vector components etc.
subroutine, public sub2(a, b, n)
Vector substraction .
integer, parameter neko_bcknd_sx
integer, parameter neko_bcknd_hip
integer, parameter neko_bcknd_device
integer, parameter neko_bcknd_opencl
integer, parameter neko_bcknd_cuda
integer, parameter neko_bcknd_xsmm
integer, parameter, public rp
Global precision used in computations.
subroutine, public opgrad(ux, uy, uz, u, coef, es, ee)
Compute the weak gradient of a scalar field, i.e. the gradient multiplied by the mass matrix.
Defines a function space.
integer, parameter, public gl
Type encapsulating advection routines with dealiasing.
Base abstract type for computing the advection operator.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Interpolation between two space::space_t.
The function space for the SEM solution fields.