38 #ifndef MESHLOADINGUTILITY_H 39 #define MESHLOADINGUTILITY_H 1
41 #pragma GCC diagnostic ignored "-Wunused-variable" 42 #pragma GCC diagnostic ignored "-Wunused-parameter" 47 #include <boost/numeric/ublas/matrix.hpp> 48 #include <boost/numeric/ublas/io.hpp> 50 #pragma GCC diagnostic warning "-Wunused-variable" 51 #pragma GCC diagnostic warning "-Wunused-parameter" 54 #include <lifev/core/util/LifeChrono.hpp> 55 #include <lifev/core/util/Displayer.hpp> 56 #include <lifev/core/mesh/MeshPartitioner.hpp> 57 #include <lifev/core/filter/PartitionIO.hpp> 58 #include <lifev/core/mesh/MeshUtility.hpp> 59 #include <lifev/core/mesh/RegionMesh3DStructured.hpp> 60 #include <lifev/core/mesh/MeshData.hpp> 61 #include <lifev/core/mesh/RegionMesh.hpp> 79 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
81 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_SerialComm );
83 Displayer displayer ( Comm );
84 MeshUtility::MeshStatistics::meshSize meshSize = MeshUtility::MeshStatistics::computeSize ( *mesh );
85 displayer.leaderPrint (
"Mesh size (max): ", meshSize.maxH,
"\n" );
86 displayer.leaderPrint (
"Mesh size (min): ", meshSize.minH,
"\n" );
87 displayer.leaderPrint (
"Mesh size (av.): ", meshSize.meanH,
"\n" );
101 const std::string& resourcesPath =
"./",
102 const std::string& meshOrder =
"P1")
107 meshData.setMeshType (
".mesh" );
126 void loadMesh ( std::shared_ptr< RegionMeshType >& meshLocal,
127 std::shared_ptr< RegionMeshType >& meshFull,
128 const std::string& meshName,
129 const std::string& resourcesPath,
130 const std::string& meshOrder )
133 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
135 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_SerialComm );
137 Displayer displayer ( Comm );
139 LifeChrono meshReadChrono;
140 meshReadChrono.start();
141 std::shared_ptr<RegionMeshType > fullMesh (
new RegionMeshType );
142 readMesh (*fullMesh, getMeshData (meshName, resourcesPath, meshOrder ) );
143 MeshUtility::printMeshInfos ( fullMesh );
144 meshReadChrono.stop();
145 displayer.leaderPrint (
"Loading time: ", meshReadChrono.diff(),
" s.\n");
147 LifeChrono meshPartChrono;
148 meshPartChrono.start();
149 MeshPartitioner< RegionMeshType > meshPartitioner ( fullMesh, Comm );
150 meshLocal = meshPartitioner.meshPartition();
151 meshPartChrono.stop();
152 displayer.leaderPrint (
"Partitioning time: ", meshPartChrono.diff(),
" s.\n");
174 const std::string& meshName,
175 const std::string& resourcesPath )
178 std::shared_ptr<Epetra_MpiComm> Comm (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
180 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_SerialComm );
182 Displayer displayer ( Comm );
184 LifeChrono meshReadChrono;
185 meshReadChrono.start();
186 #ifdef LIFEV_HAS_HDF5 187 PartitionIO< RegionMeshType > partitionIO ( ( resourcesPath + meshName ).data(), Comm);
188 partitionIO.read (meshLocal);
190 ASSERT (
false,
"You must compile LifeV with HDF5 to load partitioned meshes");
192 meshReadChrono.stop();
193 displayer.leaderPrint (
"Loading time: ", meshReadChrono.diff(),
" s.\n");
209 void loadMesh ( std::shared_ptr< RegionMeshType >& meshLocal,
210 std::shared_ptr< RegionMeshType >& meshFull ,
211 const std::string& meshName,
212 const std::string& resourcesPath =
"./",
213 bool isPartitioned =
false,
214 const std::string& meshOrder =
"P1" )
218 loadPartitionedMesh ( meshLocal, meshName, resourcesPath );
222 loadMesh ( meshLocal, meshFull, meshName, resourcesPath, meshOrder );
239 void loadMesh ( std::shared_ptr< RegionMeshType >& meshLocal,
240 const std::string& meshName,
241 const std::string& resourcesPath =
"./",
242 bool isPartitioned =
false,
243 const std::string& meshOrder =
"P1" )
245 std::shared_ptr< RegionMeshType > tmpMeshFull;
246 loadMesh ( meshLocal, tmpMeshFull, meshName, resourcesPath, isPartitioned, meshOrder );
263 std::shared_ptr< RegionMeshType >& meshFull,
264 markerID_Type regionFlag,
265 const std::vector<UInt>& m,
266 bool verbose =
false,
267 const std::vector<Real>& l = std::vector<Real> (3, 1),
268 const std::vector<Real>& t = std::vector<Real> (3, 0) )
271 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
273 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_SerialComm );
275 Displayer displayer ( Comm );
277 LifeChrono meshBuildChrono;
278 meshBuildChrono.start();
279 std::shared_ptr< RegionMeshType > fullMesh (
new RegionMeshType ( Comm ) );
284 else if ( m.size() == 2)
290 regularMesh3D ( *fullMesh,
297 MeshUtility::printMeshInfos ( fullMesh );
298 meshBuildChrono.stop();
299 displayer.leaderPrint (
"Building time: ", meshBuildChrono.diff(),
" s.\n");
301 LifeChrono meshPartChrono;
302 meshPartChrono.start();
303 MeshPartitioner< RegionMeshType > meshPartitioner ( fullMesh, Comm );
304 mesh = meshPartitioner.meshPartition();
305 meshPartChrono.stop();
306 displayer.leaderPrint (
"Partitioning time: ", meshPartChrono.diff(),
" s.\n");
331 markerID_Type regionFlag,
332 const std::vector<UInt> m,
333 bool verbose =
false,
334 const std::vector<Real>& l = std::vector<Real> (3, 1),
335 const std::vector<Real>& t = std::vector<Real> (3, 0) )
337 std::shared_ptr< RegionMeshType > tmpMeshFull;
338 loadStructuredMesh ( mesh, tmpMeshFull, regionFlag, m, verbose, l, t );
void setMeshDir(const std::string &dir)
void printMeshInfos(std::shared_ptr< RegionMeshType > mesh)
Print informations about the mesh.
void loadPartitionedMesh(std::shared_ptr< RegionMeshType > &meshLocal, const std::string &meshName, const std::string &resourcesPath)
Read and partitioned a *.mesh file.
void setMeshFile(const std::string &file)
void loadMesh(std::shared_ptr< RegionMeshType > &meshLocal, const std::string &meshName, const std::string &resourcesPath="./", bool isPartitioned=false, const std::string &meshOrder="P1")
Read and partitioned a *.mesh file.
MeshData - class for handling spatial discretization.
MeshData getMeshData(const std::string &meshName, const std::string &resourcesPath="./", const std::string &meshOrder="P1")
setup and get the mesh data
void loadStructuredMesh(std::shared_ptr< RegionMeshType > &mesh, markerID_Type regionFlag, const std::vector< UInt > m, bool verbose=false, const std::vector< Real > &l=std::vector< Real >(3, 1), const std::vector< Real > &t=std::vector< Real >(3, 0))
Build a mesh from a partitioned mesh.
void setMOrder(const std::string &order)
void setVerbose(const bool &isVerbose)