21 #ifndef THUNDEREGG_GMG_LINEARRESTRICTOR_H
22 #define THUNDEREGG_GMG_LINEARRESTRICTOR_H
40 bool extrapolate_boundary_ghosts;
54 std::array<int, D> starts;
55 for (
size_t i = 0; i < D; i++) {
56 starts[i] = orth.isLowerOnAxis(i) ? 0 : coarse_view.
getEnd()[i] + 1;
64 Loop::OverInteriorIndexes<D>(fine_ghost, [&](
const std::array<int, D>& coord) {
65 std::array<int, D> coarse_coord;
66 for (
size_t x = 0; x < s.getAxisIndex(); x++) {
67 coarse_coord[x] = (coord[x] + starts[x]) / 2;
69 for (
size_t x = s.getAxisIndex() + 1; x < D; x++) {
70 coarse_coord[x - 1] = (coord[x - 1] + starts[x]) / 2;
72 coarse_coord[D - 1] = coord[D - 1];
73 coarse_ghost[coarse_coord] += (3 * fine_ghost[coord] - fine_interior[coord]) / (1 << D);
77 if constexpr (D >= 2) {
80 std::array<int, D> neg_one;
82 std::array<int, D> zero;
87 Loop::OverInteriorIndexes<1>(fine_ghost, [&](
const std::array<int, 1>& coord) {
88 coarse_ghost[coord] += (3 * fine_ghost[coord] - fine_interior[coord]);
110 std::array<int, D> starts;
111 for (
size_t i = 0; i < D; i++) {
112 starts[i] = orth.isLowerOnAxis(i) ? 0 : (coarse_view.
getEnd()[i] + 1);
116 Loop::OverInteriorIndexes<D + 1>(fine_view, [&](
const std::array<int, D + 1>& coord) {
117 std::array<int, D + 1> coarse_coord;
118 for (
size_t x = 0; x < D; x++) {
119 coarse_coord[x] = (coord[x] + starts[x]) / 2;
121 coarse_coord[D] = coord[D];
122 coarse_view[coarse_coord] += fine_view[coord] / (1 << D);
125 if (extrapolate_boundary_ghosts) {
126 extrapolateBoundaries(pinfo, fine_view, coarse_view);
146 if (extrapolate_boundary_ghosts) {
147 Loop::OverAllIndexes<D + 1>(fine_view, [&](
const std::array<int, D + 1>& coord) {
148 coarse_view[coord] += fine_view[coord];
151 Loop::OverInteriorIndexes<D + 1>(fine_view, [&](
const std::array<int, D + 1>& coord) {
152 coarse_view[coord] += fine_view[coord];
168 bool extrapolate_boundary_ghosts =
false)
170 , extrapolate_boundary_ghosts(extrapolate_boundary_ghosts)
180 const std::vector<std::pair<
int, std::reference_wrapper<
const PatchInfo<D>>>>& patches,
182 Vector<D>& coarser_vector)
const override
184 for (
const auto& pair : patches) {
185 if (pair.second.get().hasCoarseParent()) {
186 restrictToCoarserParent(pair.second.get(), pair.first, finer_vector, coarser_vector);
188 copyToParent(pair.second.get(), pair.first, finer_vector, coarser_vector);