201 y_upper[1] = (y_upper[1] + 1) % mNumGridPts[1];
203 std::array<long, SPACE_DIM> xy_upper = x_upper;
204 xy_upper[1] = y_upper[1];
206 const double field_xy_lower = rRandomField[GetLinearIndex(lower_left)];
207 const double field_x_upper = rRandomField[GetLinearIndex(x_upper)];
208 const double field_y_upper = rRandomField[GetLinearIndex(y_upper)];
209 const double field_xy_upper = rRandomField[GetLinearIndex(xy_upper)];
212 const std::array<double, SPACE_DIM> lower_location = GetPositionUsingGridIndex(lower_left);
213 const double dist_x_lower = rLocation[0] - lower_location[0];
214 const double dist_x_upper = mGridSpacing[0] - dist_x_lower;
215 const double dist_y_lower = rLocation[1] - lower_location[1];
216 const double dist_y_upper = mGridSpacing[1] - dist_y_lower;
218 interpolated_value = mOneOverGridSpacing[0] * mOneOverGridSpacing[1] * (field_xy_lower * dist_x_upper * dist_y_upper +
219 field_x_upper * dist_x_lower * dist_y_upper +
220 field_y_upper * dist_x_upper * dist_y_lower +
221 field_xy_upper * dist_x_lower * dist_y_lower);
228 std::array<long, SPACE_DIM> x_upper = lower_left;
229 x_upper[0] = (x_upper[0] + 1) % mNumGridPts[0];
231 std::array<long, SPACE_DIM> y_upper = lower_left;
232 y_upper[1] = (y_upper[1] + 1) % mNumGridPts[1];
234 std::array<long, SPACE_DIM> z_upper = lower_left;
235 z_upper[2] = (z_upper[2] + 1) % mNumGridPts[2];
237 std::array<long, SPACE_DIM> xy_upper = x_upper;
238 xy_upper[1] = y_upper[1];
240 std::array<long, SPACE_DIM> xz_upper = x_upper;
241 xz_upper[2] = z_upper[2];
243 std::array<long, SPACE_DIM> yz_upper = y_upper;
244 yz_upper[2] = z_upper[2];
246 std::array<long, SPACE_DIM> xyz_upper = xy_upper;
247 xyz_upper[2] = z_upper[2];
249 const double field_xyz_lower = rRandomField[GetLinearIndex(lower_left)];
250 const double field_x_upper = rRandomField[GetLinearIndex(x_upper)];
251 const double field_y_upper = rRandomField[GetLinearIndex(y_upper)];
252 const double field_z_upper = rRandomField[GetLinearIndex(z_upper)];
253 const double field_xy_upper = rRandomField[GetLinearIndex(xy_upper)];
254 const double field_xz_upper = rRandomField[GetLinearIndex(xz_upper)];
255 const double field_yz_upper = rRandomField[GetLinearIndex(yz_upper)];
256 const double field_xyz_upper = rRandomField[GetLinearIndex(xyz_upper)];
259 const std::array<double, SPACE_DIM> lower_location = GetPositionUsingGridIndex(lower_left);
260 const double dist_x_lower = rLocation[0] - lower_location[0];
261 const double dist_y_lower = rLocation[1] - lower_location[1];
262 const double dist_z_lower = rLocation[2] - lower_location[2];
264 const double xd = dist_x_lower / mGridSpacing[0];
265 const double yd = dist_y_lower / mGridSpacing[1];
266 const double zd = dist_z_lower / mGridSpacing[2];
268 const double c00 = field_xyz_lower * (1.0 - xd) + (field_x_upper * xd);
269 const double c01 = field_z_upper * (1.0 - xd) + (field_xz_upper * xd);
270 const double c10 = field_y_upper * (1.0 - xd) + (field_xy_upper * xd);
271 const double c11 = field_yz_upper * (1.0 - xd) + (field_xyz_upper * xd);
273 const double c0 = c00 * (1.0 - yd) + (c10 * yd);
274 const double c1 = c01 * (1.0 - yd) + (c11 * yd);
276 const double c = c0 * (1.0 - zd) + (c1 * zd);
277 interpolated_value = c;
285 return interpolated_value;
288template <
unsigned SPACE_DIM>
297 linear_index = gridIndex[0];
302 linear_index = gridIndex[0] +
303 gridIndex[1] * mNumGridPts[0];
308 linear_index = gridIndex[0] +
309 gridIndex[1] * mNumGridPts[0] +
310 gridIndex[2] * mNumGridPts[0] * mNumGridPts[1];
320template <
unsigned SPACE_DIM>
323 std::array<double, SPACE_DIM> position = {{}};
325 for (
unsigned dim = 0; dim < SPACE_DIM; ++dim)
327 position[dim] = mLowerCorner[dim] + mGridSpacing[dim] * gridIndex[dim];