LifeV
lifev/core/examples/utility_mesh_reader/main.cpp
Go to the documentation of this file.
1 /*
2  * test_genAlpha.cpp
3  *
4  * Created on: Jul 27, 2010
5  * Author: uvilla
6  */
7 
8 #include <Epetra_ConfigDefs.h>
9 #include <Epetra_Comm.h>
10 
11 #include <lifev/core/LifeV.hpp>
12 #include <lifev/core/filter/GetPot.hpp>
13 #include <lifev/core/mesh/RegionMesh.hpp>
14 #include <lifev/core/mesh/MeshLoadingUtility.hpp>
15 
16 using namespace LifeV;
17 
18 // Do not edit
19 int main (int argc, char** argv)
20 {
21  using namespace LifeV;
22 #ifdef HAVE_MPI
23  MPI_Init (&argc, &argv);
24  std::cout << "MPI Initialization\n";
25 #endif
26 
27 #ifdef EPETRA_MPI
28  std::shared_ptr<Epetra_Comm> comm (new Epetra_MpiComm (MPI_COMM_WORLD) );
29 #else
30  std::shared_ptr<Epetra_Comm> comm (new Epetra_SerialComm() );
31 #endif
32 
33  std::string dataFileName;
34  GetPot command_line (argc, argv);
35  dataFileName = command_line.follow ("data", 2, "-f", "--file");
36  GetPot dataFile (dataFileName);
37 
38  if ( comm -> MyPID() == 0 )
39  {
40  std::cout << "\n\nReading and partitioning the cube mesh without saving the global mesh: ... \n";
41  }
42 
43  std::string meshName = dataFile ("mesh/mesh_file", "cube4x4.mesh");
44  std::string meshPath = dataFile ("mesh/mesh_dir", "./");
45  std::string meshOrder = dataFile ("mesh/mesh_order", "P1");
46  bool isPartitioned = false;
47 
48  {
49  //Create the mesh data and read and partitioned the mesh
50  std::shared_ptr< RegionMesh <LinearTetra> > meshPtr ( new RegionMesh <LinearTetra> ( comm ) );
51  MeshUtility::loadMesh ( meshPtr, meshName, meshPath, isPartitioned, meshOrder );
52  if ( comm -> MyPID() == 0 )
53  {
54  std::cout << "... DONE! ";
55  }
56  }
57 
58  {
59  //create the mesh data and read and save both the global mesh and the partitioned mesh
60  if ( comm -> MyPID() == 0 )
61  {
62  std::cout << "\n\nReading and partitioning the cube mesh saving the global mesh: ... \n";
63  }
64  std::shared_ptr< RegionMesh <LinearTetra> > meshFullPtr ( new RegionMesh <LinearTetra> ( comm ) );
65  std::shared_ptr< RegionMesh <LinearTetra> > meshLocalPtr ( new RegionMesh <LinearTetra> ( comm ) );
66  MeshUtility::loadMesh ( meshLocalPtr, meshFullPtr, meshName, meshPath, isPartitioned, "P1" );
67  if ( comm -> MyPID() == 0 )
68  {
69  std::cout << "... DONE! ";
70  }
71  }
72 
73  {
74  //create a 3D structured mesh
75  if ( comm -> MyPID() == 0 )
76  {
77  std::cout << "\n\nCreating a structured mesh without saving the full mesh: ... \n";
78  }
79  std::shared_ptr< RegionMesh <LinearTetra> > meshStructPtr ( new RegionMesh <LinearTetra> ( comm ) );
80  std::vector<Real> l (3, 1.0);
81  std::vector<Real> t (3, 0.0);
82  MeshUtility::loadStructuredMesh ( meshStructPtr,
83  1,
84  std::vector<UInt> (3, 5),
85  true,
86  l,
87  t );
88 
89 
90  if ( comm -> MyPID() == 0 )
91  {
92  std::cout << "... DONE!\n\n ";
93  }
94  }
95 
96  comm.reset();
97 
98 #ifdef HAVE_MPI
99  MPI_Finalize();
100  std::cout << "MPI Finalization \n";
101 #endif
102 
103  return 0;
104 }
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
Definition: GetPot.hpp:507
const std::string operator()(const char *VarName, const char *Default) const
Definition: GetPot.hpp:2045
GetPot(const STRING_VECTOR &FileNameList)
Definition: GetPot.hpp:645
const std::string follow(const char *Default, unsigned No, const char *Option,...)
Definition: GetPot.hpp:1510
int main(int argc, char **argv)