35#ifndef __FLUID_ENTROPY_VISCOSITY_KERNEL_H__
36#define __FLUID_ENTROPY_VISCOSITY_KERNEL_H__
45 const T * __restrict__ S,
46 const T * __restrict__ S_lag1,
47 const T * __restrict__ S_lag2,
48 const T * __restrict__ S_lag3,
55 const int idx = blockIdx.x * blockDim.x + threadIdx.x;
56 const int str = blockDim.x * gridDim.x;
58 for (
int i = idx;
i < n;
i += str) {
59 entropy_residual[
i] = (bdf1 * S[
i]
62 - bdf4 * S_lag3[
i]) /
dt;
71 const T * __restrict__ entropy_residual,
72 const T * __restrict__ h,
73 const T c_avisc_entropy,
76 const int idx = blockIdx.x * blockDim.x + threadIdx.x;
77 const int str = blockDim.x * gridDim.x;
79 for (
int i = idx;
i < n;
i += str) {
80 reg_coeff[
i] = c_avisc_entropy * h[
i] * h[
i] * entropy_residual[
i] / n_S;
92 __shared__ T sdata[1024];
94 const int el = blockIdx.x;
95 const int tid = threadIdx.x;
97 if (el >=
nelv)
return;
99 const int offset = el * lx3;
102 for (
int i = tid;
i < lx3;
i += blockDim.x) {
103 max_val =
max(max_val, reg_coeff[offset +
i]);
106 sdata[tid] = max_val;
109 const int nthreads = blockDim.x;
111 while (s < nthreads) s <<= 1;
112 for (s >>= 1; s > 0; s >>= 1) {
113 if (tid < s && tid + s < nthreads) {
114 sdata[tid] =
max(sdata[tid], sdata[tid + s]);
122 for (
int i = tid;
i < lx3;
i += blockDim.x) {
123 reg_coeff[offset +
i] = max_val;
132 const T * __restrict__ h,
133 const T * __restrict__ max_wave_speed,
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) {
140 T low_order_visc = c_avisc_low * h[
i] * max_wave_speed[
i];
141 reg_coeff[
i] = min(reg_coeff[
i], low_order_visc);
150 const T * __restrict__ temp_field,
151 const T * __restrict__ mult_field,
153 const int idx = blockIdx.x * blockDim.x + threadIdx.x;
154 const int str = blockDim.x * gridDim.x;
156 for (
int i = idx;
i < n;
i += str) {
157 reg_coeff[
i] = temp_field[
i] / mult_field[
i];
__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__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const int *__restrict__ const int nelv
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dt
__global__ void entropy_visc_clamp_to_low_order_kernel(T *__restrict__ reg_coeff, const T *__restrict__ h, const T *__restrict__ max_wave_speed, const T c_avisc_low, const int n)
__global__ void entropy_visc_compute_viscosity_kernel(T *__restrict__ reg_coeff, const T *__restrict__ entropy_residual, const T *__restrict__ h, const T c_avisc_entropy, const T n_S, const int n)
__global__ void entropy_visc_compute_residual_kernel(T *__restrict__ entropy_residual, const T *__restrict__ S, const T *__restrict__ S_lag1, const T *__restrict__ S_lag2, const T *__restrict__ S_lag3, const T bdf1, const T bdf2, const T bdf3, const T bdf4, const T dt, const int n)
__global__ void entropy_visc_apply_element_max_kernel(T *__restrict__ reg_coeff, const int lx3, const int nelv)
__global__ void entropy_visc_smooth_divide_kernel(T *__restrict__ reg_coeff, const T *__restrict__ temp_field, const T *__restrict__ mult_field, const int n)