34 template <
typename T,
typename T_GRID>
39 template <
typename T,
typename T_GRID>
44 template <
typename T,
typename T_GRID>
49 const T_GRID &grid = alpha.
grid();
53 for (
int i = 0; i < num_cells[0]; ++i)
54 for (
int j = 0; j < num_cells[1]; ++j)
55 for (
int k = 0; k < num_cells[2]; ++k) {
56 for (
int axis = 0; axis < T_GRID::dim; ++axis) {
57 typename T_GRID::value_type one_by_dx =
static_cast<typename T_GRID::value_type
>(1.) / dx[axis];
59 grad_alpha(i, j, k)[axis] =
60 (alpha(i + axis_vectors(axis, 0), j + axis_vectors(axis, 1), k + axis_vectors(axis, 2)) -
61 alpha(i - axis_vectors(axis, 0), j - axis_vectors(axis, 1), k - axis_vectors(axis, 2))) *
62 one_by_dx * static_cast<T>(0.5);
67 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.) / dx[cmpt];
83 grad_alpha(i, j, k)(axis, cmpt) =
84 (alpha(i + axis_vectors(axis, 0), j + axis_vectors(axis, 1), k + axis_vectors(axis, 2))[axis] -
85 alpha(i - axis_vectors(axis, 0), j - axis_vectors(axis, 1), k - axis_vectors(axis, 2))[axis]) *
86 one_by_dx * static_cast<T>(0.5);
const Vec3< int > numCells() const
void compute(const Array< T_GRID, T > &alpha, Array< T_GRID, Vec3< T >> &grad_alpha)
const T_GRID & grid() const