32 #pragma GCC diagnostic ignored "-Wunused-variable" 33 #pragma GCC diagnostic ignored "-Wunused-parameter" 35 #include <Epetra_ConfigDefs.h> 38 #include <Epetra_MpiComm.h> 40 #include <Epetra_SerialComm.h> 44 #pragma GCC diagnostic warning "-Wunused-variable" 45 #pragma GCC diagnostic warning "-Wunused-parameter" 48 #include <lifev/core/array/MatrixEpetra.hpp> 49 #include <lifev/core/array/MapEpetra.hpp> 50 #include <lifev/core/mesh/MeshData.hpp> 51 #include <lifev/core/mesh/MeshPartitioner.hpp> 52 #include <lifev/navier_stokes/solver/OseenData.hpp> 53 #include <lifev/navier_stokes/fem/TimeAdvanceBDFNavierStokes.hpp> 54 #include <lifev/core/fem/FESpace.hpp> 56 #include <lifev/core/filter/ExporterHDF5.hpp> 58 #include <lifev/core/filter/ExporterEnsight.hpp> 60 #include <lifev/navier_stokes/solver/OseenSolver.hpp> 67 using namespace LifeV;
79 const LifeV::Real& t,
bool _verbose )
84 for ( BCHandler::bcBaseIterator_Type it = bcHandler.begin();
85 it != bcHandler.end(); ++it )
89 Q = nssolver.flux (flag);
90 P = nssolver.pressure (flag);
94 std::ofstream outfile;
95 std::stringstream filenamess;
101 filename =
"flux_label" + filenamess.str() +
".m";
102 outfile.open (filename.c_str(), std::ios::app);
103 outfile << Q <<
" " << t <<
"\n";
106 filename =
"pressure_label" + filenamess.str() +
".m";
107 outfile.open (filename.c_str(), std::ios::app);
108 outfile << P <<
" " << t <<
"\n";
151 fluxFinal = ( 0.09403 / rampAmpl) * t;
158 const Real pi = 3.141592653589793;
159 const Real area = 0.1950;
161 const Real areaFactor = area / ( 0.195 * 0.195 * pi);
165 const Real unitFactor = 1. / 60.;
176 const Real a[M] = { -0.152001, -0.111619, 0.043304, 0.028871, 0.002098, -0.027237, -0.000557};
177 const Real b[M] = { 0.129013, -0.031435, -0.086106, 0.028263, 0.010177, 0.012160, -0.026303};
181 const Real xi (2 * pi * (t - rampAmpl + dt) / T);
187 flux += a0 * (a[k - 1] * cos (k * xi) + b[k - 1] * sin (k * xi) );
191 fluxFinal = (flux * areaFactor * unitFactor);
213 Real radius ( std::sqrt ( area / 3.14159265359 ) );
215 Real radiusSquared = radius * radius;
217 peak = ( 2 * flux ) / ( area );
224 return n1 * std::max ( 0.0, peak * ( (radiusSquared - ( (x - x0) * (x - x0) + (y - y0) * (y - y0) ) ) / radiusSquared) );
228 return n2 * std::max ( 0.0 , peak * ( (radiusSquared - ( (x - x0) * (x - x0) + (y - y0) * (y - y0) ) ) / radiusSquared) );
232 return n3 * std::max ( 0.0, peak * ( (radiusSquared - ( (x - x0) * (x - x0) + (y - y0) * (y - y0) ) ) / radiusSquared) );
266 ResistanceTest::ResistanceTest (
int argc,
269 parameters (
new Private )
272 std::string data_file_name = command_line.follow (
"data", 2,
"-f",
"--file");
273 GetPot dataFile ( data_file_name );
274 parameters->data_file_name = data_file_name;
276 parameters->Re = dataFile (
"fluid/problem/Re", 1. );
277 parameters->nu = dataFile (
"fluid/physics/viscosity", 1. ) /
278 dataFile (
"fluid/physics/density", 1. );
280 parameters->D = dataFile (
"fluid/problem/D", 1. );
281 parameters->centered = (
bool) dataFile (
"fluid/problem/centered", 0 );
282 parameters->initial_sol = (std::string) dataFile (
"fluid/problem/initial_sol",
"stokes");
283 std::cout << parameters->initial_sol << std::endl;
287 std::cout <<
"mpi initialization ... " << std::endl;
292 parameters->comm.reset (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
295 parameters->comm.reset (
new Epetra_SerialComm() );
301 ResistanceTest::run()
304 typedef RegionMesh<LinearTetra> mesh_Type;
306 typedef std::shared_ptr<feSpace_Type> feSpacePtr_Type;
307 typedef OseenSolver< mesh_Type >::vector_Type vector_Type;
308 typedef std::shared_ptr<vector_Type> vectorPtr_Type;
311 GetPot dataFile ( parameters->data_file_name );
315 bool verbose = (parameters->comm->MyPID() == 0);
320 std::shared_ptr<OseenData> oseenData (
new OseenData() );
321 oseenData->setup ( dataFile );
324 meshData.setup (dataFile,
"fluid/space_discretization");
326 std::shared_ptr<mesh_Type> fullMeshPtr (
new mesh_Type ( parameters->comm ) );
327 readMesh (*fullMeshPtr, meshData);
329 std::shared_ptr<mesh_Type> meshPtr;
332 meshPtr = meshPart.meshPartition();
337 std::string uOrder = dataFile (
"fluid/space_discretization/vel_order",
"P1");
340 std::cout <<
"Building the velocity FE space ... " << std::flush;
343 feSpacePtr_Type uFESpacePtr (
new feSpace_Type (meshPtr, uOrder, 3, parameters->comm) );
347 std::cout <<
"ok." << std::endl;
351 std::string pOrder = dataFile (
"fluid/space_discretization/press_order",
"P1");
355 std::cout <<
"Building the pressure FE space ... " << std::flush;
358 feSpacePtr_Type pFESpacePtr (
new feSpace_Type (meshPtr, pOrder, 1, parameters->comm) );
362 std::cout <<
"ok." << std::endl;
365 UInt totalVelDof = uFESpacePtr->map().map (Unique)->NumGlobalElements();
366 UInt totalPressDof = pFESpacePtr->map().map (Unique)->NumGlobalElements();
370 BCFunctionBase uIn ( Private::aneurismFluxInVectorial );
371 BCFunctionBase uZero ( Private::zeroBCF );
373 FlowConditions outFlowBC;
376 Real resistance = dataFile
( "fluid/physics/resistance", 0.0
);
377 Real hydrostatic = dataFile
( "fluid/physics/hydrostatic", 0.0
);
381 vectorPtr_Type resistanceImplicit;
382 resistanceImplicit.reset(
new vector_Type( uFESpacePtr->map(), Repeated ) );
383 resistanceImplicit->epetraVector().PutScalar(0.0);
385 BCVector resistanceBCdefinition;
386 resistanceBCdefinition.setRhsVector( *resistanceImplicit, uFESpacePtr->dof().numTotalDof(), 1 );
387 resistanceBCdefinition.setResistanceCoeff( 600000.0 );
394 bcH.addBC (
"Inlet", INLET, Essential, Full, uIn , 3 );
395 bcH.addBC (
"Wall", WALL, Essential, Full, uZero, 3 );
399 bcH.addBC (
"Outlet", OUTLET, Resistance, Full, resistanceBCdefinition, 3 );
404 std::cout <<
"Total Velocity DOF = " << totalVelDof << std::endl;
408 std::cout <<
"Total Pressure DOF = " << totalPressDof << std::endl;
413 std::cout <<
"Calling the fluid constructor ... ";
416 OseenSolver< mesh_Type > fluid (oseenData,
419 parameters->comm, numLM);
424 std::cout <<
"ok." << std::endl;
427 fluid.setUp (dataFile);
430 fluid.setupPostProc( );
432 std::cout <<
"Inlet area: " << fluid.area( INLET ) << std::endl;
435 MPI_Barrier (MPI_COMM_WORLD);
439 Real dt = oseenData->dataTime()->timeStep();
440 Real t0 = oseenData->dataTime()->initialTime();
441 Real tFinal = oseenData->dataTime()->endTime();
447 bdf.setup (oseenData->dataTimeAdvance()->orderBDF() );
449 vector_Type beta ( fullMap );
450 vector_Type rhs ( fullMap );
452 std::string
const exportFileName = dataFile (
"exporter/nameFile",
"resistance");
455 ExporterHDF5<mesh_Type > exporter ( dataFile, meshPtr, exportFileName, parameters->comm->MyPID() );
457 ExporterEnsight<mesh_Type > exporter ( dataFile, meshPtr, exportFileName, parameters->comm->MyPID() );
460 vectorPtr_Type velAndPressure (
new vector_Type (*fluid.solution(), exporter.mapType() ) );
462 exporter.addVariable ( ExporterData<mesh_Type>::VectorField,
"velocity", uFESpacePtr,
463 velAndPressure, UInt (0) );
465 exporter.addVariable ( ExporterData<mesh_Type>::ScalarField,
"pressure", pFESpacePtr,
466 velAndPressure, UInt (3 * uFESpacePtr->dof().numTotalDof() ) );
469 bdf.bdfVelocity().setInitialCondition ( *fluid.solution() );
476 for (
Real time = t0 + dt ; time <= tFinal + dt / 2.; time += dt, iter++)
479 std::cout <<
"Inlet area: " << fluid.area ( INLET ) << std::endl;
482 outFlowBC.renewParameters ( fluid, *velAndPressure );
494 oseenData->dataTime()->setTime (time);
498 double alpha = bdf.bdfVelocity().coefficientFirstDerivative ( 0 ) / oseenData->dataTime()->timeStep();
499 bdf.bdfVelocity().extrapolation (beta);
500 bdf.bdfVelocity().updateRHSContribution ( oseenData->dataTime()->timeStep() );
501 rhs = fluid.matrixMass() * bdf.bdfVelocity().rhsContributionFirstDerivative();
503 fluid.updateSystem ( alpha, beta, rhs );
504 fluid.iterate ( bcH );
506 bdf.bdfVelocity().shiftRight ( *fluid.solution() );
508 *velAndPressure = *fluid.solution();
514 exporter.postProcess ( time );
516 MPI_Barrier (MPI_COMM_WORLD);
521 std::cout <<
"Total iteration time " << chrono.diff() <<
" s." << std::endl;
std::string data_file_name
std::function< Real(Real const &, Real const &, Real const &, Real const &, ID const &) > fct_Type
double operator()(const char *VarName, const double &Default) const
bool centered
true if the cylinder is at the origin
double H
height and width of the domain (in m)
ExporterEnsight data exporter.
FESpace - Short description here please!
static Real zeroBCF(const Real &, const Real &, const Real &, const Real &, const ID &i)
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
int32_type Int
Generic integer data.
double D
diameter of the cylinder (in m)
Epetra_Import const & importer()
Getter for the Epetra_Import.
double nu
viscosity (in m^2/s)
std::shared_ptr< std::vector< Int > > M_isOnProc
MeshData - class for handling spatial discretization.
double Real
Generic real data.
static Real fluxFunctionAneurysm(const Real &t, const Real &, const Real &, const Real &, const ID &)
void postProcessFluxesPressures(OseenSolver< RegionMesh< LinearTetra > > &nssolver, BCHandler &bcHandler, const LifeV::Real &t, bool _verbose)
static Real aneurismFluxInVectorial(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
std::shared_ptr< Epetra_Comm > comm
uint32_type UInt
generic unsigned integer (used mainly for addressing)