1#ifndef __COMMON_DYNAMIC_SMAGORINSKY_NUT_KERNEL_H__
2#define __COMMON_DYNAMIC_SMAGORINSKY_NUT_KERNEL_H__
44 const T * __restrict__ s11,
45 const T * __restrict__ s22,
46 const T * __restrict__ s33,
47 const T * __restrict__ s12,
48 const T * __restrict__ s13,
49 const T * __restrict__ s23,
52 const int idx = blockIdx.x * blockDim.x + threadIdx.x;
53 const int str = blockDim.x * gridDim.x;
55 for (
int i = idx;
i < n;
i += str) {
56 const T s11_r = s11[
i];
57 const T s22_r = s22[
i];
58 const T s33_r = s33[
i];
59 const T s12_r = s12[
i];
60 const T s13_r = s13[
i];
61 const T s23_r = s23[
i];
63 s_abs[
i] = sqrt(2.0 * (s11_r * s11_r +
66 4.0 * (s12_r * s12_r +
80 const T * __restrict__
u,
81 const T * __restrict__
v,
82 const T * __restrict__
w,
83 const T * __restrict__ fu,
84 const T * __restrict__ fv,
85 const T * __restrict__ fw,
94 const int idx = blockIdx.x * blockDim.x + threadIdx.x;
95 const int str = blockDim.x * gridDim.x;
97 for (
int i = idx;
i < n;
i += str) {
101 const T fu_r = fu[
i];
102 const T fv_r = fv[
i];
103 const T fw_r = fw[
i];
105 l11[
i] = fu_r * fu_r;
106 l22[
i] = fv_r * fv_r;
107 l33[
i] = fw_r * fw_r;
108 l12[
i] = fu_r * fv_r;
109 l13[
i] = fu_r * fw_r;
110 l23[
i] = fv_r * fw_r;
123 T * __restrict__ l22,
124 T * __restrict__ l33,
125 T * __restrict__ l12,
126 T * __restrict__ l13,
127 T * __restrict__ l23,
128 const T * __restrict__ fuu,
129 const T * __restrict__ fvv,
130 const T * __restrict__ fww,
131 const T * __restrict__ fuv,
132 const T * __restrict__ fuw,
133 const T * __restrict__ fvw,
136 const int idx = blockIdx.x * blockDim.x + threadIdx.x;
137 const int str = blockDim.x * gridDim.x;
139 for (
int i = idx;
i < n;
i += str) {
151 T * __restrict__ m22,
152 T * __restrict__ m33,
153 T * __restrict__ m12,
154 T * __restrict__ m13,
155 T * __restrict__ m23,
156 const T * __restrict__ s_abs,
157 const T * __restrict__ s11,
158 const T * __restrict__ s22,
159 const T * __restrict__ s33,
160 const T * __restrict__ s12,
161 const T * __restrict__ s13,
162 const T * __restrict__ s23,
163 const T * __restrict__ delta,
164 const T * __restrict__ fs11,
165 const T * __restrict__ fs22,
166 const T * __restrict__ fs33,
167 const T * __restrict__ fs12,
168 const T * __restrict__ fs13,
169 const T * __restrict__ fs23,
170 T * __restrict__ fsabss11,
171 T * __restrict__ fsabss22,
172 T * __restrict__ fsabss33,
173 T * __restrict__ fsabss12,
174 T * __restrict__ fsabss13,
175 T * __restrict__ fsabss23,
176 const T delta_ratio2,
179 const int idx = blockIdx.x * blockDim.x + threadIdx.x;
180 const int str = blockDim.x * gridDim.x;
182 for (
int i = idx;
i < n;
i += str) {
183 const T s_abs_r = s_abs[
i];
184 const T delta_r = delta[
i];
185 const T delta2 = delta_r * delta_r;
186 const T fs_abs_r = sqrt(2.0 *
187 (fs11[
i] * fs11[
i] + fs22[
i] * fs22[
i] + fs33[
i] * fs33[
i]) +
188 4.0 * (fs12[
i] * fs12[
i] + fs13[
i] * fs13[
i] +
191 m11[
i] = delta_ratio2 * delta2 * fs_abs_r * fs11[
i];
192 m22[
i] = delta_ratio2 * delta2 * fs_abs_r * fs22[
i];
193 m33[
i] = delta_ratio2 * delta2 * fs_abs_r * fs33[
i];
194 m12[
i] = delta_ratio2 * delta2 * fs_abs_r * fs12[
i];
195 m13[
i] = delta_ratio2 * delta2 * fs_abs_r * fs13[
i];
196 m23[
i] = delta_ratio2 * delta2 * fs_abs_r * fs23[
i];
198 fsabss11[
i] = delta2 * s_abs_r * s11[
i];
199 fsabss22[
i] = delta2 * s_abs_r * s22[
i];
200 fsabss33[
i] = delta2 * s_abs_r * s33[
i];
201 fsabss12[
i] = delta2 * s_abs_r * s12[
i];
202 fsabss13[
i] = delta2 * s_abs_r * s13[
i];
203 fsabss23[
i] = delta2 * s_abs_r * s23[
i];
209 const T * __restrict__ m22,
210 const T * __restrict__ m33,
211 const T * __restrict__ m12,
212 const T * __restrict__ m13,
213 const T * __restrict__ m23,
214 T * __restrict__ l11,
215 T * __restrict__ l22,
216 T * __restrict__ l33,
217 T * __restrict__ l12,
218 T * __restrict__ l13,
219 T * __restrict__ l23,
220 const T * __restrict__ fsabss11,
221 const T * __restrict__ fsabss22,
222 const T * __restrict__ fsabss33,
223 const T * __restrict__ fsabss12,
224 const T * __restrict__ fsabss13,
225 const T * __restrict__ fsabss23,
226 T * __restrict__ num,
227 T * __restrict__ den,
228 T * __restrict__ c_dyn,
229 const T * __restrict__ delta,
230 const T * __restrict__ s_abs,
231 T * __restrict__ nut,
235 const int idx = blockIdx.x * blockDim.x + threadIdx.x;
236 const int str = blockDim.x * gridDim.x;
238 T num_curr, den_curr;
240 for (
int i = idx;
i < n;
i += str) {
241 const T delta_r = delta[
i];
242 const T delta2 = delta_r * delta_r;
245 const T m11_r = m11[
i] - fsabss11[
i];
246 const T m22_r = m22[
i] - fsabss22[
i];
247 const T m33_r = m33[
i] - fsabss33[
i];
248 const T m12_r = m12[
i] - fsabss12[
i];
249 const T m13_r = m13[
i] - fsabss13[
i];
250 const T m23_r = m23[
i] - fsabss23[
i];
252 num_curr = m11_r * l11[
i]
255 + 2.0 * (m12_r * l12[
i]
259 den_curr = m11_r * m11_r
262 + 2.0 * (m12_r * m12_r
266 const T num_r = alpha * num[
i] + (1.0 - alpha) * num_curr;
267 const T den_r = alpha * den[
i] + (1.0 - alpha) * den_curr;
273 c_dyn_r = 0.5 * num_r / den_r;
278 c_dyn_r =
max(c_dyn_r, 0.0);
280 nut[
i] = c_dyn_r * delta2 * s_abs[
i];
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ w
__global__ void const T *__restrict__ u
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ v
__global__ void mij_compute_part1(T *__restrict__ m11, T *__restrict__ m22, T *__restrict__ m33, T *__restrict__ m12, T *__restrict__ m13, T *__restrict__ m23, const T *__restrict__ s_abs, const T *__restrict__ s11, const T *__restrict__ s22, const T *__restrict__ s33, const T *__restrict__ s12, const T *__restrict__ s13, const T *__restrict__ s23, const T *__restrict__ delta, const T *__restrict__ fs11, const T *__restrict__ fs22, const T *__restrict__ fs33, const T *__restrict__ fs12, const T *__restrict__ fs13, const T *__restrict__ fs23, T *__restrict__ fsabss11, T *__restrict__ fsabss22, T *__restrict__ fsabss33, T *__restrict__ fsabss12, T *__restrict__ fsabss13, T *__restrict__ fsabss23, const T delta_ratio2, const int n)
__global__ void mij_nut_compute_part2(const T *__restrict__ m11, const T *__restrict__ m22, const T *__restrict__ m33, const T *__restrict__ m12, const T *__restrict__ m13, const T *__restrict__ m23, T *__restrict__ l11, T *__restrict__ l22, T *__restrict__ l33, T *__restrict__ l12, T *__restrict__ l13, T *__restrict__ l23, const T *__restrict__ fsabss11, const T *__restrict__ fsabss22, const T *__restrict__ fsabss33, const T *__restrict__ fsabss12, const T *__restrict__ fsabss13, const T *__restrict__ fsabss23, T *__restrict__ num, T *__restrict__ den, T *__restrict__ c_dyn, const T *__restrict__ delta, const T *__restrict__ s_abs, T *__restrict__ nut, const T alpha, const int n)
__global__ void lij_compute_part1(T *__restrict__ l11, T *__restrict__ l22, T *__restrict__ l33, T *__restrict__ l12, T *__restrict__ l13, T *__restrict__ l23, const T *__restrict__ u, const T *__restrict__ v, const T *__restrict__ w, const T *__restrict__ fu, const T *__restrict__ fv, const T *__restrict__ fw, T *__restrict__ fuu, T *__restrict__ fvv, T *__restrict__ fww, T *__restrict__ fuv, T *__restrict__ fuw, T *__restrict__ fvw, const int n)
__global__ void lij_compute_part2(T *__restrict__ l11, T *__restrict__ l22, T *__restrict__ l33, T *__restrict__ l12, T *__restrict__ l13, T *__restrict__ l23, const T *__restrict__ fuu, const T *__restrict__ fvv, const T *__restrict__ fww, const T *__restrict__ fuv, const T *__restrict__ fuw, const T *__restrict__ fvw, const int n)
__global__ void s_abs_compute(T *__restrict__ s_abs, const T *__restrict__ s11, const T *__restrict__ s22, const T *__restrict__ s33, const T *__restrict__ s12, const T *__restrict__ s13, const T *__restrict__ s23, const int n)