45 const int dim = T_GRID::dim;
46 const int axis_x = 0, axis_y = 1, axis_z = 2;
56 GALS::CPU::Vec3<int>(base_i_j_k[0] + axis_vectors(0, 0), base_i_j_k[1] + axis_vectors(1, 1), base_i_j_k[2]);
58 GALS::CPU::Vec3<int>(base_i_j_k[0], base_i_j_k[1] + axis_vectors(1, 1), base_i_j_k[2] + axis_vectors(2, 2));
60 GALS::CPU::Vec3<int>(base_i_j_k[0] + axis_vectors(0, 0), base_i_j_k[1], base_i_j_k[2] + axis_vectors(2, 2));
62 base_i_j_k[0] + axis_vectors(0, 0), base_i_j_k[1] + axis_vectors(1, 1), base_i_j_k[2] + axis_vectors(2, 2));
65 const auto& dx = grid.dX();
66 const auto& one_over_dx = grid.oneOverDX();
71 levelset.phiPrev()(base_i_j_k), levelset.psiPrev()(base_i_j_k)[axis_x], levelset.phiPrev()(base_ip1_j_k),
72 levelset.psiPrev()(base_ip1_j_k)[axis_x], dx[axis_x], use_gradient_limiting);
74 levelset.phiPrev()(base_i_j_k), levelset.psiPrev()(base_i_j_k)[axis_y], levelset.phiPrev()(base_i_jp1_k),
75 levelset.psiPrev()(base_i_jp1_k)[axis_y], dx[axis_y], use_gradient_limiting);
77 levelset.phiPrev()(base_i_j_k), levelset.psiPrev()(base_i_j_k)[axis_z], levelset.phiPrev()(base_i_j_kp1),
78 levelset.psiPrev()(base_i_j_kp1)[axis_z], dx[axis_z], use_gradient_limiting);
80 levelset.phiPrev()(base_ip1_j_k), levelset.psiPrev()(base_ip1_j_k)[axis_y], levelset.phiPrev()(base_ip1_jp1_k),
81 levelset.psiPrev()(base_ip1_jp1_k)[axis_y], dx[axis_y], use_gradient_limiting);
83 levelset.phiPrev()(base_i_jp1_k), levelset.psiPrev()(base_i_jp1_k)[axis_x], levelset.phiPrev()(base_ip1_jp1_k),
84 levelset.psiPrev()(base_ip1_jp1_k)[axis_x], dx[axis_x], use_gradient_limiting);
86 levelset.phiPrev()(base_ip1_j_k), levelset.psiPrev()(base_ip1_j_k)[axis_z], levelset.phiPrev()(base_ip1_j_kp1),
87 levelset.psiPrev()(base_ip1_j_kp1)[axis_z], dx[axis_z], use_gradient_limiting);
89 levelset.phiPrev()(base_ip1_j_kp1), levelset.psiPrev()(base_ip1_j_kp1)[axis_y],
90 levelset.phiPrev()(base_ip1_jp1_kp1), levelset.psiPrev()(base_ip1_jp1_kp1)[axis_y], dx[axis_y],
91 use_gradient_limiting);
93 levelset.phiPrev()(base_ip1_jp1_k), levelset.psiPrev()(base_ip1_jp1_k)[axis_z],
94 levelset.phiPrev()(base_ip1_jp1_kp1), levelset.psiPrev()(base_ip1_jp1_kp1)[axis_z], dx[axis_z],
95 use_gradient_limiting);
97 levelset.phiPrev()(base_i_j_kp1), levelset.psiPrev()(base_i_j_kp1)[axis_x], levelset.phiPrev()(base_ip1_j_kp1),
98 levelset.psiPrev()(base_ip1_j_kp1)[axis_x], dx[axis_x], use_gradient_limiting);
100 levelset.phiPrev()(base_i_j_kp1), levelset.psiPrev()(base_i_j_kp1)[axis_y], levelset.phiPrev()(base_i_jp1_kp1),
101 levelset.psiPrev()(base_i_jp1_kp1)[axis_y], dx[axis_y], use_gradient_limiting);
103 levelset.phiPrev()(base_i_jp1_kp1), levelset.psiPrev()(base_i_jp1_kp1)[axis_x],
104 levelset.phiPrev()(base_ip1_jp1_kp1), levelset.psiPrev()(base_ip1_jp1_kp1)[axis_x], dx[axis_x],
105 use_gradient_limiting);
107 levelset.phiPrev()(base_i_jp1_k), levelset.psiPrev()(base_i_jp1_k)[axis_z], levelset.phiPrev()(base_i_jp1_kp1),
108 levelset.psiPrev()(base_i_jp1_kp1)[axis_z], dx[axis_z], use_gradient_limiting);
110 levelset.psiPrev()(base_i_j_k)[axis_z], levelset.phiMixedDerivativesPrev()(base_i_j_k)[1],
111 levelset.psiPrev()(base_i_jp1_k)[axis_z], levelset.phiMixedDerivativesPrev()(base_i_jp1_k)[1], dx[axis_y],
112 use_gradient_limiting);
114 levelset.psiPrev()(base_i_j_kp1)[axis_z], levelset.phiMixedDerivativesPrev()(base_i_j_kp1)[1],
115 levelset.psiPrev()(base_i_jp1_kp1)[axis_z], levelset.phiMixedDerivativesPrev()(base_i_jp1_kp1)[1], dx[axis_y],
116 use_gradient_limiting);
118 levelset.psiPrev()(base_i_j_k)[axis_x], levelset.phiMixedDerivativesPrev()(base_i_j_k)[2],
119 levelset.psiPrev()(base_i_j_kp1)[axis_x], levelset.phiMixedDerivativesPrev()(base_i_j_kp1)[2], dx[axis_z],
120 use_gradient_limiting);
122 levelset.psiPrev()(base_i_j_k)[axis_y], levelset.phiMixedDerivativesPrev()(base_i_j_k)[0],
123 levelset.psiPrev()(base_ip1_j_k)[axis_y], levelset.phiMixedDerivativesPrev()(base_ip1_j_k)[0], dx[axis_x],
124 use_gradient_limiting);
126 levelset.phiMixedDerivativesPrev()(base_i_j_k)[0], levelset.phiMixedDerivativesPrev()(base_i_j_k)[3],
127 levelset.phiMixedDerivativesPrev()(base_i_j_kp1)[0], levelset.phiMixedDerivativesPrev()(base_i_j_kp1)[3],
128 dx[axis_z], use_gradient_limiting);
130 levelset.psiPrev()(base_i_j_k)[axis_y], levelset.phiMixedDerivativesPrev()(base_i_j_k)[1],
131 levelset.psiPrev()(base_i_j_kp1)[axis_y], levelset.phiMixedDerivativesPrev()(base_i_j_kp1)[1], dx[axis_z],
132 use_gradient_limiting);
134 levelset.psiPrev()(base_i_j_k)[axis_z], levelset.phiMixedDerivativesPrev()(base_i_j_k)[2],
135 levelset.psiPrev()(base_ip1_j_k)[axis_z], levelset.phiMixedDerivativesPrev()(base_ip1_j_k)[2], dx[axis_x],
136 use_gradient_limiting);
138 levelset.psiPrev()(base_i_j_kp1)[axis_z], levelset.phiMixedDerivativesPrev()(base_i_j_kp1)[2],
139 levelset.psiPrev()(base_ip1_j_kp1)[axis_z], levelset.phiMixedDerivativesPrev()(base_ip1_j_kp1)[2], dx[axis_x],
140 use_gradient_limiting);
142 levelset.psiPrev()(base_i_j_kp1)[axis_y], levelset.phiMixedDerivativesPrev()(base_i_j_kp1)[0],
143 levelset.psiPrev()(base_ip1_j_kp1)[axis_y], levelset.phiMixedDerivativesPrev()(base_ip1_j_kp1)[0], dx[axis_x],
144 use_gradient_limiting);
146 levelset.psiPrev()(base_i_jp1_k)[axis_y], levelset.phiMixedDerivativesPrev()(base_i_jp1_k)[0],
147 levelset.psiPrev()(base_ip1_jp1_k)[axis_y], levelset.phiMixedDerivativesPrev()(base_ip1_jp1_k)[0], dx[axis_x],
148 use_gradient_limiting);
150 levelset.phiMixedDerivativesPrev()(base_i_jp1_k)[0], levelset.phiMixedDerivativesPrev()(base_i_jp1_k)[3],
151 levelset.phiMixedDerivativesPrev()(base_i_jp1_kp1)[0], levelset.phiMixedDerivativesPrev()(base_i_jp1_kp1)[3],
152 dx[axis_z], use_gradient_limiting);
154 levelset.psiPrev()(base_i_jp1_k)[axis_y], levelset.phiMixedDerivativesPrev()(base_i_jp1_k)[1],
155 levelset.psiPrev()(base_i_jp1_kp1)[axis_y], levelset.phiMixedDerivativesPrev()(base_i_jp1_kp1)[1], dx[axis_z],
156 use_gradient_limiting);
158 levelset.psiPrev()(base_i_jp1_k)[axis_z], levelset.phiMixedDerivativesPrev()(base_i_jp1_k)[2],
159 levelset.psiPrev()(base_ip1_jp1_k)[axis_z], levelset.phiMixedDerivativesPrev()(base_ip1_jp1_k)[2], dx[axis_x],
160 use_gradient_limiting);
162 levelset.psiPrev()(base_i_jp1_kp1)[axis_y], levelset.phiMixedDerivativesPrev()(base_i_jp1_kp1)[0],
163 levelset.psiPrev()(base_ip1_jp1_kp1)[axis_y], levelset.phiMixedDerivativesPrev()(base_ip1_jp1_kp1)[0], dx[axis_x],
164 use_gradient_limiting);
166 levelset.psiPrev()(base_i_jp1_kp1)[axis_z], levelset.phiMixedDerivativesPrev()(base_i_jp1_kp1)[2],
167 levelset.psiPrev()(base_ip1_jp1_kp1)[axis_z], levelset.phiMixedDerivativesPrev()(base_ip1_jp1_kp1)[2], dx[axis_x],
168 use_gradient_limiting);
170 levelset.phiMixedDerivativesPrev()(base_ip1_j_k)[0], levelset.phiMixedDerivativesPrev()(base_ip1_j_k)[3],
171 levelset.phiMixedDerivativesPrev()(base_ip1_j_kp1)[0], levelset.phiMixedDerivativesPrev()(base_ip1_j_kp1)[3],
172 dx[axis_z], use_gradient_limiting);
174 levelset.psiPrev()(base_ip1_j_k)[axis_y], levelset.phiMixedDerivativesPrev()(base_ip1_j_k)[1],
175 levelset.psiPrev()(base_ip1_j_kp1)[axis_y], levelset.phiMixedDerivativesPrev()(base_ip1_j_kp1)[1], dx[axis_z],
176 use_gradient_limiting);
178 levelset.phiMixedDerivativesPrev()(base_ip1_jp1_k)[0], levelset.phiMixedDerivativesPrev()(base_ip1_jp1_k)[3],
179 levelset.phiMixedDerivativesPrev()(base_ip1_jp1_kp1)[0], levelset.phiMixedDerivativesPrev()(base_ip1_jp1_kp1)[3],
180 dx[axis_z], use_gradient_limiting);
182 levelset.psiPrev()(base_ip1_jp1_k)[axis_y], levelset.phiMixedDerivativesPrev()(base_ip1_jp1_k)[1],
183 levelset.psiPrev()(base_ip1_jp1_kp1)[axis_y], levelset.phiMixedDerivativesPrev()(base_ip1_jp1_kp1)[1], dx[axis_z],
184 use_gradient_limiting);
186 levelset.psiPrev()(base_ip1_j_k)[axis_z], levelset.phiMixedDerivativesPrev()(base_ip1_j_k)[1],
187 levelset.psiPrev()(base_ip1_jp1_k)[axis_z], levelset.phiMixedDerivativesPrev()(base_ip1_jp1_k)[1], dx[axis_y],
188 use_gradient_limiting);
190 levelset.psiPrev()(base_ip1_j_kp1)[axis_z], levelset.phiMixedDerivativesPrev()(base_ip1_j_kp1)[1],
191 levelset.psiPrev()(base_ip1_jp1_kp1)[axis_z], levelset.phiMixedDerivativesPrev()(base_ip1_jp1_kp1)[1], dx[axis_y],
192 use_gradient_limiting);
194 const T& c_21_x = control_points_x.
c_21;
195 const T& c_12_x = control_points_x.
c_12;
196 const T& c_21_y = control_points_y.
c_21;
197 const T& c_12_y = control_points_y.
c_12;
198 const T& c_30_z = control_points_z.
c_30;
199 const T& c_21_z = control_points_z.
c_21;
200 const T& c_12_z = control_points_z.
c_12;
201 const T& c_03_z = control_points_z.
c_03;
202 const T& c_21_xy = control_points_xy.
c_21;
203 const T& c_12_xy = control_points_xy.
c_12;
204 const T& c_21_yx = control_points_yx.
c_21;
205 const T& c_12_yx = control_points_yx.
c_12;
206 const T& c_30_xz = control_points_xz.
c_30;
207 const T& c_21_xz = control_points_xz.
c_21;
208 const T& c_12_xz = control_points_xz.
c_12;
209 const T& c_03_xz = control_points_xz.
c_03;
210 const T& c_21_zxy = control_points_zxy.
c_21;
211 const T& c_12_zxy = control_points_zxy.
c_12;
212 const T& c_30_xyz = control_points_xyz.
c_30;
213 const T& c_21_xyz = control_points_xyz.
c_21;
214 const T& c_12_xyz = control_points_xyz.
c_12;
215 const T& c_03_xyz = control_points_xyz.
c_03;
216 const T& c_21_zx = control_points_zx.
c_21;
217 const T& c_12_zx = control_points_zx.
c_12;
218 const T& c_21_zy = control_points_zy.
c_21;
219 const T& c_12_zy = control_points_zy.
c_12;
220 const T& c_21_yzx = control_points_yzx.
c_21;
221 const T& c_12_yzx = control_points_yzx.
c_12;
222 const T& c_30_yz = control_points_yz.
c_30;
223 const T& c_21_yz = control_points_yz.
c_21;
224 const T& c_12_yz = control_points_yz.
c_12;
225 const T& c_03_yz = control_points_yz.
c_03;
226 const T& c_21_y_z = control_points_y_z.
c_21;
227 const T& c_12_y_z = control_points_y_z.
c_12;
228 const T& c_21_zy_z = control_points_zy_z.
c_21;
229 const T& c_12_zy_z = control_points_zy_z.
c_12;
230 const T& c_21_z_x = control_points_z_x.
c_21;
231 const T& c_12_z_x = control_points_z_x.
c_12;
232 const T& c_21_x_y = control_points_x_y.
c_21;
233 const T& c_12_x_y = control_points_x_y.
c_12;
234 const T& c_21_z_xy = control_points_z_xy.
c_21;
235 const T& c_12_z_xy = control_points_z_xy.
c_12;
236 const T& c_21_z_y = control_points_z_y.
c_21;
237 const T& c_12_z_y = control_points_z_y.
c_12;
238 const T& c_21_x_z = control_points_x_z.
c_21;
239 const T& c_12_x_z = control_points_x_z.
c_12;
240 const T& c_21_zx_z = control_points_zx_z.
c_21;
241 const T& c_12_zx_z = control_points_zx_z.
c_12;
242 const T& c_21_zx_y = control_points_zx_y.
c_21;
243 const T& c_12_zx_y = control_points_zx_y.
c_12;
244 const T& c_21_yx_y = control_points_yx_y.
c_21;
245 const T& c_12_yx_y = control_points_yx_y.
c_12;
246 const T& c_21_yz_xy = control_points_yz_xy.
c_21;
247 const T& c_12_yz_xy = control_points_yz_xy.
c_12;
248 const T& c_21_yz_y = control_points_yz_y.
c_21;
249 const T& c_12_yz_y = control_points_yz_y.
c_12;
250 const T& c_21_yx_z = control_points_yx_z.
c_21;
251 const T& c_12_yx_z = control_points_yx_z.
c_12;
252 const T& c_21_yzx_y = control_points_yzx_y.
c_21;
253 const T& c_12_yzx_y = control_points_yzx_y.
c_12;
254 const T& c_21_yzx_z = control_points_yzx_z.
c_21;
255 const T& c_12_yzx_z = control_points_yzx_z.
c_12;
256 const T& c_21_xz_xy = control_points_xz_xy.
c_21;
257 const T& c_12_xz_xy = control_points_xz_xy.
c_12;
258 const T& c_21_xz_y = control_points_xz_y.
c_21;
259 const T& c_12_xz_y = control_points_xz_y.
c_12;
260 const T& c_21_xyz_xy = control_points_xyz_xy.
c_21;
261 const T& c_12_xyz_xy = control_points_xyz_xy.
c_12;
262 const T& c_21_xyz_y = control_points_xyz_y.
c_21;
263 const T& c_12_xyz_y = control_points_xyz_y.
c_12;
264 const T& c_21_xy_z = control_points_xy_z.
c_21;
265 const T& c_12_xy_z = control_points_xy_z.
c_12;
266 const T& c_21_zxy_z = control_points_zxy_z.
c_21;
267 const T& c_12_zxy_z = control_points_zxy_z.
c_12;
270 const T& hx_by_three = dx[axis_x] * (T)
one_third;
271 const T& hy_by_three = dx[axis_y] * (T)
one_third;
272 const T& hz_by_three = dx[axis_z] * (T)
one_third;
274 T bx[] = {
B0(eta[0]),
B1(eta[0]),
B2(eta[0]),
B3(eta[0])};
275 T by[] = {
B0(eta[1]),
B1(eta[1]),
B2(eta[1]),
B3(eta[1])};
276 T bz[] = {
B0(eta[2]),
B1(eta[2]),
B2(eta[2]),
B3(eta[2])};
281 T control_points_all[] = {
287 c_21_y + (dx[axis_z] * (T)
one_third * c_21_y_z),
288 c_21_zy - (dx[axis_z] * (T)
one_third * c_21_zy_z),
291 c_12_y + (dx[axis_z] * (T)
one_third * c_12_y_z),
292 c_12_zy - (dx[axis_z] * (T)
one_third * c_12_zy_z),
299 c_21_z + (dx[axis_x] * (T)
one_third * c_21_z_x),
300 c_12_z + (dx[axis_x] * (T)
one_third * c_12_z_x),
302 c_21_x + (dx[axis_y] * (T)
one_third * c_21_x_y),
303 c_21_x + (hx_by_three * hy_by_three * c_21_z_xy) + (hy_by_three * c_21_z_y) + (hz_by_three * c_21_x_z),
304 c_21_zx + (hx_by_three * hy_by_three * c_12_z_xy) + (hy_by_three * c_12_z_y) - (hz_by_three * c_21_zx_z),
305 c_21_zx + (hy_by_three * c_21_zx_y),
306 c_21_yx - (hy_by_three * c_21_yx_y),
307 c_21_yx - (hx_by_three * hy_by_three * c_21_yz_xy) - (hy_by_three * c_21_yz_y) + (hz_by_three * c_21_yx_z),
308 c_21_yzx - (hx_by_three * hy_by_three * c_12_yz_xy) - (hy_by_three * c_12_yz_y) - (hz_by_three * c_21_yzx_z),
309 c_21_yzx - (hy_by_three * c_21_yzx_y),
311 c_21_yx + (hz_by_three * c_21_yx_z),
312 c_21_yzx - (hz_by_three * c_21_yzx_z),
315 c_12_x + (hz_by_three * c_12_x_z),
316 c_12_zx - (hz_by_three * c_12_zx_z),
318 c_12_x + (hy_by_three * c_12_x_y),
319 c_12_x - (hx_by_three * hy_by_three * c_21_xz_xy) + (hy_by_three * c_21_xz_y) + (hz_by_three * c_12_x_z),
320 c_12_zx - (hx_by_three * hy_by_three * c_12_xz_xy) + (hy_by_three * c_12_xz_y) - (hz_by_three * c_12_zx_z),
321 c_12_zx + (hy_by_three * c_12_zx_y),
322 c_12_yx - (hy_by_three * c_12_yx_y),
323 c_12_yx + (hx_by_three * hy_by_three * c_21_xyz_xy) - (hy_by_three * c_21_xyz_y) + (hz_by_three * c_12_yx_z),
324 c_12_yzx + (hx_by_three * hy_by_three * c_12_xyz_xy) - (hy_by_three * c_12_xyz_y) - (hz_by_three * c_12_yzx_z),
325 c_12_yzx - (hy_by_three * c_12_yzx_y),
327 c_12_yx + (hz_by_three * c_12_yx_z),
328 c_12_yzx - (hz_by_three * c_12_yzx_z),
335 c_21_xy + (hz_by_three * c_21_xy_z),
336 c_21_zxy - (hz_by_three * c_21_zxy_z),
339 c_12_xy + (hz_by_three * c_12_xy_z),
340 c_12_zxy - (hz_by_three * c_12_zxy_z),
347 for (
int i = 0, l = 0; i < 4; ++i)
348 for (
int j = 0; j < 4; ++j)
349 for (
int k = 0; k < 4; ++k) {
350 hermite_fields.
phi_interpolated += bx[i] * by[j] * bz[k] * control_points_all[l];
354 for (
int i = 0, l = 0; i < 4; ++i)
355 for (
int j = 0; j < 4; ++j)
356 for (
int k = 0; k < 4; ++k) {
357 hermite_fields.
psi_interpolated[axis_x] += bx_prime[i] * by[j] * bz[k] * control_points_all[l];
362 for (
int i = 0, l = 0; i < 4; ++i)
363 for (
int j = 0; j < 4; ++j)
364 for (
int k = 0; k < 4; ++k) {
365 hermite_fields.
psi_interpolated[axis_y] += bx[i] * by_prime[j] * bz[k] * control_points_all[l];
370 for (
int i = 0, l = 0; i < 4; ++i)
371 for (
int j = 0; j < 4; ++j)
372 for (
int k = 0; k < 4; ++k) {
373 hermite_fields.
psi_interpolated[axis_z] += bx[i] * by[j] * bz_prime[k] * control_points_all[l];
378 return hermite_fields;
381 template <
typename T>
389 const T_GRID& grid = levelset.grid();
393 for (
int i = 0; i < num_cells_interp[0]; ++i)
394 for (
int j = 0; j < num_cells_interp[1]; ++j)
395 for (
int k = 0; k < num_cells_interp[2]; ++k) {
396 const auto& hermite_fields = this->interpolate(grid, x_interp(i, j, k), levelset);
398 levelset.phiInterpPrev()(i, j, k) = hermite_fields.phi_interpolated;
399 levelset.psiInterpPrev()(i, j, k) = hermite_fields.psi_interpolated;
T B0(T eta)
cubic Bernstein polynomials
T_VECTOR psi_interpolated
const Vec3< T > & dX() const
static const double one_third
static struct ControlPoints< T > get_control_points(const T &phi_0, const T &phi_x_0, const T &phi_1, const T &phi_x_1, const T &dx, bool use_gradient_limiting=false)