Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
RAMP_mapping_kernel.h
Go to the documentation of this file.
1
37#ifndef __NEKO_CUDA_RAMP_MAPPING_KERNELS__
38#define __NEKO_CUDA_RAMP_MAPPING_KERNELS__
39
43template <typename T>
45 const T f_min, const T f_max, const T q, T* __restrict__ X_out_d,
46 T* __restrict__ X_in_d, const int n) {
47
48 const int idx = blockIdx.x * blockDim.x + threadIdx.x;
49 const int str = blockDim.x * gridDim.x;
50
51 for (int i = idx; i < n; i += str) {
52 X_out_d[i] = f_min
53 + (f_max - f_min) * X_in_d[i] / (1.0 + q * (1.0 - X_in_d[i]));
54 }
55}
56
60template <typename T>
62 const T f_min, const T f_max, const T q, T* __restrict__ sens_out_d,
63 T* __restrict__ sens_in_d, T* __restrict__ X_in_d, const int n) {
64
65 const int idx = blockIdx.x * blockDim.x + threadIdx.x;
66 const int str = blockDim.x * gridDim.x;
67
68 for (int i = idx; i < n; i += str) {
69 sens_out_d[i] = (f_max - f_min) * (q + 1.0) / (
70 (1.0 - q * (X_in_d[i] - 1.0)) * (1.0 - q * (X_in_d[i] - 1.0))
71 ) * sens_in_d[i];
72 }
73}
77template <typename T>
79 const T f_min, const T f_max, const T q, T* __restrict__ X_out_d,
80 T* __restrict__ X_in_d, const int n) {
81
82 const int idx = blockIdx.x * blockDim.x + threadIdx.x;
83 const int str = blockDim.x * gridDim.x;
84
85 for (int i = idx; i < n; i += str) {
86 X_out_d[i] = f_min
87 + (f_max - f_min) * X_in_d[i] * (1.0 + q) / (X_in_d[i] + q);
88 }
89}
90
94template <typename T>
96 const T f_min, const T f_max, const T q, T* __restrict__ sens_out_d,
97 T* __restrict__ sens_in_d, T* __restrict__ X_in_d, const int n) {
98
99 const int idx = blockIdx.x * blockDim.x + threadIdx.x;
100 const int str = blockDim.x * gridDim.x;
101
102 for (int i = idx; i < n; i += str) {
103 sens_out_d[i] = (f_max - f_min) * q
104 * (q + 1.0) / ( (X_in_d[i] + q) * (X_in_d[i] + q)) * sens_in_d[i];
105 }
106}
107#endif // __NEKO_CUDA_RAMP_MAPPING_KERNELS__
__global__ void convex_down_RAMP_mapping_apply_kernel(const T f_min, const T f_max, const T q, T *__restrict__ X_out_d, T *__restrict__ X_in_d, const int n)
__global__ void convex_up_RAMP_mapping_apply_backward_kernel(const T f_min, const T f_max, const T q, T *__restrict__ sens_out_d, T *__restrict__ sens_in_d, T *__restrict__ X_in_d, const int n)
__global__ void convex_down_RAMP_mapping_apply_backward_kernel(const T f_min, const T f_max, const T q, T *__restrict__ sens_out_d, T *__restrict__ sens_in_d, T *__restrict__ X_in_d, const int n)
__global__ void convex_up_RAMP_mapping_apply_kernel(const T f_min, const T f_max, const T q, T *__restrict__ X_out_d, T *__restrict__ X_in_d, const int n)