34 template <
typename T,
typename T_GRID>
39 template <
typename T,
typename T_GRID>
44 template <
typename T,
typename T_GRID>
48 const T_GRID &grid = alpha.
grid();
52 for (
int i = 0; i < num_cells[0]; ++i)
53 for (
int j = 0; j < num_cells[1]; ++j)
54 for (
int k = 0; k < num_cells[2]; ++k) {
55 for (
int axis = 0; axis < T_GRID::dim; ++axis) {
56 typename T_GRID::value_type one_by_dx =
static_cast<typename T_GRID::value_type
>(1.) / (6.0 * dx[axis]);
58 grad_alpha(i, j, k)[axis] =
59 (2 * alpha(i + axis_vectors(axis, 0), j + axis_vectors(axis, 1), k + axis_vectors(axis, 2)) +
61 6 * alpha(i - axis_vectors(axis, 0), j - axis_vectors(axis, 1), k - axis_vectors(axis, 2)) +
62 1 * alpha(i - 2 * axis_vectors(axis, 0), j - 2 * axis_vectors(axis, 1), k - 2 * axis_vectors(axis, 2))) *
68 template <
typename T,
typename T_GRID>
71 const Vec3<int> num_cells = alpha.numCells();
72 const T_GRID &grid = alpha.grid();
76 for (
int i = 0; i < num_cells[0]; ++i)
77 for (
int j = 0; j < num_cells[1]; ++j)
78 for (
int k = 0; k < num_cells[2]; ++k) {
79 for (
int axis = 0; axis < T_GRID::dim; ++axis) {
80 for (
int cmpt = 0; cmpt < T_GRID::dim; ++cmpt) {
81 typename T_GRID::value_type one_by_dx =
static_cast<typename T_GRID::value_type
>(1.) / (6 * dx[cmpt]);
83 grad_alpha(i, j, k)(axis, cmpt) =
84 (2 * alpha(i + axis_vectors(axis, 0), j + axis_vectors(axis, 1), k + axis_vectors(axis, 2))[axis] +
85 3 * alpha(i, j, k)[axis] -
86 6 * alpha(i - axis_vectors(axis, 0), j - axis_vectors(axis, 1), k - axis_vectors(axis, 2))[axis] +
87 1 * alpha(i - 2 * axis_vectors(axis, 0), j - 2 * axis_vectors(axis, 1),
88 k - 2 * axis_vectors(axis, 2))[axis]) *
void compute(const Array< T_GRID, T > &alpha, Array< T_GRID, Vec3< T >> &grad_alpha)
const Vec3< int > numCells() const
const T_GRID & grid() const