Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/bout/interpolation_z.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected:

public:
explicit ZInterpolation(int y_offset = 0, Mesh* mesh = nullptr,
Region<Ind3D> region_in = {});
const Region<Ind3D>& region_in = {});
virtual ~ZInterpolation() = default;

virtual void calcWeights(const Field3D& delta_z) = 0;
Expand Down
35 changes: 4 additions & 31 deletions src/mesh/interpolation/interpolation_z.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,7 @@
#include <bout/interpolation_z.hxx>
#include <bout/mesh.hxx>

ZInterpolation::ZInterpolation(int y_offset, Mesh* mesh, Region<Ind3D> region_in)
: localmesh(mesh == nullptr ? bout::globals::mesh : mesh), region(region_in),
y_offset(y_offset) {
if (region.size() == 0) {
// Construct region that skips calculating interpolation in y-boundary regions that
// should be filled by boundary conditions

region = localmesh->getRegion3D("RGN_NOBNDRY");

const int ny = localmesh->LocalNy;
const int nz = localmesh->LocalNz;
auto mask_region = Region<Ind3D>(0, -1, 0, -1, 0, 0, ny, nz);
if (y_offset > 0) {
for (auto it = localmesh->iterateBndryUpperY(); not it.isDone(); it.next()) {
mask_region +=
Region<Ind3D>(it.ind, it.ind, localmesh->yend - y_offset + 1, localmesh->yend,
localmesh->zstart, localmesh->zend, ny, nz);
}
} else if (y_offset < 0) {
for (auto it = localmesh->iterateBndryLowerY(); not it.isDone(); it.next()) {
mask_region += Region<Ind3D>(it.ind, it.ind, localmesh->ystart,
localmesh->ystart - y_offset - 1, localmesh->zstart,
localmesh->zend, ny, nz);
}
}

mask_region.unique();

region.mask(mask_region);
}
}
ZInterpolation::ZInterpolation(int y_offset, Mesh* mesh, const Region<Ind3D>& region_in)
Comment thread
ZedThree marked this conversation as resolved.
Comment thread
ZedThree marked this conversation as resolved.
: localmesh(mesh == nullptr ? bout::globals::mesh : mesh),
Comment thread
ZedThree marked this conversation as resolved.
region(region_in.size() == 0 ? localmesh->getRegion3D("RGN_NOY") : region_in),
y_offset(y_offset) {}
3 changes: 3 additions & 0 deletions tests/unit/fake_mesh.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public:
GlobalNx = nx;
GlobalNy = ny;
GlobalNz = nz;
GlobalNxNoBoundaries = nx - 2;
GlobalNyNoBoundaries = ny - 2;
GlobalNzNoBoundaries = nz;
LocalNx = nx;
LocalNy = ny;
LocalNz = nz;
Expand Down
32 changes: 8 additions & 24 deletions tests/unit/mesh/parallel/test_shiftedmetric.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -314,35 +314,19 @@ TYPED_TEST(ShiftedMetricTest, CalcParallelSlices) {
// We don't shift in the guard cells, and the parallel slices are
// stored offset in y, therefore we need to make new regions that we
// can compare the expected and actual outputs over

constexpr bool is_shifted_interp = std::is_same_v<TypeParam, ShiftedMetricInterp>;

// ShiftedMetricInterp doesn't seem to store interpolated values in _any_ of the
// guards, so we can only check the interior X point
const int xstart = is_shifted_interp ? mesh->xstart : 0;
const int xend = is_shifted_interp ? mesh->xend : mesh->LocalNx - 1;

// It also means we can't check in the _y_ guards either.
// TODO(peter): Is this a bug?
const int yup_1_end = is_shifted_interp ? mesh->yend : mesh->yend + 1;
const int yup_2_end = is_shifted_interp ? mesh->yend : mesh->yend + 2;

const int ydown_1_start = is_shifted_interp ? mesh->ystart : mesh->ystart - 1;
const int ydown_2_start = is_shifted_interp ? mesh->ystart : mesh->ystart - 2;

mesh->addRegion3D("RGN_YUP",
Region<Ind3D>(xstart, xend, mesh->ystart + 1, yup_1_end, 0,
mesh->LocalNz - 1, mesh->LocalNy, mesh->LocalNz));
Region<Ind3D>(0, mesh->LocalNx - 1, mesh->ystart + 1, mesh->yend + 1,
0, mesh->LocalNz - 1, mesh->LocalNy, mesh->LocalNz));
mesh->addRegion3D("RGN_YUP2",
Region<Ind3D>(xstart, xend, mesh->ystart + 2, yup_2_end, 0,
mesh->LocalNz - 1, mesh->LocalNy, mesh->LocalNz));
Region<Ind3D>(0, mesh->LocalNx - 1, mesh->ystart + 2, mesh->yend + 2,
0, mesh->LocalNz - 1, mesh->LocalNy, mesh->LocalNz));

mesh->addRegion3D("RGN_YDOWN",
Region<Ind3D>(xstart, xend, ydown_1_start, mesh->yend - 1, 0,
mesh->LocalNz - 1, mesh->LocalNy, mesh->LocalNz));
Region<Ind3D>(0, mesh->LocalNx - 1, mesh->ystart - 1, mesh->yend - 1,
0, mesh->LocalNz - 1, mesh->LocalNy, mesh->LocalNz));
mesh->addRegion3D("RGN_YDOWN2",
Region<Ind3D>(xstart, xend, ydown_2_start, mesh->yend - 2, 0,
mesh->LocalNz - 1, mesh->LocalNy, mesh->LocalNz));
Region<Ind3D>(0, mesh->LocalNx - 1, mesh->ystart - 2, mesh->yend - 2,
0, mesh->LocalNz - 1, mesh->LocalNy, mesh->LocalNz));
output_info.enable();

// Actual interesting bit here!
Expand Down
Loading