32 #include <Epetra_ConfigDefs.h> 35 #include <Epetra_MpiComm.h> 37 #include <Epetra_SerialComm.h> 42 #include <lifev/core/array/MatrixEpetra.hpp> 43 #include <lifev/core/array/MapEpetra.hpp> 44 #include <lifev/core/mesh/MeshData.hpp> 45 #include <lifev/core/mesh/MeshPartitioner.hpp> 46 #include <lifev/navier_stokes/solver/OseenData.hpp> 47 #include <lifev/navier_stokes/fem/TimeAdvanceBDFNavierStokes.hpp> 48 #include <lifev/core/fem/FESpace.hpp> 50 #include <lifev/core/filter/ExporterHDF5.hpp> 52 #include <lifev/core/filter/ExporterEnsight.hpp> 54 #include <lifev/navier_stokes/solver/OseenSolver.hpp> 61 using namespace LifeV;
108 BCHandler& bcHandler,
109 const LifeV::Real& t,
bool _verbose )
114 for ( BCHandler::bcBaseIterator_Type it = bcHandler.begin();
115 it != bcHandler.end(); ++it )
119 Q = nssolver.flux (flag);
120 P = nssolver.pressure (flag);
124 std::ofstream outfile;
125 std::stringstream filenamess;
126 std::string filename;
131 filename =
"flux_label" + filenamess.str() +
".m";
132 outfile.open (filename.c_str(), std::ios::app);
133 outfile << Q <<
" " << t <<
"\n";
136 filename =
"pressure_label" + filenamess.str() +
".m";
137 outfile.open (filename.c_str(), std::ios::app);
138 outfile << P <<
" " << t <<
"\n";
215 return Um_3d() * (H + y) * (H - y) * (H + z) * (H - z) / std::pow (H, 4);
219 return 16 * Um_3d() * y * z * (H - y) * (H - z) / std::pow (H, 4);
231 f = std::bind (&Cylinder::Private::u3d,
this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5);
273 f = std::bind (&Cylinder::Private::u2d,
this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5);
288 double r = std::sqrt (x * x + y * y);
292 return Um_2d() * 2 * ( (
D / 2.) * (
D / 2.) - r * r);
301 f = std::bind (&Cylinder::Private::poiseuille,
this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5);
321 f = std::bind (&Cylinder::Private::oneU,
this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5);
334 std::string data_file_name = command_line.follow (
"data", 2,
"-f",
"--file");
335 GetPot dataFile ( data_file_name );
336 d->data_file_name = data_file_name;
338 d->Re = dataFile (
"fluid/problem/Re", 1. );
339 d->nu = dataFile (
"fluid/physics/viscosity", 1. ) /
340 dataFile (
"fluid/physics/density", 1. );
342 d->D = dataFile (
"fluid/problem/D", 1. );
343 d->centered = (
bool) dataFile (
"fluid/problem/centered", 0 );
344 d->initial_sol = (std::string) dataFile (
"fluid/problem/initial_sol",
"stokes");
345 std::cout << d->initial_sol << std::endl;
349 std::cout <<
"mpi initialization ... " << std::endl;
354 d->comm.reset (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
355 if (!d->comm->MyPID() )
357 std::cout <<
"My PID = " << d->comm->MyPID() <<
" out of " << ntasks <<
" running." << std::endl;
358 std::cout <<
"Re = " << d->Re << std::endl
359 <<
"nu = " << d->nu << std::endl
360 <<
"H = " << d->H << std::endl
361 <<
"D = " << d->D << std::endl;
365 d->comm.reset (
new Epetra_SerialComm() );
375 typedef std::shared_ptr<feSpace_Type> feSpacePtr_Type;
376 typedef OseenSolver< mesh_Type >::vector_Type vector_Type;
377 typedef std::shared_ptr<vector_Type> vectorPtr_Type;
380 GetPot dataFile ( d->data_file_name );
384 bool verbose = (d->comm->MyPID() == 0);
388 BCFunctionBase uZero ( zero_scalar );
389 std::vector<ID> zComp (1);
392 BCFunctionBase uIn ( d->getU_2d() );
393 BCFunctionBase uOne ( d->getU_one() );
394 BCFunctionBase uPois ( d->getU_pois() );
401 bcH.addBC (
"Inlet", INLET, Essential, Full, uPois , 3 );
402 bcH.addBC (
"Ringin", RINGIN, Essential, Full, uZero , 3 );
403 bcH.addBC (
"Ringout", RINGOUT, Essential, Full, uZero , 3 );
404 bcH.addBC (
"Outlet", OUTLET, Natural, Full, uZero, 3 );
405 bcH.addBC (
"Wall", WALL, Essential, Full, uZero, 3 );
409 std::shared_ptr<OseenData> oseenData (
new OseenData() );
410 oseenData->setup ( dataFile );
413 meshData.setup (dataFile,
"fluid/space_discretization");
415 std::shared_ptr<mesh_Type> fullMeshPtr (
new mesh_Type ( d->comm ) );
416 readMesh (*fullMeshPtr, meshData);
418 std::shared_ptr<mesh_Type> meshPtr;
421 meshPtr = meshPart.meshPartition();
425 std::cout << std::endl;
429 std::cout <<
"Time discretization order " << oseenData->dataTimeAdvance()->orderBDF() << std::endl;
434 std::string uOrder = dataFile (
"fluid/space_discretization/vel_order",
"P1");
437 std::cout <<
"Building the velocity FE space ... " << std::flush;
440 feSpacePtr_Type uFESpacePtr (
new feSpace_Type (meshPtr, uOrder, 3, d->comm) );
444 std::cout <<
"ok." << std::endl;
448 std::string pOrder = dataFile (
"fluid/space_discretization/press_order",
"P1");
452 std::cout <<
"Building the pressure FE space ... " << std::flush;
455 feSpacePtr_Type pFESpacePtr (
new feSpace_Type (meshPtr, pOrder, 1, d->comm) );
459 std::cout <<
"ok." << std::endl;
462 UInt totalVelDof = uFESpacePtr->map().map (Unique)->NumGlobalElements();
463 UInt totalPressDof = pFESpacePtr->map().map (Unique)->NumGlobalElements();
469 std::cout <<
"Total Velocity DOF = " << totalVelDof << std::endl;
473 std::cout <<
"Total Pressure DOF = " << totalPressDof << std::endl;
478 std::cout <<
"Calling the fluid constructor ... ";
481 bcH.setOffset (
"Inlet", totalVelDof + totalPressDof - 1 );
483 OseenSolver< mesh_Type > fluid (oseenData,
491 std::cout <<
"ok." << std::endl;
494 fluid.setUp (dataFile);
497 MPI_Barrier (MPI_COMM_WORLD);
501 Real dt = oseenData->dataTime()->timeStep();
502 Real t0 = oseenData->dataTime()->initialTime();
503 Real tFinal = oseenData->dataTime()->endTime();
509 bdf.setup (oseenData->dataTimeAdvance()->orderBDF() );
511 vector_Type beta ( fullMap );
512 vector_Type rhs ( fullMap );
515 ExporterHDF5<mesh_Type > ensight ( dataFile, meshPtr,
"cylinder", d->comm->MyPID() );
520 vectorPtr_Type velAndPressure (
new vector_Type (*fluid.solution(), ensight.mapType() ) );
522 ensight.addVariable ( ExporterData<mesh_Type>::VectorField,
"velocity", uFESpacePtr,
523 velAndPressure, UInt (0) );
525 ensight.addVariable ( ExporterData<mesh_Type>::ScalarField,
"pressure", pFESpacePtr,
526 velAndPressure, UInt (3 * uFESpacePtr->dof().numTotalDof() ) );
530 if (d->initial_sol ==
"stokes")
534 std::cout << std::endl;
538 std::cout <<
"Computing the stokes solution ... " << std::endl << std::endl;
541 oseenData->dataTime()->setTime (t0);
543 MPI_Barrier (MPI_COMM_WORLD);
548 fluid.updateSystem (0, beta, rhs );
549 fluid.iterate ( bcH );
553 *velAndPressure = *fluid.solution();
554 ensight.postProcess ( 0 );
555 fluid.resetPreconditioner();
558 bdf.bdfVelocity().setInitialCondition ( *fluid.solution() );
565 for (
Real time = t0 + dt ; time <= tFinal + dt / 2.; time += dt, iter++)
568 oseenData->dataTime()->setTime (time);
572 std::cout << std::endl;
573 std::cout <<
"We are now at time " << oseenData->dataTime()->time() <<
" s. " << std::endl;
574 std::cout << std::endl;
579 double alpha = bdf.bdfVelocity().coefficientFirstDerivative ( 0 ) / oseenData->dataTime()->timeStep();
581 bdf.bdfVelocity().extrapolation (beta);
582 bdf.bdfVelocity().updateRHSContribution ( oseenData->dataTime()->timeStep() );
583 rhs = fluid.matrixMass() * bdf.bdfVelocity().rhsContributionFirstDerivative();
585 fluid.updateSystem ( alpha, beta, rhs );
586 fluid.iterate ( bcH );
588 bdf.bdfVelocity().shiftRight ( *fluid.solution() );
592 *velAndPressure = *fluid.solution();
593 ensight.postProcess ( time );
598 MPI_Barrier (MPI_COMM_WORLD);
603 std::cout <<
"Total iteration time " << chrono.diff() <<
" s." << std::endl;
double H
height and width of the domain (in m)
Real zero_scalar(const Real &, const Real &, const Real &, const Real &, const ID &)
Null function used to define the boundary conditions.
std::function< Real(Real const &, Real const &, Real const &, Real const &, ID const &) > fct_Type
std::shared_ptr< Epetra_Comm > comm
ExporterEnsight data exporter.
FESpace - Short description here please!
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
double nu
viscosity (in m^2/s)
Real poiseuille(const Real &, const Real &x, const Real &y, const Real &, const ID &id) const
one flat (1,1,1)
2D/3D Cylinder Simulation class
Epetra_Import const & importer()
Getter for the Epetra_Import.
double D
diameter of the cylinder (in m)
std::shared_ptr< std::vector< Int > > M_isOnProc
MeshData - class for handling spatial discretization.
Real oneU(const Real &, const Real &, const Real &, const Real &, const ID &) const
double Real
Generic real data.
std::string data_file_name
void postProcessFluxesPressures(OseenSolver< RegionMesh< LinearTetra > > &nssolver, BCHandler &bcHandler, const LifeV::Real &t, bool _verbose)
RegionMesh< LinearTetra > mesh_Type
Cylinder(int argc, char **argv)
double Ubar() const
get the characteristic velocity
bool centered
true if the cylinder is at the origin
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Real u2d(const Real &t, const Real &, const Real &, const Real &, const ID &id) const
u2d flat 2D velocity profile.
Real u3d(const Real &, const Real &, const Real &y, const Real &z, const ID &id) const
u3d 3D velocity profile.
double Um_3d() const
get the magnitude of the profile velocity
Real u2(const Real &t, const Real &, const Real &, const Real &, const ID &i)