13 #include <Epetra_ConfigDefs.h> 15 #include <Epetra_MpiComm.h> 17 #include <Epetra_SerialComm.h> 20 #include <boost/program_options.hpp> 22 #include <life/lifecore/LifeV.hpp> 23 #include <life/lifecore/application.hpp> 27 #include <life/lifearray/EpetraMatrix.hpp> 28 #include <life/lifearray/MapEpetra.hpp> 29 #include <life/lifemesh/MeshPartitioner.hpp> 30 #include <life/lifesolver/OseenData.hpp> 31 #include <life/lifefem/FESpace.hpp> 32 #include <life/lifefem/TimeAdvanceBDFNavierStokes.hpp> 33 #include <life/lifefilters/ExporterEnsight.hpp> 35 #include <life/lifesolver/OseenSolver.hpp> 44 using namespace LifeV;
48 typedef OseenSolver< RegionMesh<LinearTetra> >::vector_type vector_type;
81 LifeV::AboutData about (
"life_cavity" ,
84 "3D cavity test case",
85 LifeV::AboutData::License_GPL,
86 "Copyright (c) 2008 EPFL");
88 about.addAuthor (
"Gilles Fourestey",
"developer",
"gilles.fourestey@epfl.ch",
"");
96 main (
int argc,
char** argv )
107 MPI_Init (&argc, &argv);
108 Epetra_MpiComm comm (MPI_COMM_WORLD);
110 bool verbose = comm.MyPID() == 0;
114 cout <<
"% using MPI" << endl;
116 int err = MPI_Comm_size (MPI_COMM_WORLD, &ntasks);
117 std::cout <<
"My PID = " << comm.MyPID() <<
" out of " << ntasks <<
" running." << std::endl;
125 GetPot command_line (argc, argv);
126 const std::string data_file_name = command_line.follow (
"data-cavity", 2,
"-f",
"--file");
127 GetPot dataFile ( data_file_name );
130 OseenData<RegionMesh<LinearTetra> > oseenData (dataFile,
false,
"fluid/discretization",
"fluid/discretization");
131 oseenData.setup ( dataFile );
142 std::vector<ID> zComp (1);
145 BCFunctionBase uIn ( boost::bind (&uLid, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5) );
146 BCFunctionBase uZero ( zero_scalar );
150 bcH.addBC (
"Upwall", UPWALL, Essential, Full, uIn, 3 );
151 bcH.addBC (
"Wall", WALL, Essential, Full, uZero, 3 );
154 bcH.addBC (
"Slipwall", SLIPWALL, Essential, Component, uZero, zComp );
157 partitionMesh< RegionMesh<LinearTetra> > meshPart (*oseenData.mesh(), comm);
162 const RefFE* refFE_vel;
163 const QuadRule* qR_vel;
164 const QuadRule* bdQr_vel;
166 refFE_vel = &feTetraP2;
167 qR_vel = &quadRuleTetra15pt;
170 bdQr_vel = &quadRuleTria3pt;
172 const RefFE* refFE_press;
173 const QuadRule* qR_press;
174 const QuadRule* bdQr_press;
176 refFE_press = &feTetraP1;
177 qR_press = &quadRuleTetra4pt;
178 bdQr_press = &quadRuleTria3pt;
186 std::cout <<
"Building the velocity FE space ... " << std::flush;
189 FESpace< RegionMesh<LinearTetra>, MapEpetra > uFESpace (meshPart,
198 std::cout <<
"ok " << std::flush;
205 std::cout <<
"Building the pressure FE space ... " << std::flush;
208 FESpace< RegionMesh<LinearTetra>, MapEpetra > pFESpace (meshPart,
218 std::cout <<
"ok." << std::endl;
221 UInt totalVelDof = uFESpace.map().getMap (Unique)->NumGlobalElements();
222 UInt totalPressDof = pFESpace.map().getMap (Unique)->NumGlobalElements();
227 std::cout <<
"Total Velocity Dof ... " << totalVelDof << std::endl;
231 std::cout <<
"Total Pressure Dof ... " << totalPressDof << std::endl;
240 std::cout <<
"Calling the fluid constructor ... ";
243 OseenSolver< RegionMesh<LinearTetra> > fluid (oseenData,
252 MapEpetra fullMap (fluid.getMap() );
256 std::cout <<
"ok." << std::endl;
260 fluid.setUp (dataFile);
268 Ensight<RegionMesh<LinearTetra> > ensight ( dataFile, meshPart.mesh(),
"cavity", comm.MyPID() );
271 vector_ptrtype velAndPressure (
new vector_type (fluid.solution(), Repeated ) );
275 ensight.addVariable ( ExporterData::Vector,
"velocity", velAndPressure,
276 UInt (0), uFESpace.dof().numTotalDof() );
279 ensight.addVariable ( ExporterData::Scalar,
"pressure", velAndPressure,
280 UInt (3 * uFESpace.dof().numTotalDof() ),
281 UInt ( pFESpace.dof().numTotalDof() ) );
285 MPI_Barrier (MPI_COMM_WORLD);
290 Real dt = oseenData.timeStep();
291 Real t0 = oseenData.initialTime();
292 Real tFinal = oseenData.endTime();
296 TimeAdvanceBDFNavierStokes<vector_type> bdf (oseenData.orderBDF() );
300 std::cout << std::endl;
304 std::cout <<
"Computing the stokes solution ... " << std::endl << std::endl;
307 oseenData.setTime (t0);
311 vector_type beta ( fullMap );
312 vector_type rhs ( fullMap );
314 MPI_Barrier (MPI_COMM_WORLD);
321 fluid.updateSystem (0, beta, rhs );
324 fluid.iterate ( bcH );
327 *velAndPressure = fluid.solution();
328 ensight.postProcess ( 0 );
LifeV::AboutData makeAbout()
Real zero_scalar(const Real &, const Real &, const Real &, const Real &, const ID &)
Real uLid(const Real &t, const Real &, const Real &, const Real &, const ID &i)
std::function< Real(Real const &, Real const &, Real const &, Real const &, ID const &) > fct_type
std::shared_ptr< vector_type > vector_ptrtype
int main(int argc, char **argv)