diff --git a/include/bout/field3d.hxx b/include/bout/field3d.hxx index c6e1d1191d..54d9fb85c9 100644 --- a/include/bout/field3d.hxx +++ b/include/bout/field3d.hxx @@ -331,6 +331,7 @@ public: const Region& getValidRegionWithDefault(const std::string& region_name) const; void setRegion(const std::string& region_name) override; void resetRegion() override { regionID.reset(); }; + void resetRegionParallel(); void setRegion(size_t id) override { regionID = id; }; void setRegion(std::optional id) override { regionID = id; }; std::optional getRegionID() const override { return regionID; }; diff --git a/src/field/field3d.cxx b/src/field/field3d.cxx index fe9fdc9263..da7bd494c9 100644 --- a/src/field/field3d.cxx +++ b/src/field/field3d.cxx @@ -145,6 +145,7 @@ void Field3D::splitParallelSlices() { yup_fields.emplace_back(fieldmesh); ydown_fields.emplace_back(fieldmesh); } + resetRegionParallel(); } void Field3D::clearParallelSlices() { @@ -841,6 +842,15 @@ void Field3D::setRegion(const std::string& region_name) { regionID = fieldmesh->getRegionID(region_name); } +void Field3D::resetRegionParallel() { + if (isFci()) { + for (int i = 0; i < fieldmesh->ystart; ++i) { + yup_fields[i].setRegion(fmt::format("RGN_YPAR_{:+d}", i + 1)); + ydown_fields[i].setRegion(fmt::format("RGN_YPAR_{:+d}", -i - 1)); + } + } +} + Field3D& Field3D::enableTracking(const std::string& name, std::weak_ptr _tracking) { tracking = std::move(_tracking); diff --git a/src/mesh/mesh.cxx b/src/mesh/mesh.cxx index 8964a6b797..010e799b2b 100644 --- a/src/mesh/mesh.cxx +++ b/src/mesh/mesh.cxx @@ -654,6 +654,12 @@ void Mesh::createDefaultRegions() { + getRegion3D("RGN_YGUARDS") + getRegion3D("RGN_ZGUARDS")) .unique()); + for (int offset_ = -ystart; offset_ <= ystart; ++offset_) { + const auto region = fmt::format("RGN_YPAR_{:+d}", offset_); + addRegion3D(region, Region(xstart, xend, ystart + offset_, yend + offset_, 0, + LocalNz - 1, LocalNy, LocalNz)); + } + //2D regions addRegion2D("RGN_ALL", Region(0, LocalNx - 1, 0, LocalNy - 1, 0, 0, LocalNy, 1, maxregionblocksize)); diff --git a/src/mesh/parallel/fci.cxx b/src/mesh/parallel/fci.cxx index 39654519af..152ffaed2d 100644 --- a/src/mesh/parallel/fci.cxx +++ b/src/mesh/parallel/fci.cxx @@ -261,16 +261,6 @@ FCIMap::FCIMap(Mesh& mesh, [[maybe_unused]] const Coordinates::FieldMetric& dy, region_no_boundary = region_no_boundary.mask(to_remove); interp->setRegion(region_no_boundary); - - const auto region = fmt::format("RGN_YPAR_{:+d}", offset_); - if (not map_mesh->hasRegion3D(region)) { - // The valid region for this slice - map_mesh->addRegion3D(region, Region(map_mesh->xstart, map_mesh->xend, - map_mesh->ystart + offset_, - map_mesh->yend + offset_, 0, - map_mesh->LocalNz - 1, map_mesh->LocalNy, - map_mesh->LocalNz)); - } } Field3D FCIMap::integrate(Field3D& f) const {