39 #include <lifev/core/LifeV.hpp> 44 #include "Epetra_config.h" 48 #include <Epetra_MpiComm.h> 51 #include <lifev/core/filter/GetPot.hpp> 52 #include <lifev/core/mesh/MeshPartitioner.hpp> 53 #include <lifev/core/mesh/MeshPartitionTool.hpp> 54 #include <lifev/core/filter/PartitionIO.hpp> 55 #include <lifev/core/mesh/RegionMesh3DStructured.hpp> 57 using namespace LifeV;
62 typedef MeshPartitionTool < RegionMesh<LinearTetra> > meshCutter_Type;
64 int main (
int argc,
char** argv)
69 typedef RegionMesh<LinearTetra> mesh_Type;
70 typedef std::shared_ptr<mesh_Type> meshPtr_Type;
71 typedef std::vector<meshPtr_Type> meshParts_Type;
72 typedef std::shared_ptr<meshParts_Type> meshPartsPtr_Type;
74 MPI_Init (&argc, &argv);
75 std::shared_ptr<Epetra_Comm> comm (
new Epetra_MpiComm (MPI_COMM_WORLD) );
77 if (comm->NumProc() != 1)
79 std::cout <<
"This test needs to be run " 80 <<
"with a single process. Aborting." 85 GetPot cl (argc, argv);
86 const UInt numElements = cl.follow (9,
"--num-elem");
87 const Int numParts = cl.follow (3,
"--num-parts");
90 const std::string partitionerType = cl.follow (
"MeshPartitioner",
91 "--partitioner-type");
92 std::string partsFile;
93 partsFile.reserve (50);
95 partsFile += partitionerType;
98 std::cout <<
"Number of elements in mesh: " << numElements << std::endl;
99 std::cout <<
"Number of parts: " << numParts << std::endl;
100 std::cout <<
"Mesh partitioner type: " << partitionerType << std::endl;
101 std::cout <<
"Name of HDF5 container: " << partsFile << std::endl;
103 meshPtr_Type fullMeshPtr (
new mesh_Type ( comm ) );
104 meshPartsPtr_Type meshPartPtr;
105 regularMesh3D (*fullMeshPtr, 1, numElements, numElements, numElements,
106 false, 2.0, 2.0, 2.0, -1.0, -1.0, -1.0);
108 if (partitionerType ==
"MeshPartitioner")
111 MeshPartitioner<mesh_Type> meshCutter;
112 meshCutter.setup (numParts, comm);
113 meshCutter.attachUnpartitionedMesh (fullMeshPtr);
114 meshCutter.doPartitionGraph();
115 meshCutter.fillEntityPID();
116 meshCutter.doPartitionMesh();
117 meshCutter.releaseUnpartitionedMesh();
118 meshPartPtr = meshCutter.meshPartitions();
120 else if (partitionerType ==
"MeshPartitionTool_ParMETIS")
123 Teuchos::ParameterList meshParameters;
124 meshParameters.set (
"num-parts", numParts,
"");
125 meshParameters.set (
"offline-mode",
true,
"");
126 meshParameters.set (
"graph-lib",
"parmetis",
"");
127 meshCutter_Type meshCutter (fullMeshPtr, comm, meshParameters);
128 if (! meshCutter.success() )
130 std::cout <<
"Mesh partition failed.";
133 meshPartPtr = meshCutter.allMeshParts();
135 else if (partitionerType ==
"MeshPartitionTool_Zoltan")
138 Teuchos::ParameterList meshParameters;
139 meshParameters.set (
"num-parts", numParts,
"");
140 meshParameters.set (
"offline-mode",
true,
"");
141 meshParameters.set (
"graph-lib",
"zoltan",
"");
142 meshCutter_Type meshCutter (fullMeshPtr, comm, meshParameters);
143 if (! meshCutter.success() )
145 std::cout <<
"Mesh partition failed.";
148 meshPartPtr = meshCutter.allMeshParts();
156 std::shared_ptr<Epetra_MpiComm> mpiComm =
157 std::dynamic_pointer_cast<Epetra_MpiComm> (comm);
158 PartitionIO<mesh_Type> partitionIO (partsFile, mpiComm);
159 partitionIO.write (meshPartPtr);
165 std::cout <<
"This test needs MPI to run. Aborting." << std::endl;
166 return (EXIT_FAILURE);
169 std::cout <<
"This test needs HDF5 to run. Aborting." << std::endl;
170 return (EXIT_FAILURE);
int main(int argc, char **argv)