47 use,
intrinsic :: iso_c_binding, only : c_ptr, c_null_ptr, &
62 real(kind=
rp),
allocatable :: temp(:)
63 type(c_ptr) :: temp_d = c_null_ptr
74 procedure, pass(this) :: compute_scalar => &
90 real(kind=
rp),
allocatable :: temp(:), tbf(:)
92 real(kind=
rp),
allocatable :: tx(:), ty(:), tz(:)
93 real(kind=
rp),
allocatable :: vr(:), vs(:), vt(:)
95 type(c_ptr) :: temp_d = c_null_ptr
97 type(c_ptr) :: tbf_d = c_null_ptr
99 type(c_ptr) :: tx_d = c_null_ptr
101 type(c_ptr) :: ty_d = c_null_ptr
103 type(c_ptr) :: tz_d = c_null_ptr
105 type(c_ptr) :: vr_d = c_null_ptr
107 type(c_ptr) :: vs_d = c_null_ptr
109 type(c_ptr) :: vt_d = c_null_ptr
143 type(
space_t),
intent(inout) :: Xh
144 type(
coef_t),
intent(inout) :: coef
145 type(
field_t),
intent(inout) :: vx, vy, vz
146 integer,
intent(in) :: n
147 real(kind=
rp),
intent(inout),
dimension(n) :: fx, fy, fz
169 type(
field_t),
intent(inout) :: vx, vy, vz
170 type(
field_t),
intent(inout) :: s
171 real(kind=
rp),
intent(inout),
dimension(n) :: fs
172 type(
space_t),
intent(inout) :: xh
173 type(
coef_t),
intent(inout) :: coef
174 integer,
intent(in) :: n
192 type(
coef_t),
intent(in) :: coef
194 allocate(this%temp(coef%dof%size()))
197 call device_map(this%temp, this%temp_d, coef%dof%size())
206 if (
allocated(this%temp))
then
207 deallocate(this%temp)
209 if (c_associated(this%temp_d))
then
219 integer,
intent(in) :: lxd
220 type(
coef_t),
intent(inout),
target :: coef
221 integer :: nel, n_GL, n
223 call this%Xh_GL%init(
gl, lxd, lxd, lxd)
224 this%Xh_GLL => coef%Xh
225 this%coef_GLL => coef
226 call this%GLL_to_GL%init(this%Xh_GL, this%Xh_GLL)
228 call this%coef_GL%init(this%Xh_GL, coef%msh)
231 n_gl = nel*this%Xh_GL%lxyz
233 call this%GLL_to_GL%map(this%coef_GL%drdx, coef%drdx, nel, this%Xh_GL)
234 call this%GLL_to_GL%map(this%coef_GL%dsdx, coef%dsdx, nel, this%Xh_GL)
235 call this%GLL_to_GL%map(this%coef_GL%dtdx, coef%dtdx, nel, this%Xh_GL)
236 call this%GLL_to_GL%map(this%coef_GL%drdy, coef%drdy, nel, this%Xh_GL)
237 call this%GLL_to_GL%map(this%coef_GL%dsdy, coef%dsdy, nel, this%Xh_GL)
238 call this%GLL_to_GL%map(this%coef_GL%dtdy, coef%dtdy, nel, this%Xh_GL)
239 call this%GLL_to_GL%map(this%coef_GL%drdz, coef%drdz, nel, this%Xh_GL)
240 call this%GLL_to_GL%map(this%coef_GL%dsdz, coef%dsdz, nel, this%Xh_GL)
241 call this%GLL_to_GL%map(this%coef_GL%dtdz, coef%dtdz, nel, this%Xh_GL)
245 allocate(this%temp(n_gl))
246 allocate(this%tbf(n_gl))
247 allocate(this%tx(n_gl))
248 allocate(this%ty(n_gl))
249 allocate(this%tz(n_gl))
250 allocate(this%vr(n_gl))
251 allocate(this%vs(n_gl))
252 allocate(this%vt(n_gl))
287 type(
space_t),
intent(inout) :: Xh
288 type(
coef_t),
intent(inout) :: coef
289 type(
field_t),
intent(inout) :: vx, vy, vz
290 integer,
intent(in) :: n
291 real(kind=
rp),
intent(inout),
dimension(n) :: fx, fy, fz
292 real(kind=
rp),
dimension(this%Xh_GL%lxyz) :: tx, ty, tz
293 real(kind=
rp),
dimension(this%Xh_GL%lxyz) :: tfx, tfy, tfz
294 real(kind=
rp),
dimension(this%Xh_GL%lxyz) :: vr, vs, vt
295 real(kind=
rp),
dimension(this%Xh_GLL%lxyz) :: tempx, tempy, tempz
296 type(c_ptr) :: fx_d, fy_d, fz_d
297 integer :: e, i, idx, nel, n_gl
299 n_gl = nel * this%Xh_GL%lxyz
301 associate(c_gl => this%coef_GL)
306 call this%GLL_to_GL%map(this%tx, vx%x, nel, this%Xh_GL)
307 call this%GLL_to_GL%map(this%ty, vy%x, nel, this%Xh_GL)
308 call this%GLL_to_GL%map(this%tz, vz%x, nel, this%Xh_GL)
310 call opgrad(this%vr, this%vs, this%vt, this%tx, c_gl)
311 call device_vdot3(this%tbf_d, this%vr_d, this%vs_d, this%vt_d, &
312 this%tx_d, this%ty_d, this%tz_d, n_gl)
313 call this%GLL_to_GL%map(this%temp, this%tbf, nel, this%Xh_GLL)
317 call opgrad(this%vr, this%vs, this%vt, this%ty, c_gl)
318 call device_vdot3(this%tbf_d, this%vr_d, this%vs_d, this%vt_d, &
319 this%tx_d, this%ty_d, this%tz_d, n_gl)
320 call this%GLL_to_GL%map(this%temp, this%tbf, nel, this%Xh_GLL)
323 call opgrad(this%vr, this%vs, this%vt, this%tz, c_gl)
324 call device_vdot3(this%tbf_d, this%vr_d, this%vs_d, this%vt_d, &
325 this%tx_d, this%ty_d, this%tz_d, n_gl)
326 call this%GLL_to_GL%map(this%temp, this%tbf, nel, this%Xh_GLL)
331 call this%GLL_to_GL%map(this%tx, vx%x, nel, this%Xh_GL)
332 call this%GLL_to_GL%map(this%ty, vy%x, nel, this%Xh_GL)
333 call this%GLL_to_GL%map(this%tz, vz%x, nel, this%Xh_GL)
335 call opgrad(this%vr, this%vs, this%vt, this%tx, c_gl)
336 call vdot3(this%tbf, this%vr, this%vs, this%vt, &
337 this%tx, this%ty, this%tz, n_gl)
338 call this%GLL_to_GL%map(this%temp, this%tbf, nel, this%Xh_GLL)
339 call sub2(fx, this%temp, n)
342 call opgrad(this%vr, this%vs, this%vt, this%ty, c_gl)
343 call vdot3(this%tbf, this%vr, this%vs, this%vt, &
344 this%tx, this%ty, this%tz, n_gl)
345 call this%GLL_to_GL%map(this%temp, this%tbf, nel, this%Xh_GLL)
346 call sub2(fy, this%temp, n)
348 call opgrad(this%vr, this%vs, this%vt, this%tz, c_gl)
349 call vdot3(this%tbf, this%vr, this%vs, this%vt, &
350 this%tx, this%ty, this%tz, n_gl)
351 call this%GLL_to_GL%map(this%temp, this%tbf, nel, this%Xh_GLL)
352 call sub2(fz, this%temp, n)
356 do e = 1, coef%msh%nelv
357 call this%GLL_to_GL%map(tx, vx%x(1,1,1,e), 1, this%Xh_GL)
358 call this%GLL_to_GL%map(ty, vy%x(1,1,1,e), 1, this%Xh_GL)
359 call this%GLL_to_GL%map(tz, vz%x(1,1,1,e), 1, this%Xh_GL)
361 call opgrad(vr, vs, vt, tx, c_gl, e, e)
362 do i = 1, this%Xh_GL%lxyz
363 tfx(i) = tx(i)*vr(i) + ty(i)*vs(i) + tz(i)*vt(i)
366 call opgrad(vr, vs, vt, ty, c_gl, e, e)
367 do i = 1, this%Xh_GL%lxyz
368 tfy(i) = tx(i)*vr(i) + ty(i)*vs(i) + tz(i)*vt(i)
371 call opgrad(vr, vs, vt, tz, c_gl, e, e)
372 do i = 1, this%Xh_GL%lxyz
373 tfz(i) = tx(i)*vr(i) + ty(i)*vs(i) + tz(i)*vt(i)
376 call this%GLL_to_GL%map(tempx, tfx, 1, this%Xh_GLL)
377 call this%GLL_to_GL%map(tempy, tfy, 1, this%Xh_GLL)
378 call this%GLL_to_GL%map(tempz, tfz, 1, this%Xh_GLL)
380 idx = (e-1)*this%Xh_GLL%lxyz+1
381 call sub2(fx(idx), tempx, this%Xh_GLL%lxyz)
382 call sub2(fy(idx), tempy, this%Xh_GLL%lxyz)
383 call sub2(fz(idx), tempz, this%Xh_GLL%lxyz)
403 type(space_t),
intent(inout) :: Xh
404 type(coef_t),
intent(inout) :: coef
405 type(field_t),
intent(inout) :: vx, vy, vz
406 integer,
intent(in) :: n
407 real(kind=rp),
intent(inout),
dimension(n) :: fx, fy, fz
408 type(c_ptr) :: fx_d, fy_d, fz_d
410 if (neko_bcknd_device .eq. 1)
then
411 fx_d = device_get_ptr(fx)
412 fy_d = device_get_ptr(fy)
413 fz_d = device_get_ptr(fz)
415 call conv1(this%temp, vx%x, vx%x, vy%x, vz%x, xh, coef)
416 call device_subcol3 (fx_d, coef%B_d, this%temp_d, n)
417 call conv1(this%temp, vy%x, vx%x, vy%x, vz%x, xh, coef)
418 call device_subcol3 (fy_d, coef%B_d, this%temp_d, n)
419 if (coef%Xh%lz .eq. 1)
then
420 call device_rzero (this%temp_d, n)
422 call conv1(this%temp, vz%x, vx%x, vy%x, vz%x, xh, coef)
423 call device_subcol3(fz_d, coef%B_d, this%temp_d, n)
426 call conv1(this%temp, vx%x, vx%x, vy%x, vz%x, xh, coef)
427 call subcol3 (fx, coef%B, this%temp, n)
428 call conv1(this%temp, vy%x, vx%x, vy%x, vz%x, xh, coef)
429 call subcol3 (fy, coef%B, this%temp, n)
430 if (coef%Xh%lz .eq. 1)
then
431 call rzero (this%temp, n)
433 call conv1(this%temp, vz%x, vx%x, vy%x, vz%x, xh, coef)
434 call subcol3(fz, coef%B, this%temp, n)
454 type(field_t),
intent(inout) :: vx, vy, vz
455 type(field_t),
intent(inout) :: s
456 integer,
intent(in) :: n
457 real(kind=rp),
intent(inout),
dimension(n) :: fs
458 type(space_t),
intent(inout) :: xh
459 type(coef_t),
intent(inout) :: coef
462 if (neko_bcknd_device .eq. 1)
then
463 fs_d = device_get_ptr(fs)
465 call conv1(this%temp, s%x, vx%x, vy%x, vz%x, xh, coef)
466 call device_subcol3 (fs_d, coef%B_d, this%temp_d, n)
467 if (coef%Xh%lz .eq. 1)
then
468 call device_rzero (this%temp_d, n)
472 call conv1(this%temp, s%x, vx%x, vy%x, vz%x, xh, coef)
475 call subcol3 (fs, coef%B, this%temp, n)
476 if (coef%Xh%lz .eq. 1)
then
477 call rzero (this%temp, n)
497 type(field_t),
intent(inout) :: vx, vy, vz
498 type(field_t),
intent(inout) :: s
499 integer,
intent(in) :: n
500 real(kind=rp),
intent(inout),
dimension(n) :: fs
501 type(space_t),
intent(inout) :: xh
502 type(coef_t),
intent(inout) :: coef
504 real(kind=rp),
dimension(this%Xh_GL%lxyz) :: vx_gl, vy_gl, vz_gl, s_gl
505 real(kind=rp),
dimension(this%Xh_GL%lxyz) :: dsdx, dsdy, dsdz
506 real(kind=rp),
dimension(this%Xh_GL%lxyz) :: f_gl
507 integer :: e, i, idx, nel, n_GL
508 real(kind=rp),
dimension(this%Xh_GLL%lxyz) :: temp
511 n_gl = nel * this%Xh_GL%lxyz
513 associate(c_gl => this%coef_GL)
514 if (neko_bcknd_device .eq. 1)
then
515 fs_d = device_get_ptr(fs)
518 call this%GLL_to_GL%map(this%tx, vx%x, nel, this%Xh_GL)
519 call this%GLL_to_GL%map(this%ty, vy%x, nel, this%Xh_GL)
520 call this%GLL_to_GL%map(this%tz, vz%x, nel, this%Xh_GL)
523 call this%GLL_to_GL%map(this%temp, s%x, nel, this%Xh_GL)
526 call opgrad(this%vr, this%vs, this%vt, this%temp, c_gl)
529 call device_vdot3(this%tbf_d, this%vr_d, this%vs_d, this%vt_d, &
530 this%tx_d, this%ty_d, this%tz_d, n_gl)
533 call this%GLL_to_GL%map(this%temp, this%tbf, nel, this%Xh_GLL)
536 call device_sub2(fs_d, this%temp_d, n)
538 else if ((neko_bcknd_sx .eq. 1) .or. (neko_bcknd_xsmm .eq. 1))
then
541 call this%GLL_to_GL%map(this%tx, vx%x, nel, this%Xh_GL)
542 call this%GLL_to_GL%map(this%ty, vy%x, nel, this%Xh_GL)
543 call this%GLL_to_GL%map(this%tz, vz%x, nel, this%Xh_GL)
546 call this%GLL_to_GL%map(this%temp, s%x, nel, this%Xh_GL)
549 call opgrad(this%vr, this%vs, this%vt, this%temp, c_gl)
552 call vdot3(this%tbf, this%vr, this%vs, this%vt, &
553 this%tx, this%ty, this%tz, n_gl)
556 call this%GLL_to_GL%map(this%temp, this%tbf, nel, this%Xh_GLL)
559 call sub2(fs, this%temp, n)
562 do e = 1, coef%msh%nelv
564 call this%GLL_to_GL%map(vx_gl, vx%x(1,1,1,e), 1, this%Xh_GL)
565 call this%GLL_to_GL%map(vy_gl, vy%x(1,1,1,e), 1, this%Xh_GL)
566 call this%GLL_to_GL%map(vz_gl, vz%x(1,1,1,e), 1, this%Xh_GL)
569 call this%GLL_to_GL%map(s_gl, s%x(1,1,1,e), 1, this%Xh_GL)
572 call opgrad(dsdx, dsdy, dsdz, s_gl, c_gl, e, e)
575 do i = 1, this%Xh_GL%lxyz
576 f_gl(i) = vx_gl(i)*dsdx(i) + vy_gl(i)*dsdy(i) + vz_gl(i)*dsdz(i)
580 call this%GLL_to_GL%map(temp, f_gl, 1, this%Xh_GLL)
582 idx = (e-1)*this%Xh_GLL%lxyz + 1
584 call sub2(fs(idx), temp, this%Xh_GLL%lxyz)
Add advection operator to the right-hand-side for a fluld.
Add advection operator to the right-hand-side for a scalar.
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 init_dealias(this, lxd, coef)
Constructor.
subroutine compute_advection_no_dealias(this, vx, vy, vz, fx, fy, fz, Xh, coef, n)
Add the advection term for the fluid, i.e. to the RHS.
subroutine compute_advection_dealias(this, vx, vy, vz, fx, fy, fz, Xh, coef, n)
Add the advection term for the fluid, i.e. , to the RHS.
subroutine init_no_dealias(this, coef)
Constructor.
subroutine compute_scalar_advection_dealias(this, vx, vy, vz, s, fs, Xh, coef, n)
Add the advection term for a scalar, i.e. , to the RHS.
subroutine free_no_dealias(this)
Destructor.
subroutine compute_scalar_advection_no_dealias(this, vx, vy, vz, s, fs, Xh, coef, n)
Add the advection term for a scalar, i.e. , to the RHS.
subroutine free_dealias(this)
Destructor.
subroutine, public device_vdot3(dot_d, u1_d, u2_d, u3_d, v1_d, v2_d, v3_d, n)
subroutine, public device_sub2(a_d, b_d, n)
Device abstraction, common interface for various accelerators.
subroutine, public device_free(x_d)
Deallocate memory on the device.
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 gradient of a scalar field.
Defines a function space.
integer, parameter, public gl
Type encapsulating advection routines with dealiasing.
Type encapsulating advection routines with no dealiasing applied.
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.