Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
cai_sagaut_model_ii_kernel.h
Go to the documentation of this file.
1#ifndef CAI_SAGAUT_MODEL_II_KERNEL_H
2#define CAI_SAGAUT_MODEL_II_KERNEL_H
3
4/*
5 Copyright (c) 2026, The Neko Authors
6 All rights reserved.
7
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions
10 are met:
11
12 * Redistributions of source code must retain the above copyright
13 notice, this list of conditions and the following disclaimer.
14
15 * Redistributions in binary form must reproduce the above
16 copyright notice, this list of conditions and the following
17 disclaimer in the documentation and/or other materials provided
18 with the distribution.
19
20 * Neither the name of the authors nor the names of its
21 contributors may be used to endorse or promote products derived
22 from this software without specific prior written permission.
23
24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 POSSIBILITY OF SUCH DAMAGE.
36*/
37
38#include <cfloat>
39#include <algorithm>
40#include <cmath>
41
66template<typename T>
68 const T * __restrict__ v_d,
69 const T * __restrict__ w_d,
70 const T * __restrict__ n_x_d,
71 const T * __restrict__ n_y_d,
72 const T * __restrict__ n_z_d,
73 const T * __restrict__ nu_d,
74 const T * __restrict__ rho_w_d,
75 const T * __restrict__ h_d,
79 const int n_nodes,
80 const T kappa,
81 const T B,
82 const T p,
83 const T s) {
84 const int idx = blockIdx.x * blockDim.x + threadIdx.x;
85 const int str = blockDim.x * gridDim.x;
86 const T one = static_cast<T>(1.0);
87 const T eps = (sizeof(T) == sizeof(float)) ?
88 static_cast<T>(FLT_EPSILON) :
89 static_cast<T>(DBL_EPSILON);
90 const T e_const = exp(kappa * B);
91
92 for (int i = idx; i < n_nodes; i += str) {
93 T ui = u_d[i];
94 T vi = v_d[i];
95 T wi = w_d[i];
96 const T rho = rho_w_d[i];
97 const T nx = n_x_d[i];
98 const T ny = n_y_d[i];
99 const T nz = n_z_d[i];
100
101 const T normu = ui * nx + vi * ny + wi * nz;
102 ui -= normu * nx;
103 vi -= normu * ny;
104 wi -= normu * nz;
105
106 const T magu = sqrt(ui * ui + vi * vi + wi * wi);
107
108 if (magu < eps) {
109 tau_x_d[i] = static_cast<T>(0.0);
110 tau_y_d[i] = static_cast<T>(0.0);
111 tau_z_d[i] = static_cast<T>(0.0);
112 continue;
113 }
114
115 const T rey = magu * h_d[i] / nu_d[i];
116 const T blend = exp(-pow(rey / s, p));
117 const T warg = kappa * e_const * rey;
118 const T a = one /
119 (one + static_cast<T>(0.5) * log(one + warg));
120 T wlam = log(one + a * warg);
121 wlam = wlam / (one + wlam) * (one + log(warg / wlam));
122 const T up = blend * sqrt(rey) +
123 (one - blend) * wlam / kappa;
124 const T utau = magu / (up + eps);
125
126 tau_x_d[i] = -rho * utau * utau * ui / (magu + eps);
127 tau_y_d[i] = -rho * utau * utau * vi / (magu + eps);
128 tau_z_d[i] = -rho * utau * utau * wi / (magu + eps);
129 }
130}
131
132#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)
const int i
__global__ void cai_sagaut_model_ii_compute(const T *__restrict__ u_d, const T *__restrict__ v_d, const T *__restrict__ w_d, const T *__restrict__ n_x_d, const T *__restrict__ n_y_d, const T *__restrict__ n_z_d, const T *__restrict__ nu_d, const T *__restrict__ rho_w_d, const T *__restrict__ h_d, T *__restrict__ tau_x_d, T *__restrict__ tau_y_d, T *__restrict__ tau_z_d, const int n_nodes, const T kappa, const T B, const T p, const T s)