28 #include <Epetra_ConfigDefs.h> 31 #include <Epetra_MpiComm.h> 33 #include <Epetra_SerialComm.h> 37 #include <lifev/core/LifeV.hpp> 38 #include <lifev/core/mesh/MeshData.hpp> 39 #include <lifev/core/mesh/MeshPartitioner.hpp> 40 #include <lifev/navier_stokes_blocks/solver/NavierStokesSolverBlocks.hpp> 41 #include <lifev/core/fem/TimeAndExtrapolationHandler.hpp> 42 #include <lifev/core/filter/ExporterEnsight.hpp> 43 #include <lifev/core/filter/ExporterHDF5.hpp> 44 #include <lifev/core/filter/ExporterVTK.hpp> 45 #include <Teuchos_XMLParameterListHelpers.hpp> 46 #include <lifev/core/filter/PartitionIO.hpp> 50 using namespace LifeV;
53 main (
int argc,
char** argv )
57 MPI_Init (&argc, &argv);
58 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_MpiComm (MPI_COMM_WORLD) );
59 if ( Comm->MyPID() == 0 )
64 std::shared_ptr<Epetra_Comm> Comm(
new Epetra_SerialComm () );
73 typedef RegionMesh<LinearTetra> mesh_Type;
74 typedef VectorEpetra vector_Type;
75 typedef std::shared_ptr<vector_Type> vectorPtr_Type;
78 const std::string defaultDataName =
"data";
80 std::string data_file_name = command_line.follow (defaultDataName.c_str(), 2,
"-f",
"--file");
81 GetPot dataFile( data_file_name );
84 std::shared_ptr<mesh_Type > localMeshPtr (
new mesh_Type ( Comm ) );
86 if ( dataFile
( "offline_partitioner/useOfflinePartitionedMesh", false) )
88 std::shared_ptr<Epetra_MpiComm> comm = std::dynamic_pointer_cast<Epetra_MpiComm>(Comm);
89 const std::string partsFileName (dataFile (
"offline_partitioner/hdf5_file_name",
"name.h5") );
90 PartitionIO<mesh_Type > partitionIO (partsFileName, comm);
91 partitionIO.read (localMeshPtr);
96 std::shared_ptr<mesh_Type > fullMeshPtr (
new mesh_Type ( Comm ) );
98 meshData.setup (dataFile,
"fluid/space_discretization");
99 readMesh (*fullMeshPtr, meshData);
103 localMeshPtr = meshPart.meshPartition();
109 ns.setup(localMeshPtr);
114 std::string outputName = dataFile (
"exporter/filename",
"result");
115 std::shared_ptr< Exporter<mesh_Type > > exporter;
116 std::string
const exporterType = dataFile (
"exporter/type",
"ensight");
119 if (exporterType.compare (
"hdf5") == 0)
121 exporter.reset (
new ExporterHDF5<mesh_Type > ( dataFile, outputName ) );
122 exporter->setPostDir (
"./" );
123 exporter->setMeshProcId ( localMeshPtr, Comm->MyPID() );
126 else if(exporterType.compare (
"vtk") == 0)
128 exporter.reset (
new ExporterVTK<mesh_Type > ( dataFile, outputName ) );
129 exporter->setPostDir (
"./" );
130 exporter->setMeshProcId ( localMeshPtr, Comm->MyPID() );
134 vectorPtr_Type velocity(
new vector_Type(ns.uFESpace()->map(), exporter->mapType() ) );
135 vectorPtr_Type pressure(
new vector_Type(ns.pFESpace()->map(), exporter->mapType() ) );
136 exporter->addVariable ( ExporterData<mesh_Type>::VectorField,
"velocity", ns.uFESpace(), velocity, UInt (0) );
137 exporter->addVariable ( ExporterData<mesh_Type>::ScalarField,
"pressure", ns.pFESpace(), pressure, UInt (0) );
138 exporter->postProcess ( 0.0 );
141 std::shared_ptr<BCHandler> bc (
new BCHandler (*BCh_fluid ()) );
144 ns.setBoundaryConditions( bc );
150 ns.updateVelocity(velocity);
156 exporter->postProcess ( 1.0 );
159 exporter->closeFile();
161 normTwo_Velo = velocity->norm2();
162 normTwo_Pres = pressure->norm2();
169 std::cout <<
"\nMPI Finalization" << std::endl;
174 if ( std::abs(normTwo_Velo - 108.783606 ) < 1.0e-4 && std::abs(normTwo_Pres - 129.597065 ) < 1.0e-4 )
176 return ( EXIT_SUCCESS );
180 return ( EXIT_FAILURE );
void iterate_steady()
Solve the steady Navier-Stokes equations.
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
std::shared_ptr< std::vector< Int > > M_isOnProc
MeshData - class for handling spatial discretization.
void setParameters()
Set parameters of the solver.
double Real
Generic real data.
void updatePressure(vectorPtr_Type &pressure)
Get the pressure vector.
void buildSystem()
Assemble constant terms.
bool operator()(const char *VarName, bool Default) const
int main(int argc, char **argv)