36 #ifndef GRAPH_PARTITION_TOOL_PARMETIS_H 37 #define GRAPH_PARTITION_TOOL_PARMETIS_H 1
40 #include <boost/shared_ptr.hpp> 41 #include <boost/lexical_cast.hpp> 42 #include <boost/bimap.hpp> 43 #include <Epetra_Comm.h> 44 #include <Teuchos_ParameterList.hpp> 46 #include <lifev/core/LifeV.hpp> 47 #include <lifev/core/mesh/GraphCutterBase.hpp> 48 #include <lifev/core/mesh/GraphUtil.hpp> 69 template<
typename MeshType>
115 return M_vertexPartition->at (i);
119 return M_vertexPartition->at (i);
125 return M_vertexPartition->size();
131 idTablePtr_Type graph (
new idTable_Type (M_vertexPartition->size() ) );
133 for (UInt i = 0; i < M_vertexPartition->size(); ++i)
135 graph->at (i) = getPart (i);
187 template<
typename MeshType>
202 template<
typename MeshType>
207 M_parameters.set (
"num-parts",
static_cast<Int> (M_comm->NumProc() ),
208 "The desired number of parts");
209 M_parameters.set<
bool> (
"hierarchical",
false);
210 M_parameters.set (
"topology",
"1",
211 "The topology of the mesh partition process.");
213 M_parameters.setParameters (parameters);
215 M_hierarchical = M_parameters.get<
bool> (
"hierarchical");
217 M_parameters.get<std::string> (
"topology") );
218 M_numParts = M_parameters.get<Int> (
"num-parts");
221 template<
typename MeshType>
250 template<
typename MeshType>
254 Int numVertices = M_mesh->numElements();
257 for (
Int i = 0; i < numVertices; ++i)
259 vertexList->at (i) = i;
264 Teuchos::ParameterList pList;
265 pList.set<Int> (
"num-parts", M_numParts);
266 partitionGraphParMETIS (vertexList, * (M_mesh), pList,
267 M_vertexPartition, M_comm);
272 template<
typename MeshType>
279 std::cout <<
"Hierarchical partitioning can only be performed with " 280 <<
"one MPI process." << std::endl;
288 std::cout <<
"Hierarchical partitioning can only be performed if " 289 <<
"the number of mesh parts is a multiple of the" 290 <<
" topology parameter." << std::endl;
297 Int numVertices = M_mesh->numElements();
301 for (
Int i = 0; i < numVertices; ++i)
303 vertexList->at (i) = i;
312 Teuchos::ParameterList pList;
313 pList.set<Int> (
"num-parts", numSubdomains);
314 partitionGraphParMETIS (vertexList, * (M_mesh), pList,
315 tempVertexPartition, M_comm);
321 pList.set<Int> (
"num-parts", M_topology);
322 M_vertexPartition->resize (M_numParts);
324 for (
Int i = 0; i < numSubdomains; ++i)
326 const idList_Type& currentVertices = * (tempVertexPartition->at (i) );
327 idListPtr_Type subdomainVertexMap (
new idList_Type (currentVertices.size() ) );
328 for (size_t k = 0; k < currentVertices.size(); ++k)
330 subdomainVertexMap->at (k) = currentVertices[k];
335 partitionGraphParMETIS (subdomainVertexMap, * (M_mesh),
336 pList, subdomainParts, M_comm);
340 M_vertexPartition->at (currentPart++) = subdomainParts->at (j);
Int partitionHierarchical()
Perform a hierarchical (2-level) partition.
GraphCutterParMETIS(const GraphCutterParMETIS &)
Graph cutter base class (abstract)
int32_type Int
Generic integer data.
virtual void setParameters(pList_Type ¶meters)
Set values for all the parameters, with default values where needed.
void updateInverseJacobian(const UInt &iQuadPt)
virtual const idTablePtr_Type getGraph() const
Get the entire partitioned graph, wrapped in a smart pointer.
virtual const UInt numParts() const
Return the number of parts.
GraphCutterParMETIS & operator=(const GraphCutterParMETIS &)
std::vector< LifeV::Int > idList_Type
GraphCutterParMETIS(meshPtr_Type &mesh, commPtr_Type &comm, pList_Type ¶meters)
virtual ~GraphCutterParMETIS()
Destructor.
Class that partitions the graph associated with a mesh (ParMETIS version)
boost::bimap< UInt, UInt > biMap_Type
biMap_Type::value_type biMapValue_Type
virtual Int run()
Performs the graph partitioning.
std::shared_ptr< idTable_Type > idTablePtr_Type
virtual idListPtr_Type & getPart(const UInt i)
Int partitionFlat()
Perform a flat, non-hierarchical partition.
std::shared_ptr< mesh_Type > meshPtr_Type
uint32_type UInt
generic unsigned integer (used mainly for addressing)
std::shared_ptr< Epetra_Comm > commPtr_Type
std::shared_ptr< idList_Type > idListPtr_Type
Teuchos::ParameterList pList_Type
idTablePtr_Type M_vertexPartition
virtual const idListPtr_Type & getPart(const UInt i) const
Get a pointer to one of the partitions.