Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
ax_helm_svv_one_sided_kernel.h
Go to the documentation of this file.
1#ifndef __MATH_AX_HELM_SVV_KERNEL_H__
2#define __MATH_AX_HELM_SVV_KERNEL_H__
3/*
4 Copyright (c) 2025-2026, The Neko Authors
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions
9 are met:
10
11 * Redistributions of source code must retain the above copyright
12 notice, this list of conditions and the following disclaimer.
13
14 * Redistributions in binary form must reproduce the above
15 copyright notice, this list of conditions and the following
16 disclaimer in the documentation and/or other materials provided
17 with the distribution.
18
19 * Neither the name of the authors nor the names of its
20 contributors may be used to endorse or promote products derived
21 from this software without specific prior written permission.
22
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 POSSIBILITY OF SUCH DAMAGE.
35*/
36
44template<typename T, const int LX>
47 const T * __restrict__ u,
48 const T * __restrict__ dx,
49 const T * __restrict__ dy,
50 const T * __restrict__ dz,
51 const T * __restrict__ h1,
52 const T * __restrict__ drdx,
53 const T * __restrict__ drdy,
54 const T * __restrict__ drdz,
55 const T * __restrict__ dsdx,
56 const T * __restrict__ dsdy,
57 const T * __restrict__ dsdz,
58 const T * __restrict__ dtdx,
59 const T * __restrict__ dtdy,
60 const T * __restrict__ dtdz,
61 const T * __restrict__ jacinv,
62 const T * __restrict__ w3,
63 const T * __restrict__ h1_svv,
64 const T * __restrict__ filter_r,
65 const T * __restrict__ filter_s,
66 const T * __restrict__ filter_t) {
67
68 extern __shared__ T shared[];
69 T *shfield = shared;
70 T *shwork = shared + LX * LX * LX;
71
72 const int e = blockIdx.x;
73 const int i = threadIdx.x;
74 const int j = threadIdx.y;
75 const int ij = i + j * LX;
76 const int lx2 = LX * LX;
77 const int elem = e * LX * lx2;
78
79#pragma unroll 1
80 for (int k = 0; k < LX; ++k) {
81 w[ij + k * lx2 + elem] = 0.0;
82 }
83
84 // Process the x, y and z components of the physical gradient in turn.
85#pragma unroll 1
86 for (int component = 0; component < 3; ++component) {
87
88 // Form one component of the physical gradient.
89#pragma unroll 1
90 for (int k = 0; k < LX; ++k) {
91 T ur = 0.0;
92 T us = 0.0;
93 T ut = 0.0;
94
95#pragma unroll
96 for (int l = 0; l < LX; ++l) {
97 ur += dx[i + l * LX] * u[l + j * LX + k * lx2 + elem];
98 us += dy[j + l * LX] * u[i + l * LX + k * lx2 + elem];
99 ut += dz[k + l * LX] * u[ij + l * lx2 + elem];
100 }
101
102 const int ijk = ij + k * lx2;
103 const int index = ijk + elem;
104 if (component == 0) {
105 shwork[ijk] = (ur * drdx[index] + us * dsdx[index] +
106 ut * dtdx[index]) * jacinv[index];
107 }
108 else if (component == 1) {
109 shwork[ijk] = (ur * drdy[index] + us * dsdy[index] +
110 ut * dtdy[index]) * jacinv[index];
111 }
112 else {
113 shwork[ijk] = (ur * drdz[index] + us * dsdz[index] +
114 ut * dtdz[index]) * jacinv[index];
115 }
116 }
117
118 // Apply filter_r, filter_s and filter_t as a tensor product.
120#pragma unroll 1
121 for (int k = 0; k < LX; ++k) {
122 T value = 0.0;
123#pragma unroll
124 for (int l = 0; l < LX; ++l) {
125 value += filter_r[i + l * LX] *
126 shwork[l + j * LX + k * lx2];
127 }
128 shfield[ij + k * lx2] = value;
129 }
131
132#pragma unroll 1
133 for (int k = 0; k < LX; ++k) {
134 T value = 0.0;
135#pragma unroll
136 for (int l = 0; l < LX; ++l) {
137 value += filter_s[l + j * LX] *
138 shfield[i + l * LX + k * lx2];
139 }
140 shwork[ij + k * lx2] = value;
141 }
143
144#pragma unroll 1
145 for (int k = 0; k < LX; ++k) {
146 T value = 0.0;
147#pragma unroll
148 for (int l = 0; l < LX; ++l) {
149 value += filter_t[l + k * LX] * shwork[ij + l * lx2];
150 }
151 shfield[ij + k * lx2] = value;
152 }
154
155 // Recompute the unfiltered gradient and form the weighted physical flux.
156#pragma unroll 1
157 for (int k = 0; k < LX; ++k) {
158 T ur = 0.0;
159 T us = 0.0;
160 T ut = 0.0;
161#pragma unroll
162 for (int l = 0; l < LX; ++l) {
163 ur += dx[i + l * LX] * u[l + j * LX + k * lx2 + elem];
164 us += dy[j + l * LX] * u[i + l * LX + k * lx2 + elem];
165 ut += dz[k + l * LX] * u[ij + l * lx2 + elem];
166 }
167
168 const int ijk = ij + k * lx2;
169 const int index = ijk + elem;
170 T gradient;
171 if (component == 0) {
172 gradient = (ur * drdx[index] + us * dsdx[index] +
173 ut * dtdx[index]) * jacinv[index];
174 }
175 else if (component == 1) {
176 gradient = (ur * drdy[index] + us * dsdy[index] +
177 ut * dtdy[index]) * jacinv[index];
178 }
179 else {
180 gradient = (ur * drdz[index] + us * dsdz[index] +
181 ut * dtdz[index]) * jacinv[index];
182 }
183
184 const T weighted_gradient =
185 w3[ijk] * (h1[index] * gradient +
186 h1_svv[index] * (gradient - shfield[ijk]));
188 }
190
191 // Apply the r-direction reference flux contribution.
192#pragma unroll 1
193 for (int k = 0; k < LX; ++k) {
194 const int ijk = ij + k * lx2;
195 const int index = ijk + elem;
196 if (component == 0) {
197 shfield[ijk] = drdx[index] * shwork[ijk];
198 }
199 else if (component == 1) {
200 shfield[ijk] = drdy[index] * shwork[ijk];
201 }
202 else {
203 shfield[ijk] = drdz[index] * shwork[ijk];
204 }
205 }
207
208#pragma unroll 1
209 for (int k = 0; k < LX; ++k) {
210 T value = 0.0;
211#pragma unroll
212 for (int l = 0; l < LX; ++l) {
213 value += dx[l + i * LX] * shfield[l + j * LX + k * lx2];
214 }
215 w[ij + k * lx2 + elem] += value;
216 }
218
219 // Apply the s-direction reference flux contribution.
220#pragma unroll 1
221 for (int k = 0; k < LX; ++k) {
222 const int ijk = ij + k * lx2;
223 const int index = ijk + elem;
224 if (component == 0) {
225 shfield[ijk] = dsdx[index] * shwork[ijk];
226 }
227 else if (component == 1) {
228 shfield[ijk] = dsdy[index] * shwork[ijk];
229 }
230 else {
231 shfield[ijk] = dsdz[index] * shwork[ijk];
232 }
233 }
235
236#pragma unroll 1
237 for (int k = 0; k < LX; ++k) {
238 T value = 0.0;
239#pragma unroll
240 for (int l = 0; l < LX; ++l) {
241 value += dy[l + j * LX] * shfield[i + l * LX + k * lx2];
242 }
243 w[ij + k * lx2 + elem] += value;
244 }
246
247 // Apply the t-direction reference flux contribution.
248#pragma unroll 1
249 for (int k = 0; k < LX; ++k) {
250 const int ijk = ij + k * lx2;
251 const int index = ijk + elem;
252 if (component == 0) {
253 shfield[ijk] = dtdx[index] * shwork[ijk];
254 }
255 else if (component == 1) {
256 shfield[ijk] = dtdy[index] * shwork[ijk];
257 }
258 else {
259 shfield[ijk] = dtdz[index] * shwork[ijk];
260 }
261 }
263
264#pragma unroll 1
265 for (int k = 0; k < LX; ++k) {
266 T value = 0.0;
267#pragma unroll
268 for (int l = 0; l < LX; ++l) {
269 value += dz[l + k * LX] * shfield[ij + l * lx2];
270 }
271 w[ij + k * lx2 + elem] += value;
272 }
274 }
275}
276
277#endif
__global__ void ale_add_kinematics_kernel(const int n, T *__restrict__ wx, T *__restrict__ wy, T *__restrict__ wz, const T *__restrict__ x_ref, const T *__restrict__ y_ref, const T *__restrict__ z_ref, const T *__restrict__ phi, const T *__restrict__ x, const T *__restrict__ y, const T *__restrict__ z, const kinematics_params_t kin_params)
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dtdy
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dtdx
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dtdz
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ w
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ jacinv
const int i
const int ij
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dz
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dsdz
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dx
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ u
const int e
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dy
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ drdz
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ drdx
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dsdx
const int j
__syncthreads()
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dsdy
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ h1
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ drdy
__global__ void ax_helm_svv_one_sided_kernel(T *__restrict__ w, const T *__restrict__ u, const T *__restrict__ dx, const T *__restrict__ dy, const T *__restrict__ dz, const T *__restrict__ h1, const T *__restrict__ drdx, const T *__restrict__ drdy, const T *__restrict__ drdz, const T *__restrict__ dsdx, const T *__restrict__ dsdy, const T *__restrict__ dsdz, const T *__restrict__ dtdx, const T *__restrict__ dtdy, const T *__restrict__ dtdz, const T *__restrict__ jacinv, const T *__restrict__ w3, const T *__restrict__ h1_svv, const T *__restrict__ filter_r, const T *__restrict__ filter_s, const T *__restrict__ filter_t)
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ w3