Neko 1.99.11
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
ax_helm_svv_factorized_full_device.F90
Go to the documentation of this file.
1! Copyright (c) 2026, The Neko Authors
2! All rights reserved.
3!
4! Redistribution and use in source and binary forms, with or without
5! modification, are permitted provided that the following conditions
6! are met:
7!
8! * Redistributions of source code must retain the above copyright
9! notice, this list of conditions and the following disclaimer.
10!
11! * Redistributions in binary form must reproduce the above
12! copyright notice, this list of conditions and the following
13! disclaimer in the documentation and/or other materials provided
14! with the distribution.
15!
16! * Neither the name of the authors nor the names of its
17! contributors may be used to endorse or promote products derived
18! from this software without specific prior written permission.
19!
20! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24! COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30! ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31! POSSIBILITY OF SUCH DAMAGE.
32!
33!> Device implementation of the factorized full-stress SVV Helmholtz operator.
36 use num_types, only : rp
37 use coefs, only : coef_t
38 use space, only : space_t
39 use mesh, only : mesh_t
40 use device_math, only : device_addcol4
41 use device, only : device_get_ptr
42 use utils, only : neko_error
43 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
44 implicit none
45 private
46
47 !> Device factorized full-stress SVV Helmholtz operator.
48 type, public, extends(ax_helm_svv_full_t) :: &
50 contains
51 !> Compute the coupled vector product.
52 procedure, pass(this) :: compute_vector => &
55
56#ifdef HAVE_HIP
57 interface
58 subroutine hip_ax_helm_svv_factorized_full(au_d, av_d, aw_d, u_d, &
59 v_d, w_d, &
60 dx_d, dy_d, dz_d, h1_d, Br_d, Bs_d, Bt_d, svv_h1_d, &
61 drdx_d, drdy_d, drdz_d, dsdx_d, dsdy_d, dsdz_d, &
62 dtdx_d, dtdy_d, dtdz_d, jacinv_d, w3_d, nelv, lx) &
63 bind(c, name='hip_ax_helm_svv_factorized_full')
64 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
65 type(c_ptr), value :: au_d, av_d, aw_d
66 type(c_ptr), value :: u_d, v_d, w_d
67 type(c_ptr), value :: dx_d, dy_d, dz_d, h1_d
68 type(c_ptr), value :: Br_d, Bs_d, Bt_d, svv_h1_d
69 type(c_ptr), value :: drdx_d, drdy_d, drdz_d
70 type(c_ptr), value :: dsdx_d, dsdy_d, dsdz_d
71 type(c_ptr), value :: dtdx_d, dtdy_d, dtdz_d
72 type(c_ptr), value :: jacinv_d, w3_d
73 integer(c_int) :: nelv, lx
75 end interface
76#elif HAVE_CUDA
77 interface
78 subroutine cuda_ax_helm_svv_factorized_full(au_d, av_d, aw_d, u_d, &
79 v_d, w_d, &
80 dx_d, dy_d, dz_d, h1_d, Br_d, Bs_d, Bt_d, svv_h1_d, &
81 drdx_d, drdy_d, drdz_d, dsdx_d, dsdy_d, dsdz_d, &
82 dtdx_d, dtdy_d, dtdz_d, jacinv_d, w3_d, nelv, lx) &
83 bind(c, name='cuda_ax_helm_svv_factorized_full')
84 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
85 type(c_ptr), value :: au_d, av_d, aw_d
86 type(c_ptr), value :: u_d, v_d, w_d
87 type(c_ptr), value :: dx_d, dy_d, dz_d, h1_d
88 type(c_ptr), value :: Br_d, Bs_d, Bt_d, svv_h1_d
89 type(c_ptr), value :: drdx_d, drdy_d, drdz_d
90 type(c_ptr), value :: dsdx_d, dsdy_d, dsdz_d
91 type(c_ptr), value :: dtdx_d, dtdy_d, dtdz_d
92 type(c_ptr), value :: jacinv_d, w3_d
93 integer(c_int) :: nelv, lx
95 end interface
96#endif
97
98contains
99
100 !> Compute the coupled factorized full-stress SVV Helmholtz product.
101 !! @param this Device factorized full-stress SVV operator.
102 !! @param au Result for the first component.
103 !! @param av Result for the second component.
104 !! @param aw Result for the third component.
105 !! @param u First input component.
106 !! @param v Second input component.
107 !! @param w Third input component.
108 !! @param coef Coefficients.
109 !! @param msh Mesh.
110 !! @param Xh Function space.
112 av, aw, &
113 u, v, w, coef, msh, Xh)
114 class(ax_helm_svv_factorized_full_device_t), intent(in) :: this
115 type(mesh_t), intent(in) :: msh
116 type(space_t), intent(in) :: Xh
117 type(coef_t), intent(in) :: coef
118 real(kind=rp), intent(inout) :: au(xh%lx, xh%ly, xh%lz, msh%nelv)
119 real(kind=rp), intent(inout) :: av(xh%lx, xh%ly, xh%lz, msh%nelv)
120 real(kind=rp), intent(inout) :: aw(xh%lx, xh%ly, xh%lz, msh%nelv)
121 real(kind=rp), intent(in) :: u(xh%lx, xh%ly, xh%lz, msh%nelv)
122 real(kind=rp), intent(in) :: v(xh%lx, xh%ly, xh%lz, msh%nelv)
123 real(kind=rp), intent(in) :: w(xh%lx, xh%ly, xh%lz, msh%nelv)
124 type(c_ptr) :: au_d, av_d, aw_d, u_d, v_d, w_d
125
126 au_d = device_get_ptr(au)
127 av_d = device_get_ptr(av)
128 aw_d = device_get_ptr(aw)
129 u_d = device_get_ptr(u)
130 v_d = device_get_ptr(v)
131 w_d = device_get_ptr(w)
132
133#ifdef HAVE_HIP
134 call hip_ax_helm_svv_factorized_full(au_d, av_d, aw_d, u_d, v_d, w_d, &
135 xh%dx_d, xh%dy_d, xh%dz_d, coef%h1_d, &
136 this%svv%Br_d, this%svv%Bs_d, this%svv%Bt_d, this%svv%h1_d, &
137 coef%drdx_d, coef%drdy_d, coef%drdz_d, &
138 coef%dsdx_d, coef%dsdy_d, coef%dsdz_d, &
139 coef%dtdx_d, coef%dtdy_d, coef%dtdz_d, coef%jacinv_d, &
140 xh%w3_d, msh%nelv, xh%lx)
141#elif HAVE_CUDA
142 call cuda_ax_helm_svv_factorized_full(au_d, av_d, aw_d, u_d, v_d, w_d, &
143 xh%dx_d, xh%dy_d, xh%dz_d, coef%h1_d, &
144 this%svv%Br_d, this%svv%Bs_d, this%svv%Bt_d, this%svv%h1_d, &
145 coef%drdx_d, coef%drdy_d, coef%drdz_d, &
146 coef%dsdx_d, coef%dsdy_d, coef%dsdz_d, &
147 coef%dtdx_d, coef%dtdy_d, coef%dtdz_d, coef%jacinv_d, &
148 xh%w3_d, msh%nelv, xh%lx)
149#elif HAVE_OPENCL
150 call neko_error('OPENCL is not implemented for factorized full SVV')
151#endif
152
153 if (coef%ifh2) then
154 call device_addcol4(au_d, coef%h2_d, coef%B_d, u_d, coef%dof%size())
155 call device_addcol4(av_d, coef%h2_d, coef%B_d, v_d, coef%dof%size())
156 call device_addcol4(aw_d, coef%h2_d, coef%B_d, w_d, coef%dof%size())
157 end if
158
160
void cuda_ax_helm_svv_factorized_full(void *au, void *av, void *aw, void *u, void *v, void *w, void *dx, void *dy, void *dz, void *h1, void *Br, void *Bs, void *Bt, void *h1_svv, void *drdx, void *drdy, void *drdz, void *dsdx, void *dsdy, void *dsdz, void *dtdx, void *dtdy, void *dtdz, void *jacinv, void *w3, int *nelv, int *lx)
Return the device pointer for an associated Fortran array.
Definition device.F90:113
Device implementation of the factorized full-stress SVV Helmholtz operator.
subroutine ax_helm_svv_factorized_full_device_compute_vector(this, au, av, aw, u, v, w, coef, msh, xh)
Compute the coupled factorized full-stress SVV Helmholtz product.
Defines the full-stress SVV Helmholtz operator.
Coefficients.
Definition coef.f90:34
subroutine, public device_addcol4(a_d, b_d, c_d, d_d, n, strm)
Returns .
Device abstraction, common interface for various accelerators.
Definition device.F90:34
Defines a mesh.
Definition mesh.f90:34
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:14
Defines a function space.
Definition space.f90:34
Utilities.
Definition utils.f90:35
Matrix-vector product for a Helmholtz problem.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:136
The function space for the SEM solution fields.
Definition space.f90:64