Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
steepest_descent_kernel.h
Go to the documentation of this file.
1
41#ifndef __NEKO_TOP_HIP_STEEPEST_DESCENT_KERNELS__
42#define __NEKO_TOP_HIP_STEEPEST_DESCENT_KERNELS__
43
54template <typename T>
56 T* __restrict__ s, const T* __restrict__ x, const T xmin, const T xmax,
57 const int n) {
58
59 const int idx = blockIdx.x * blockDim.x + threadIdx.x;
60 const int str = blockDim.x * gridDim.x;
61
62 for (int i = idx; i < n; i += str) {
63 const T xi = x[i];
64 T si = -s[i];
65 if ((xi >= xmax && si > T(0.0)) || (xi <= xmin && si < T(0.0))) {
66 si = T(0.0);
67 }
68 s[i] = si;
69 }
70}
71
86template <typename T>
88 T* __restrict__ delta, const T* __restrict__ x, const T* __restrict__ x1,
89 const T* __restrict__ x2, const T dec, const T inc, const T dmin,
90 const T dmax, const int n) {
91
92 const int idx = blockIdx.x * blockDim.x + threadIdx.x;
93 const int str = blockDim.x * gridDim.x;
94
95 for (int i = idx; i < n; i += str) {
96 const T d = (x[i] - x1[i]) * (x1[i] - x2[i]);
97 T di = delta[i];
98 if (d < T(0.0)) {
99 di = dec * di;
100 } else if (d > T(0.0)) {
101 di = inc * di;
102 }
103 delta[i] = min(dmax, max(dmin, di));
104 }
105}
106
121template <typename T>
123 T* __restrict__ x_new, const T* __restrict__ x, const T* __restrict__ s,
124 const T* __restrict__ delta, const T psi, const T smax, const T xmin,
125 const T xmax, const int n) {
126
127 const int idx = blockIdx.x * blockDim.x + threadIdx.x;
128 const int str = blockDim.x * gridDim.x;
129
130 for (int i = idx; i < n; i += str) {
131 const T xi = x[i];
132 const T di = delta[i];
133 const T trial = xi + psi * (s[i] / smax);
134 x_new[i] = min(xmax, max(xmin, min(xi + di, max(xi - di, trial))));
135 }
136}
137
138#endif // __NEKO_TOP_HIP_STEEPEST_DESCENT_KERNELS__
__global__ void Borrvall_Petersson_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 sd_update_design_kernel(T *__restrict__ x_new, const T *__restrict__ x, const T *__restrict__ s, const T *__restrict__ delta, const T psi, const T smax, const T xmin, const T xmax, const int n)
__global__ void sd_update_move_limits_kernel(T *__restrict__ delta, const T *__restrict__ x, const T *__restrict__ x1, const T *__restrict__ x2, const T dec, const T inc, const T dmin, const T dmax, const int n)
__global__ void sd_direction_kernel(T *__restrict__ s, const T *__restrict__ x, const T xmin, const T xmax, const int n)