diff --git a/src/mesa_pd/domain/BlockForestDomain.cpp b/src/mesa_pd/domain/BlockForestDomain.cpp index 4339671d40ed67464635cd3957c2bd028970b6c7..12e341fd98c58bc6b312d593bea9c569b398c12b 100644 --- a/src/mesa_pd/domain/BlockForestDomain.cpp +++ b/src/mesa_pd/domain/BlockForestDomain.cpp @@ -32,6 +32,12 @@ namespace domain { /// \post neighborSubdomains_ is sorted by rank BlockForestDomain::BlockForestDomain(const std::shared_ptr<blockforest::BlockForest>& blockForest) : blockForest_(blockForest) +{ + refresh(); +} + +/// \post neighborSubdomains_ is sorted by rank +void BlockForestDomain::refresh() { ownRank_ = mpi::MPIManager::instance()->rank(); @@ -41,6 +47,9 @@ BlockForestDomain::BlockForestDomain(const std::shared_ptr<blockforest::BlockFor if (blockForest_->empty()) return; + localAABBs_.clear(); + neighborSubdomains_.clear(); + neighborProcesses_.clear(); unionOfLocalAABBs_ = blockForest_->begin()->getAABB(); for (auto& iBlk : *blockForest_) { diff --git a/src/mesa_pd/domain/BlockForestDomain.h b/src/mesa_pd/domain/BlockForestDomain.h index 897b56348a8b2874a9384bb0f99fdd3ce982a914..e4d01fbb9863317c249c4f20b0aad0d54a523de0 100644 --- a/src/mesa_pd/domain/BlockForestDomain.h +++ b/src/mesa_pd/domain/BlockForestDomain.h @@ -35,6 +35,14 @@ class BlockForestDomain : public IDomain public: BlockForestDomain(const std::shared_ptr<blockforest::BlockForest>& blockForest); + /** + * @brief If the BlockForest is changed this function has to be called in order to + * update all interal caches! + * + * Updates the local caches for local and neighbor AABBs. + */ + void refresh(); + bool isContainedInProcessSubdomain(const uint_t rank, const Vec3& pt) const override; bool isContainedInLocalSubdomain(const Vec3& pt, const real_t& radius) const override; /// Is the sphere defined by \p pt and \p radius completely inside the local subdomin? @@ -48,6 +56,7 @@ public: bool intersectsWithProcessSubdomain(const uint_t rank, const Vec3& pt, const real_t& radius) const override; void correctParticlePosition(Vec3& pt) const override; + const math::AABB& getUnionOfLocalAABBs() const {return unionOfLocalAABBs_;} size_t getNumLocalAABBs() const {return localAABBs_.size();} size_t getNumNeighborSubdomains() const {return neighborSubdomains_.size();} size_t getNumNeighborProcesses() const {return neighborProcesses_.size();}