Skip to content
Snippets Groups Projects
Commit 6c514a80 authored by Sebastian Eibl's avatar Sebastian Eibl
Browse files

added base weight and stringify functions to parmetis

parent aae402a0
Branches
No related merge requests found
...@@ -272,7 +272,7 @@ DynamicParMetis::Algorithm DynamicParMetis::stringToAlgorithm( std::string s ) ...@@ -272,7 +272,7 @@ DynamicParMetis::Algorithm DynamicParMetis::stringToAlgorithm( std::string s )
else if( s == "REFINE_KWAY" ) else if( s == "REFINE_KWAY" )
return PARMETIS_REFINE_KWAY; return PARMETIS_REFINE_KWAY;
else else
WALBERLA_ABORT( "Illegal ParMetis algorithm specified! Valid choices are: \"PART_GEOM_KWAY\", \"PART_KWAY\", \"PART_ADAPTIVE_REPART\", or \"REFINE_KWAY\"." ); WALBERLA_ABORT( "Illegal ParMetis algorithm specified (" << s << ")! Valid choices are: \"PART_GEOM_KWAY\", \"PART_KWAY\", \"PART_ADAPTIVE_REPART\", or \"REFINE_KWAY\"." );
} }
...@@ -290,7 +290,7 @@ DynamicParMetis::WeightsToUse DynamicParMetis::stringToWeightsToUse( std::string ...@@ -290,7 +290,7 @@ DynamicParMetis::WeightsToUse DynamicParMetis::stringToWeightsToUse( std::string
else if( s == "BOTH_WEIGHTS" ) else if( s == "BOTH_WEIGHTS" )
return PARMETIS_BOTH_WEIGHTS; return PARMETIS_BOTH_WEIGHTS;
else else
WALBERLA_ABORT( "Illegal ParMetis weights usage specified! Valid choices are: \"NO_WEIGHTS\", \"EDGE_WEIGHTS\", \"VERTEX_WEIGHTS\", or \"BOTH_WEIGHTS\"." ); WALBERLA_ABORT( "Illegal ParMetis weights usage specified (" << s << ")! Valid choices are: \"NO_WEIGHTS\", \"EDGE_WEIGHTS\", \"VERTEX_WEIGHTS\", or \"BOTH_WEIGHTS\"." );
} }
...@@ -304,7 +304,54 @@ DynamicParMetis::EdgeSource DynamicParMetis::stringToEdgeSource( std::string s ) ...@@ -304,7 +304,54 @@ DynamicParMetis::EdgeSource DynamicParMetis::stringToEdgeSource( std::string s )
else if( s == "EDGES_FROM_EDGE_WEIGHTS" ) else if( s == "EDGES_FROM_EDGE_WEIGHTS" )
return PARMETIS_EDGES_FROM_EDGE_WEIGHTS; return PARMETIS_EDGES_FROM_EDGE_WEIGHTS;
else else
WALBERLA_ABORT( "Illegal ParMetis weights usage specified! Valid choices are: \"EDGES_FROM_FOREST\" or \"EDGES_FROM_EDGE_WEIGHTS\"" ); WALBERLA_ABORT( "Illegal ParMetis weights usage specified (" << s << ")! Valid choices are: \"EDGES_FROM_FOREST\" or \"EDGES_FROM_EDGE_WEIGHTS\"" );
}
std::string DynamicParMetis::algorithmToString( ) const
{
switch (algorithm_)
{
case walberla::blockforest::DynamicParMetis::PARMETIS_PART_GEOM_KWAY:
return "PART_GEOM_KWAY";
case walberla::blockforest::DynamicParMetis::PARMETIS_PART_KWAY:
return "PART_KWAY";
case walberla::blockforest::DynamicParMetis::PARMETIS_ADAPTIVE_REPART:
return "PART_ADAPTIVE_REPART";
case walberla::blockforest::DynamicParMetis::PARMETIS_REFINE_KWAY:
return "PARMETIS_REFINE_KWAY";
}
return "Unknown";
}
std::string DynamicParMetis::weightsToUseToString( ) const
{
switch (weightsToUse_)
{
case walberla::blockforest::DynamicParMetis::PARMETIS_NO_WEIGHTS:
return "NO_WEIGHTS";
case walberla::blockforest::DynamicParMetis::PARMETIS_EDGE_WEIGHTS:
return "EDGE_WEIGHTS";
case walberla::blockforest::DynamicParMetis::PARMETIS_VERTEX_WEIGHTS:
return "VERTEX_WEIGHTS";
case walberla::blockforest::DynamicParMetis::PARMETIS_BOTH_WEIGHTS:
return "BOTH_WEIGHTS";
}
return "Unknown";
}
std::string DynamicParMetis::edgeSourceToString( ) const
{
switch (edgeSource_)
{
case walberla::blockforest::DynamicParMetis::PARMETIS_EDGES_FROM_FOREST:
return "EDGES_FROM_FOREST";
case walberla::blockforest::DynamicParMetis::PARMETIS_EDGES_FROM_EDGE_WEIGHTS:
return "EDGES_FROM_EDGE_WEIGHTS";
}
return "Unknown";
} }
......
...@@ -62,6 +62,10 @@ public: ...@@ -62,6 +62,10 @@ public:
static WeightsToUse stringToWeightsToUse( std::string s ); static WeightsToUse stringToWeightsToUse( std::string s );
static EdgeSource stringToEdgeSource( std::string s ); static EdgeSource stringToEdgeSource( std::string s );
std::string algorithmToString() const;
std::string weightsToUseToString() const;
std::string edgeSourceToString() const;
protected: protected:
Algorithm algorithm_; Algorithm algorithm_;
WeightsToUse weightsToUse_; WeightsToUse weightsToUse_;
......
...@@ -35,14 +35,13 @@ public: ...@@ -35,14 +35,13 @@ public:
typedef blockforest::DynamicParMetisBlockInfo PhantomBlockWeight; typedef blockforest::DynamicParMetisBlockInfo PhantomBlockWeight;
typedef blockforest::DynamicParMetisBlockInfoPackUnpack PhantomBlockWeightPackUnpackFunctor; typedef blockforest::DynamicParMetisBlockInfoPackUnpack PhantomBlockWeightPackUnpackFunctor;
MetisAssignmentFunctor( const shared_ptr<InfoCollection>& ic ) : ic_( ic ) MetisAssignmentFunctor( shared_ptr<InfoCollection>& ic, const real_t baseWeight = real_t(10.0) ) : ic_(ic), baseWeight_(baseWeight) {}
{}
void operator()( std::vector< std::pair< const PhantomBlock *, walberla::any > > & blockData, const PhantomBlockForest & ) void operator()( std::vector< std::pair< const PhantomBlock *, walberla::any > > & blockData, const PhantomBlockForest & )
{ {
for( auto it = blockData.begin(); it != blockData.end(); ++it ) for( auto it = blockData.begin(); it != blockData.end(); ++it )
{ {
const uint_t& weight = ic_->find( it->first->getId() )->second.numberOfLocalBodies; const uint_t& weight = ic_->find( it->first->getId() )->second.numberOfLocalBodies + uint_c(baseWeight_);
blockforest::DynamicParMetisBlockInfo info( int64_c(weight) ); blockforest::DynamicParMetisBlockInfo info( int64_c(weight) );
info.setVertexSize(int64_c( weight )); info.setVertexSize(int64_c( weight ));
for( uint_t nb = uint_t(0); nb < it->first->getNeighborhoodSize(); ++nb ) for( uint_t nb = uint_t(0); nb < it->first->getNeighborhoodSize(); ++nb )
...@@ -53,8 +52,14 @@ public: ...@@ -53,8 +52,14 @@ public:
} }
} }
inline void setBaseWeight( const double weight) { baseWeight_ = weight;}
inline double getBaseWeight() const { return baseWeight_; }
private: private:
shared_ptr< InfoCollection > ic_; 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_ = real_t(10.0);
}; };
} }
......
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