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> 49 using namespace LifeV;
52 main (
int argc,
char** argv )
56 MPI_Init (&argc, &argv);
57 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_MpiComm (MPI_COMM_WORLD) );
58 if ( Comm->MyPID() == 0 )
63 std::shared_ptr<Epetra_Comm> Comm(
new Epetra_SerialComm () );
67 typedef RegionMesh<LinearTetra> mesh_Type;
68 typedef VectorEpetra vector_Type;
69 typedef std::shared_ptr<vector_Type> vectorPtr_Type;
72 const std::string defaultDataName =
"data";
74 std::string data_file_name = command_line.follow (defaultDataName.c_str(), 2,
"-f",
"--file");
75 GetPot dataFile( data_file_name );
78 std::shared_ptr<mesh_Type > fullMeshPtr (
new mesh_Type ( Comm ) );
80 meshData.setup (dataFile,
"fluid/space_discretization");
81 readMesh (*fullMeshPtr, meshData);
85 std::shared_ptr<mesh_Type > localMeshPtr (
new mesh_Type ( Comm ) );
86 localMeshPtr = meshPart.meshPartition();
90 TimeAndExtrapolationHandler timeVelocity;
91 Real dt = dataFile
("fluid/time_discretization/timestep",0.0
);
92 Real t0 = dataFile
("fluid/time_discretization/initialtime",0.0
);
93 Real tFinal = dataFile
("fluid/time_discretization/endtime",0.0
);
94 UInt orderBDF = dataFile
("fluid/time_discretization/BDF_order",2
);
97 timeVelocity.setBDForder(orderBDF);
98 timeVelocity.setMaximumExtrapolationOrder(orderBDF);
99 timeVelocity.setTimeStep(dt);
103 ns.setup(localMeshPtr);
107 vector_Type velocityInitial ( ns.uFESpace()->map() );
108 std::vector<vector_Type> initialStateVelocity;
109 velocityInitial *= 0 ;
110 for ( UInt i = 0; i < orderBDF; ++i )
111 initialStateVelocity.push_back(velocityInitial);
113 timeVelocity.initialize(initialStateVelocity);
116 std::string outputName = dataFile (
"exporter/filename",
"result");
117 std::shared_ptr< Exporter<mesh_Type > > exporter;
118 std::string
const exporterType = dataFile (
"exporter/type",
"ensight");
121 if (exporterType.compare (
"hdf5") == 0)
123 exporter.reset (
new ExporterHDF5<mesh_Type > ( dataFile, outputName ) );
124 exporter->setPostDir (
"./" );
125 exporter->setMeshProcId ( localMeshPtr, Comm->MyPID() );
128 else if(exporterType.compare (
"vtk") == 0)
130 exporter.reset (
new ExporterVTK<mesh_Type > ( dataFile, outputName ) );
131 exporter->setPostDir (
"./" );
132 exporter->setMeshProcId ( localMeshPtr, Comm->MyPID() );
135 vectorPtr_Type velocity(
new vector_Type(ns.uFESpace()->map(), exporter->mapType() ) );
136 vectorPtr_Type pressure(
new vector_Type(ns.pFESpace()->map(), exporter->mapType() ) );
137 exporter->addVariable ( ExporterData<mesh_Type>::VectorField,
"velocity", ns.uFESpace(), velocity, UInt (0) );
138 exporter->addVariable ( ExporterData<mesh_Type>::ScalarField,
"pressure", ns.pFESpace(), pressure, UInt (0) );
139 exporter->postProcess ( t0 );
142 std::shared_ptr<BCHandler> bc (
new BCHandler (*BCh_fluid ()) );
145 ns.setBoundaryConditions( bc );
148 LifeChrono iterChrono;
151 vectorPtr_Type rhs_velocity(
new vector_Type(ns.uFESpace()->map(), Unique ) );
158 for ( ; time <= tFinal + dt / 2.; time += dt)
161 std::cout <<
"\nWe are at time " << time <<
" s\n\n";
166 rhs_velocity->zero();
167 timeVelocity.rhsContribution (*rhs_velocity);
173 ns.updateVelocity(velocity);
179 std::cout <<
"\nTimestep solved in " << iterChrono.diff() <<
" s\n";
181 exporter->postProcess ( time );
183 timeVelocity.shift(*velocity);
187 exporter->closeFile();
189 Real normTwo_Velo = velocity->norm2();
190 Real normTwo_Pres = pressure->norm2();
195 std::cout <<
"\nMPI Finalization" << std::endl;
200 if ( std::abs(normTwo_Velo - 36.87669 ) < 1.0e-4 && std::abs(normTwo_Pres - 118.83078 ) < 1.0e-4 )
202 return ( EXIT_SUCCESS );
206 return ( EXIT_FAILURE );
void setAlpha(const Real &alpha)
Set coefficient associated to the time discretization scheme.
double operator()(const char *VarName, const double &Default) const
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
void setRhsVelocity(const vectorPtr_Type &vel_rhs)
Set the rhs vector, velocity component.
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 iterate_nonlinear(const Real &time)
Solve the Navier-Stokes equations at a certain time.
void updatePressure(vectorPtr_Type &pressure)
Get the pressure vector.
void setTimeStep(const Real &dt)
Set time step.
int operator()(const char *VarName, int Default) const
void buildSystem()
Assemble constant terms.
int main(int argc, char **argv)
uint32_type UInt
generic unsigned integer (used mainly for addressing)