Skip to content
Merged
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
4 changes: 2 additions & 2 deletions include/bout/mesh.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,11 @@ public:

/// Is there a boundary on the lower guard cells in Y
/// on any processor along the X direction?
bool hasBndryLowerY();
virtual bool hasBndryLowerY() const = 0;

/// Is there a boundary on the upper guard cells in Y
/// on any processor along the X direction?
bool hasBndryUpperY();
virtual bool hasBndryUpperY() const = 0;
// Boundary regions

/// Return a vector containing all the boundary regions on this processor
Expand Down
14 changes: 14 additions & 0 deletions src/mesh/impls/bout/boutmesh.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,20 @@ int BoutMesh::load() {
// Add boundary regions
addBoundaryRegions();

// Set cached values
{
int mybndry = static_cast<int>(!(iterateBndryLowerY().isDone()));
int allbndry = 0;
mpi->MPI_Allreduce(&mybndry, &allbndry, 1, MPI_INT, MPI_BOR, getXcomm(yend));
has_boundary_lower_y = static_cast<bool>(allbndry);
}
{
int mybndry = static_cast<int>(!(iterateBndryUpperY().isDone()));
int allbndry = 0;
mpi->MPI_Allreduce(&mybndry, &allbndry, 1, MPI_INT, MPI_BOR, getXcomm(ystart));
has_boundary_upper_y = static_cast<bool>(allbndry);
}

// Initialize default coordinates
getCoordinates();

Expand Down
5 changes: 5 additions & 0 deletions src/mesh/impls/bout/boutmesh.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ public:
RangeIterator iterateBndryUpperInnerY() const override;
RangeIterator iterateBndryUpperOuterY() const override;

bool hasBndryLowerY() const override { return has_boundary_lower_y; }
bool hasBndryUpperY() const override { return has_boundary_upper_y; }

// Boundary regions
std::vector<BoundaryRegion*> getBoundaries() override;
std::vector<std::shared_ptr<BoundaryRegionPar>>
Expand Down Expand Up @@ -400,6 +403,8 @@ private:
static_cast<int>(BoundaryParType::SIZE)>
par_boundary; // Vector of parallel boundary regions

bool has_boundary_lower_y{false};
bool has_boundary_upper_y{false};
//////////////////////////////////////////////////
// Communications

Expand Down
28 changes: 0 additions & 28 deletions src/mesh/mesh.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -408,34 +408,6 @@ int Mesh::ySize(int jx) const {
return all;
}

bool Mesh::hasBndryLowerY() {
static bool calc = false, answer;
if (calc) {
return answer; // Already calculated
}

int mybndry = static_cast<int>(!(iterateBndryLowerY().isDone()));
int allbndry;
mpi->MPI_Allreduce(&mybndry, &allbndry, 1, MPI_INT, MPI_BOR, getXcomm(yend));
answer = static_cast<bool>(allbndry);
calc = true;
return answer;
}

bool Mesh::hasBndryUpperY() {
static bool calc = false, answer;
if (calc) {
return answer; // Already calculated
}

int mybndry = static_cast<int>(!(iterateBndryUpperY().isDone()));
int allbndry;
mpi->MPI_Allreduce(&mybndry, &allbndry, 1, MPI_INT, MPI_BOR, getXcomm(ystart));
answer = static_cast<bool>(allbndry);
calc = true;
return answer;
}

int Mesh::localSize3D() {
if (localNumCells3D < 0) {
const int xs = firstX() ? xstart - 1 : xstart;
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/fake_mesh.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ public:
RangeIterator iterateBndryLowerInnerY() const override { return RangeIterator(); }
RangeIterator iterateBndryUpperOuterY() const override { return RangeIterator(); }
RangeIterator iterateBndryUpperInnerY() const override { return RangeIterator(); }
bool hasBndryLowerY() const override { return false; }
bool hasBndryUpperY() const override { return false; }
void addBoundary(BoundaryRegion* region) override { boundaries.push_back(region); }
std::vector<BoundaryRegion*> getBoundaries() override { return boundaries; }
std::vector<std::shared_ptr<BoundaryRegionPar>>
Expand Down
Loading