39 #include <lifev/core/LifeV.hpp> 44 #include "Epetra_config.h" 48 #include <Epetra_MpiComm.h> 51 #include <lifev/core/mesh/MeshPartitioner.hpp> 52 #include <lifev/core/filter/PartitionIO.hpp> 53 #include <lifev/core/filter/ExporterHDF5Mesh3D.hpp> 54 #include <lifev/core/mesh/RegionMesh3DStructured.hpp> 55 #include <lifev/core/mesh/MeshData.hpp> 57 using namespace LifeV;
62 int main (
int argc,
char** argv)
67 typedef RegionMesh<LinearTetra> mesh_Type;
68 typedef boost::shared_ptr<mesh_Type> meshPtr_Type;
70 MPI_Init (&argc, &argv);
71 boost::shared_ptr<Epetra_Comm> comm (
new Epetra_MpiComm (MPI_COMM_WORLD) );
73 if (comm->NumProc() != 1)
75 std::cout <<
"This test needs to be run " 76 <<
"with a single process. Aborting." 78 return (EXIT_FAILURE);
81 GetPot commandLine (argc, argv);
82 std::string dataFileName = commandLine.follow (
"data", 2,
"-f",
"--file");
83 GetPot dataFile (dataFileName);
85 const UInt numParts (dataFile (
"test/num_parts", 4) );
86 const std::string partsFileName (dataFile (
"test/hdf5_file_name",
"cube.h5") );
87 const std::string ioClass (dataFile (
"test/io_class",
"new") );
89 std::cout <<
"Number of parts: " << numParts << std::endl;
90 std::cout <<
"Name of HDF5 container: " << partsFileName << std::endl;
92 boost::shared_ptr<mesh_Type> fullMeshPtr (
new mesh_Type );
98 meshData.setup(dataFile,
"mesh");
99 readMesh(*fullMeshPtr, meshData);
101 MeshPartitioner<mesh_Type> meshPart;
102 meshPart.setup (numParts, comm);
104 meshPart.attachUnpartitionedMesh (fullMeshPtr);
105 meshPart.doPartitionGraph();
106 meshPart.doPartitionMesh();
110 meshPart.releaseUnpartitionedMesh();
114 if (! ioClass.compare (
"old") )
116 ExporterHDF5Mesh3D<mesh_Type> HDF5Output (dataFile,
117 meshPart.meshPartition(),
120 HDF5Output.addPartitionGraph (meshPart.elementDomains(), comm);
121 HDF5Output.addMeshPartitionAll (meshPart.meshPartitions(), comm);
122 HDF5Output.postProcess (0);
123 HDF5Output.closeFile();
127 boost::shared_ptr<Epetra_MpiComm> mpiComm =
128 boost::dynamic_pointer_cast<Epetra_MpiComm> (comm);
129 PartitionIO<mesh_Type> partitionIO (partsFileName, mpiComm);
130 partitionIO.write (meshPart.meshPartitions() );
136 std::cout <<
"This test needs MPI to run. Aborting." << std::endl;
137 return (EXIT_FAILURE);
140 std::cout <<
"This test needs HDF5 to run. Aborting." << std::endl;
141 return (EXIT_FAILURE);
144 return (EXIT_SUCCESS);
int main(int argc, char **argv)