Neko 1.99.1
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
rough_log_law_kernel.h
Go to the documentation of this file.
1#ifndef ROUGH_LOG_LAW_KERNEL_H
2#define ROUGH_LOG_LAW_KERNEL_H
3
4#include <cmath>
5#include <algorithm>
6
10template<typename T>
12 const T* __restrict__ v_d,
13 const T* __restrict__ w_d,
14 const int* __restrict__ ind_r_d,
15 const int* __restrict__ ind_s_d,
16 const int* __restrict__ ind_t_d,
17 const int* __restrict__ ind_e_d,
18 const T* __restrict__ n_x_d,
19 const T* __restrict__ n_y_d,
20 const T* __restrict__ n_z_d,
21 const T* __restrict__ h_d,
25 const int n_nodes,
26 const int lx,
27 const T kappa,
28 const T B,
29 const T z0) {
30
31 const int idx = blockIdx.x * blockDim.x + threadIdx.x;
32 const int str = blockDim.x * gridDim.x;
33 for (int i = idx; i < n_nodes; i += str) {
34 // Sample the velocity
35 const int index = (ind_e_d[i] - 1) * lx * lx * lx +
36 (ind_t_d[i] - 1) * lx * lx +
37 (ind_s_d[i] - 1) * lx +
38 (ind_r_d[i] - 1);
39
40 T ui = u_d[index];
41 T vi = v_d[index];
42 T wi = w_d[index];
43
44 // Load normal vectors and wall shear stress values once
45 T nx = n_x_d[i];
46 T ny = n_y_d[i];
47 T nz = n_z_d[i];
48 T h = h_d[i];
49
50 // Project on tangential direction
51 T normu = ui * nx + vi * ny + wi * nz;
52
53 ui -= normu * nx;
54 vi -= normu * ny;
55 wi -= normu * nz;
56
57 T magu = sqrt(ui * ui + vi * vi + wi * wi);
58
59 // Compute the wall shear stress using the rough log-law
60 T utau = 0.0;
61 if (h > z0) {
62 utau = (magu - B) * kappa / log(h / z0);
63 }
64
65 // Distribute according to the velocity vector
66 tau_x_d[i] = -utau * utau * ui / magu;
67 tau_y_d[i] = -utau * utau * vi / magu;
68 tau_z_d[i] = -utau * utau * wi / magu;
69 }
70}
71
72#endif // ROUGH_LOG_LAW_KERNEL_H
const int i
__global__ void dirichlet_apply_scalar_kernel(const int *__restrict__ msk, T *__restrict__ x, const T g, const int m)
__global__ void rough_log_law_compute(const T *__restrict__ u_d, const T *__restrict__ v_d, const T *__restrict__ w_d, const int *__restrict__ ind_r_d, const int *__restrict__ ind_s_d, const int *__restrict__ ind_t_d, const int *__restrict__ ind_e_d, const T *__restrict__ n_x_d, const T *__restrict__ n_y_d, const T *__restrict__ n_z_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 int lx, const T kappa, const T B, const T z0)