From 1c80bd93b3c53178b8f544febe1f8cd9382b0003 Mon Sep 17 00:00:00 2001 From: Sebastian Eibl <sebastian.eibl@fau.de> Date: Fri, 9 Aug 2019 16:50:54 +0200 Subject: [PATCH] [REFACTOR] initialization of BlockForestDomain moved initialization of BlockForestDomain into refresh function This way the BlockForestDomain can be refreshed (e.g. as part of the load balancing) without recreating it. --- src/mesa_pd/domain/BlockForestDomain.cpp | 9 +++++++++ src/mesa_pd/domain/BlockForestDomain.h | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/mesa_pd/domain/BlockForestDomain.cpp b/src/mesa_pd/domain/BlockForestDomain.cpp index 4339671d4..12e341fd9 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 897b56348..e4d01fbb9 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();} -- GitLab