Commit 8d804824 authored by Sebastian Eibl's avatar Sebastian Eibl
Browse files

MetisAssignment functor now uses weighted edges

parent cbc79ce4
......@@ -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;
};
}
......
......@@ -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_ );
}
}
......
Markdown is supported
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