diff --git a/src/pe/amr/weight_assignment/MetisAssignmentFunctor.h b/src/pe/amr/weight_assignment/MetisAssignmentFunctor.h index 720c80a2e363302f6b60a582c7628000cada10ea..692f0cd13a403038e54fb843568684e8dd6957b4 100644 --- a/src/pe/amr/weight_assignment/MetisAssignmentFunctor.h +++ b/src/pe/amr/weight_assignment/MetisAssignmentFunctor.h @@ -41,32 +41,37 @@ public: { for( auto it = blockData.begin(); it != blockData.end(); ++it ) { - const double weight = double_c( ic_->find( it->first->getId() )->second.numberOfLocalBodies ) + baseWeight_; - //const double commWeight = double_c( edgeWeightFactor * (double_c(ic_->find( it->first->getId() )->second.numberOfShadowBodies) + baseWeight_)) + 1; + const PhantomBlock * block = it->first; + //only change of one level is supported! + WALBERLA_ASSERT_LESS( abs(int_c(block->getLevel()) - int_c(block->getSourceLevel())), 2 ); + + //all information is provided by info collection + auto infoIt = ic_->find( block->getId() ); + WALBERLA_CHECK_UNEQUAL( infoIt, ic_->end() ); + const double weight = double_c( infoIt->second.numberOfLocalBodies ) + baseWeight_; blockforest::DynamicParMetisBlockInfo info( 0 ); info.setVertexWeight( int64_c(weight) ); info.setVertexSize( int64_c( weight ) ); info.setVertexCoords( it->first->getAABB().center() ); for( uint_t nb = uint_t(0); nb < it->first->getNeighborhoodSize(); ++nb ) { - info.setEdgeWeight(it->first->getNeighborId(nb), int64_c(edgeWeight_) ); + const double dx(1.0); + info.setEdgeWeight(it->first->getNeighborId(nb), + int64_c(it->first->getAABB().intersectionVolume( it->first->getNeighborAABB(nb).getExtended(dx) )) ); } it->second = info; + continue; } } inline void setBaseWeight( const double weight) { baseWeight_ = weight;} inline double getBaseWeight() const { return baseWeight_; } - inline void setEdgeWeight( const double weight) { edgeWeight_ = weight;} - inline double getEdgeWeight() const { return edgeWeight_; } - private: shared_ptr< InfoCollection > ic_; ///Base weight due to allocated data structures. A weight of zero for blocks is dangerous as empty blocks might accumulate on one process! double baseWeight_ = 10.0; - double edgeWeight_ = 1.0; }; } diff --git a/src/pe/amr/weight_assignment/WeightAssignmentFunctor.h b/src/pe/amr/weight_assignment/WeightAssignmentFunctor.h index 1632bc596e1c3b01fc9d090e5fd29ca6c1f18ad0..7c7b381786967bd739b31f6c49ed673230ebd4fb 100644 --- a/src/pe/amr/weight_assignment/WeightAssignmentFunctor.h +++ b/src/pe/amr/weight_assignment/WeightAssignmentFunctor.h @@ -43,37 +43,11 @@ public: { const PhantomBlock * block = it->first; //only change of one level is supported! - WALBERLA_ASSERT_LESS( int_c(block->getLevel()) - int_c(block->getSourceLevel()), 2 ); + WALBERLA_CHECK_LESS( abs(int_c(block->getLevel()) - int_c(block->getSourceLevel())), 2 ); - if (block->sourceBlockIsLarger()) - { - auto infoIt = ic_->find( block->getId()/*.getFatherId()*/ ); - WALBERLA_ASSERT_UNEQUAL( infoIt, ic_->end() ); - it->second = PhantomBlockWeight( double_c(infoIt->second.numberOfLocalBodies) + baseWeight_ ); - continue; - } - - if (block->sourceBlockHasTheSameSize()) - { - auto infoIt = ic_->find( block->getId() ); - WALBERLA_ASSERT_UNEQUAL( infoIt, ic_->end() ); - it->second = PhantomBlockWeight( double_c(infoIt->second.numberOfLocalBodies) + baseWeight_ ); - continue; - } - - if (block->sourceBlockIsSmaller()) - { - double weight = 0; - for (uint_t child = 0; child < 8; ++child) - { - blockforest::BlockID childId(block->getId(), child); - auto childIt = ic_->find( childId ); - WALBERLA_ASSERT_UNEQUAL( childIt, ic_->end() ); - weight += double_c(childIt->second.numberOfLocalBodies); - } - it->second = PhantomBlockWeight( weight + baseWeight_ ); - continue; - } + auto infoIt = ic_->find( block->getId()/*.getFatherId()*/ ); + WALBERLA_CHECK_UNEQUAL( infoIt, ic_->end() ); + it->second = PhantomBlockWeight( double_c(infoIt->second.numberOfLocalBodies) + baseWeight_ ); } }