diff --git a/runtime/domain/block_forest.cpp b/runtime/domain/block_forest.cpp index 1e8966b6231220ba42827eacdd984b9e6fec4b3e..9718b95ebc9711a56fdd68766119a67d964e80a8 100644 --- a/runtime/domain/block_forest.cpp +++ b/runtime/domain/block_forest.cpp @@ -47,7 +47,7 @@ void BlockForest::updateNeighborhood() { if(neighbor_info.computationalWeight > 0 && find_if(begin, end, [neighbor_block](const auto &nbh) { - return nbh == nb; }) == end) { + return nbh == neighbor_block; }) == end) { neighborhood[neighbor_rank].push_back(neighbor_aabb); blocks_pushed[neighbor_rank].push_back(neighbor_block); @@ -79,11 +79,11 @@ void BlockForest::updateNeighborhood() { } void BlockForest::copyRuntimeArray(const std::string& name, void *dest, const int size) { - void *src = name.compare("ranks") ? ranks.data() : - name.compare("naabbs") ? naabbs.data() : - name.compare("aabb_offsets") ? aabb_offsets.data() : - name.compare("aabbs") ? aabbs.data() : - name.compare("subdom") ? subdom : nullptr; + void *src = name.compare("ranks") ? static_cast<void *>(ranks.data()) : + name.compare("naabbs") ? static_cast<void *>(naabbs.data()) : + name.compare("aabb_offsets") ? static_cast<void *>(aabb_offsets.data()) : + name.compare("aabbs") ? static_cast<void *>(aabbs.data()) : + name.compare("subdom") ? static_cast<void *>(subdom) : nullptr; PAIRS_ASSERT(src != nullptr); bool is_real = name.compare("aabbs") || name.compare("subdom"); @@ -91,7 +91,7 @@ void BlockForest::copyRuntimeArray(const std::string& name, void *dest, const in std::memcpy(dest, src, size * tsize); } -void BlockForest::updateWeights(PairsSimulation *ps, int nparticles) { +void BlockForest::updateWeights() { walberla::mpi::BufferSystem bs(walberla::mpi::MPIManager::instance()->comm(), 756); info.clear(); @@ -101,7 +101,8 @@ void BlockForest::updateWeights(PairsSimulation *ps, int nparticles) { auto& block_info = info[block->getId()]; pairs::compute_boundary_weights( - ps, aabb.xMin(), aabb.xMax(), aabb.yMin(), aabb.yMax(), aabb.zMin(), aabb.zMax(), + this->ps, + aabb.xMin(), aabb.xMax(), aabb.yMin(), aabb.yMax(), aabb.zMin(), aabb.zMax(), &(block_info.computationalWeight), &(block_info.communicationWeight)); for(int branch = 0; branch < 8; ++branch) { @@ -110,7 +111,8 @@ void BlockForest::updateWeights(PairsSimulation *ps, int nparticles) { auto& b_info = info[b_id]; pairs::compute_boundary_weights( - ps, b_aabb.xMin(), b_aabb.xMax(), b_aabb.yMin(), b_aabb.yMax(), b_aabb.zMin(), b_aabb.zMax(), + this->ps, + b_aabb.xMin(), b_aabb.xMax(), b_aabb.yMin(), b_aabb.yMax(), b_aabb.zMin(), b_aabb.zMax(), &(b_info.computationalWeight), &(b_info.communicationWeight)); } } diff --git a/runtime/domain/block_forest.hpp b/runtime/domain/block_forest.hpp index aa622a05d5f6c15926244b00a394f89b019dbdb1..2c07fc24d7ec6cf5374669ba7b80486696b7a795 100644 --- a/runtime/domain/block_forest.hpp +++ b/runtime/domain/block_forest.hpp @@ -20,8 +20,11 @@ namespace pairs { +class PairsSimulation; + class BlockForest : public DomainPartitioner { private: + PairsSimulation *ps; std::shared_ptr<walberla::BlockForest> forest; walberla::blockforest::InfoCollection info; std::map<int, std::vector<walberla::math::AABB>> neighborhood; @@ -36,7 +39,9 @@ private: public: BlockForest( + PairsSimulation *ps_, real_t xmin, real_t xmax, real_t ymin, real_t ymax, real_t zmin, real_t zmax) : + ps(ps_), DomainPartitioner(xmin, xmax, ymin, ymax, zmin, zmax) { subdom = new real_t[ndims * 2]; @@ -55,7 +60,7 @@ public: void initializeWorkloadBalancer(); void updateNeighborhood(); - void updateWeights(real_t *position, int nparticles); + void updateWeights(); walberla::Vector3<int> getBlockConfig(int num_processes, int nx, int ny, int nz); int getInitialRefinementLevel(int num_processes); void setBoundingBox(); diff --git a/runtime/domain/domain_partitioning.hpp b/runtime/domain/domain_partitioning.hpp index 7384133dad1d8c55c3a6793417e40acece0f1b76..5806f3a00d281dc4dac283a9e84753de854ae684 100644 --- a/runtime/domain/domain_partitioning.hpp +++ b/runtime/domain/domain_partitioning.hpp @@ -8,6 +8,7 @@ class Regular6DStencil; class DomainPartitioner { friend class Regular6DStencil; + friend class BlockForest; protected: real_t *grid_min; diff --git a/runtime/pairs.cpp b/runtime/pairs.cpp index ab0ec4768031f11cd31f87dd2b4ec4194f5f7c5b..9ec0c8240ecc98a621adc50b288abdd737fc7e12 100644 --- a/runtime/pairs.cpp +++ b/runtime/pairs.cpp @@ -23,7 +23,7 @@ void PairsSimulation::initDomain( const int flags[] = {1, 1, 0}; dom_part = new Regular6DStencil(xmin, xmax, ymin, ymax, zmin, zmax, flags); } else if(dom_part_type == BlockForestPartitioning) { - dom_part = new BlockForest(xmin, xmax, ymin, ymax, zmin, zmax); + dom_part = new BlockForest(this, xmin, xmax, ymin, ymax, zmin, zmax); } else { PAIRS_EXCEPTION("Domain partitioning type not implemented!\n"); }