35#ifndef __LPT_PERIODIC_BC_KERNEL_H__
36#define __LPT_PERIODIC_BC_KERNEL_H__
44 const T cos_theta = cos(theta);
45 const T sin_theta = sin(theta);
47 x[
i] = cos_theta * x_old - sin_theta * y_old;
48 y[
i] = sin_theta * x_old + cos_theta * y_old;
57 const int n_periodic_dirs,
58 const T periodic_dir_x1,
59 const T periodic_dir_y1,
60 const T periodic_dir_z1,
61 const T periodic_dir_x2,
62 const T periodic_dir_y2,
63 const T periodic_dir_z2,
64 const T periodic_dir_x3,
65 const T periodic_dir_y3,
66 const T periodic_dir_z3,
67 const T periodic_min1,
68 const T periodic_min2,
69 const T periodic_min3,
70 const T periodic_max1,
71 const T periodic_max2,
72 const T periodic_max3,
73 const T periodic_shift_x1,
74 const T periodic_shift_y1,
75 const T periodic_shift_z1,
76 const T periodic_shift_x2,
77 const T periodic_shift_y2,
78 const T periodic_shift_z2,
79 const T periodic_shift_x3,
80 const T periodic_shift_y3,
81 const T periodic_shift_z3,
82 const T periodic_len1,
83 const T periodic_len2,
84 const T periodic_len3) {
87 const int idx = blockIdx.x * blockDim.x + threadIdx.x;
88 const int str = blockDim.x * gridDim.x;
90 for (
int i = idx;
i < n;
i += str) {
95 for (
int j = 0;
j < n_periodic_dirs;
j++) {
96 T dir0 = periodic_dir_x1;
97 T dir1 = periodic_dir_y1;
98 T dir2 = periodic_dir_z1;
99 T min = periodic_min1;
100 T
max = periodic_max1;
101 T shift0 = periodic_shift_x1;
102 T shift1 = periodic_shift_y1;
103 T shift2 = periodic_shift_z1;
104 T len = periodic_len1;
108 dir0 = periodic_dir_x2;
109 dir1 = periodic_dir_y2;
110 dir2 = periodic_dir_z2;
113 shift0 = periodic_shift_x2;
114 shift1 = periodic_shift_y2;
115 shift2 = periodic_shift_z2;
119 dir0 = periodic_dir_x3;
120 dir1 = periodic_dir_y3;
121 dir2 = periodic_dir_z3;
124 shift0 = periodic_shift_x3;
125 shift1 = periodic_shift_y3;
126 shift2 = periodic_shift_z3;
133 T coord = point0 * dir0 + point1 * dir1 + point2 * dir2;
135 while (coord < min - tol) {
142 while (coord >
max + tol) {
168 T * __restrict__ u_lag,
169 T * __restrict__ v_lag,
170 T * __restrict__ w_lag,
171 T * __restrict__ u_laglag,
172 T * __restrict__ v_laglag,
173 T * __restrict__ w_laglag,
174 T * __restrict__ acc_xlag,
175 T * __restrict__ acc_ylag,
176 T * __restrict__ acc_zlag,
177 T * __restrict__ acc_xlaglag,
178 T * __restrict__ acc_ylaglag,
179 T * __restrict__ acc_zlaglag) {
181 const T tol = 1.0e-8;
182 const T pi = acos((T) -1.0);
183 const int idx = blockIdx.x * blockDim.x + threadIdx.x;
184 const int str = blockDim.x * gridDim.x;
186 for (
int i = idx;
i < n;
i += str) {
187 const T radius = sqrt(
x[
i] *
x[
i] + y[
i] * y[
i]);
188 const T theta_old = fmod(atan2(y[
i],
x[
i]) + 2.0 * pi, 2.0 * pi);
191 while (theta < theta_min - tol) {
195 while (theta > theta_max + tol) {
199 const T dtheta = theta - theta_old;
200 x[
i] = radius * cos(theta);
201 y[
i] = radius * sin(theta);
202 if (fabs(dtheta) <= tol) {
209 if (u_lag && v_lag) {
212 if (u_laglag && v_laglag) {
215 if (acc_xlag && acc_ylag) {
218 if (acc_xlaglag && acc_ylaglag) {
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ w
__global__ void const T *__restrict__ u
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ v
__global__ void const T *__restrict__ x
__device__ void lpt_rotate_xy(T *x, T *y, const int i, const T theta)
__global__ void lpt_periodic_bc_wrap_translational_kernel(T *__restrict__ x, T *__restrict__ y, T *__restrict__ z, const int n, const int n_periodic_dirs, const T periodic_dir_x1, const T periodic_dir_y1, const T periodic_dir_z1, const T periodic_dir_x2, const T periodic_dir_y2, const T periodic_dir_z2, const T periodic_dir_x3, const T periodic_dir_y3, const T periodic_dir_z3, const T periodic_min1, const T periodic_min2, const T periodic_min3, const T periodic_max1, const T periodic_max2, const T periodic_max3, const T periodic_shift_x1, const T periodic_shift_y1, const T periodic_shift_z1, const T periodic_shift_x2, const T periodic_shift_y2, const T periodic_shift_z2, const T periodic_shift_x3, const T periodic_shift_y3, const T periodic_shift_z3, const T periodic_len1, const T periodic_len2, const T periodic_len3)
__global__ void lpt_periodic_bc_wrap_rotational_kernel(T *__restrict__ x, T *__restrict__ y, T *__restrict__ z, const int n, const T theta_min, const T theta_max, const T theta_len, T *__restrict__ u, T *__restrict__ v, T *__restrict__ w, T *__restrict__ u_lag, T *__restrict__ v_lag, T *__restrict__ w_lag, T *__restrict__ u_laglag, T *__restrict__ v_laglag, T *__restrict__ w_laglag, T *__restrict__ acc_xlag, T *__restrict__ acc_ylag, T *__restrict__ acc_zlag, T *__restrict__ acc_xlaglag, T *__restrict__ acc_ylaglag, T *__restrict__ acc_zlaglag)