Skip to content
Snippets Groups Projects
Commit 42cc96ec authored by Rafael Ravedutti's avatar Rafael Ravedutti
Browse files

Fix PairsSimulation instance used within BlockForest


Signed-off-by: default avatarRafael Ravedutti <rafaelravedutti@gmail.com>
parent ccd01789
Branches
Tags
No related merge requests found
......@@ -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));
}
}
......
......@@ -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();
......
......@@ -8,6 +8,7 @@ class Regular6DStencil;
class DomainPartitioner {
friend class Regular6DStencil;
friend class BlockForest;
protected:
real_t *grid_min;
......
......@@ -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");
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment