42 using namespace LifeV;
131 f = std::bind ( &dataProblem::UOne, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 );
138 f = std::bind ( &dataProblem::UZero, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 );
145 f = std::bind ( &dataProblem::pressureSource, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 );
152 m = std::bind ( &dataProblem::pressurePermeability, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 );
159 f = std::bind ( &dataProblem::saturationInitialCondition, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 );
166 v = std::bind ( &dataProblem::saturationPhysicalFlux, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 );
173 v = std::bind ( &dataProblem::saturationFirstDerivativePhysicalFlux, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 );
180 f = std::bind ( &dataProblem::saturationSource, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 );
187 mnl = std::bind ( &dataProblem::saturationPermeability, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 );
194 f = std::bind ( &dataProblem::saturationMass, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 );
208 GetPot command_line (argc, argv);
209 const std::string data_file_name = command_line.follow (
"data", 2,
"-f",
"--file");
210 GetPot dataFile ( data_file_name );
212 Members->data_file_name = data_file_name;
213 Members->discretization_section =
"impes";
214 Members->discretization_section_darcy = Members->discretization_section +
"/darcy";
215 Members->discretization_section_hyperbolic = Members->discretization_section +
"/hyperbolic";
216 Members->discretization_section_darcy_nonlin_trans = Members->discretization_section +
"/darcy_transient_non_linear";
219 std::cout <<
"Epetra Initialization" << std::endl;
220 Members->comm.reset (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
222 MPI_Comm_size (MPI_COMM_WORLD, &ntasks);
224 Members->comm.reset (
new Epetra_SerialComm() );
236 typedef RegionMesh<LinearTetra> RegionMesh;
237 typedef SolverAztecOO solver_type;
238 typedef DarcySolver< RegionMesh, solver_type > ds;
239 typedef DarcySolverTransientNonLinear< RegionMesh, solver_type > dstnl;
241 typedef ds::vector_Type vector_type;
242 typedef std::shared_ptr<vector_type> vector_ptrtype;
243 typedef FESpace< RegionMesh, MapEpetra > feSpace_Type;
244 typedef std::shared_ptr<feSpace_Type> feSpacePtr_Type;
246 LifeChrono chronoTotal;
247 LifeChrono chronoReadAndPartitionMesh;
248 LifeChrono chronoBoundaryCondition;
249 LifeChrono chronoFiniteElementSpace;
250 LifeChrono chronoProblem;
251 LifeChrono chronoProcess;
252 LifeChrono chronoError;
258 GetPot dataFile ( Members->data_file_name.c_str() );
261 bool isLeader = ( Members->comm->MyPID() == 0 );
269 std::cout <<
"The IMPES solver" << std::endl << std::flush;
273 chronoReadAndPartitionMesh.start();
282 DarcyData<RegionMesh> dataSaturationDarcyNonLinear;
285 dataPressure.setup ( dataFile, Members->discretization_section_darcy );
288 dataSaturationHyperbolic.setup ( dataFile, Members->discretization_section_hyperbolic );
291 dataSaturationDarcyNonLinear.setup ( dataFile, Members->discretization_section_darcy_nonlin_trans );
297 meshData.setup ( dataFile, Members->discretization_section +
"/space_discretization");
300 std::shared_ptr<RegionMesh> fullMeshPtr (
new RegionMesh ( * ( Members->comm ) ) );
303 readMesh ( *fullMeshPtr, meshData );
306 std::shared_ptr<RegionMesh> meshPtr;
309 meshPtr = meshPart.meshPartition();
313 chronoReadAndPartitionMesh.stop();
317 std::cout <<
"Time for read and partition the mesh " <<
318 chronoReadAndPartitionMesh.diff() << std::endl << std::flush;
323 chronoBoundaryCondition.start();
325 BCFunctionBase pressureDirichletBDfun1,
326 pressureDirichletBDfun2,
327 pressureDirichletBDfun3,
328 pressureNeumannBDfun;
330 BCFunctionBase saturationDirichletBDfun1,
331 saturationDirichletBDfun2,
332 saturationDirichletBDfun3,
333 saturationNeumannBDfun;
338 pressureDirichletBDfun1.setFunction ( dataProblem::pressureDirichlet1 );
339 pressureDirichletBDfun2.setFunction ( dataProblem::pressureDirichlet2 );
340 pressureDirichletBDfun3.setFunction ( dataProblem::pressureDirichlet3 );
342 pressureNeumannBDfun.setFunction ( dataProblem::pressureNeumann );
349 saturationDirichletBDfun1.setFunction ( dataProblem::saturationDirichlet1 );
350 saturationDirichletBDfun2.setFunction ( dataProblem::saturationDirichlet2 );
351 saturationDirichletBDfun3.setFunction ( dataProblem::saturationDirichlet3 );
353 saturationNeumannBDfun.setFunction ( dataProblem::saturationNeumann );
359 BCHandler bcPressure;
362 BCHandler bcSaturation;
364 bcPressure.addBC (
"Top", FLUX0, Natural, Full, pressureNeumannBDfun, 0 );
365 bcPressure.addBC (
"Top2", FLUX1, Natural, Full, pressureNeumannBDfun, 0 );
366 bcPressure.addBC (
"InletPressure", INLETPRESSURE1, Essential, Scalar, pressureDirichletBDfun1 );
367 bcPressure.addBC (
"InletPressure1", INLETPRESSURE2, Essential, Scalar, pressureDirichletBDfun3 );
368 bcPressure.addBC (
"OutletPressure", OUTLETPRESSURE, Essential, Scalar, pressureDirichletBDfun2 );
370 bcSaturation.addBC (
"Top", FLUX0, Natural, Full, saturationNeumannBDfun, 0 );
371 bcSaturation.addBC (
"Top2", FLUX1, Natural, Full, saturationNeumannBDfun, 0 );
372 bcSaturation.addBC (
"InletPressure", INLETPRESSURE1, Essential, Scalar, saturationDirichletBDfun1 );
373 bcSaturation.addBC (
"InletPressure1", INLETPRESSURE2, Essential, Scalar, saturationDirichletBDfun3 );
374 bcSaturation.addBC (
"OutletPressure", OUTLETPRESSURE, Essential, Scalar, saturationDirichletBDfun2 );
393 chronoBoundaryCondition.stop();
398 std::cout <<
"Time for create the boundary conditions handler " <<
399 chronoBoundaryCondition.diff() << std::endl << std::flush;
406 chronoFiniteElementSpace.start();
415 pressure_refFE_primal = &feTetraP0;
424 pressure_refFE_dual = &feTetraRT0;
433 pressure_refFE_dualInterpolate = &feTetraP0;
443 pressure_refFE_hybrid = &feTetraRT0Hyb;
452 pressure_refFE_VdotN = &feTetraRT0VdotNHyb;
458 feSpacePtr_Type pressure_p_FESpacePtr (
new feSpace_Type ( meshPtr, *pressure_refFE_primal, *pressure_qR_primal,
459 *pressure_bdQr_primal, 1, Members->comm ) );
462 feSpacePtr_Type pressure_u_FESpacePtr (
new feSpace_Type ( meshPtr, *pressure_refFE_dual, *pressure_qR_dual,
463 *pressure_bdQr_dual, 1, Members->comm ) );
466 feSpacePtr_Type pressure_uInterpolate_FESpacePtr (
new feSpace_Type ( meshPtr, *pressure_refFE_dualInterpolate,
467 *pressure_qR_dualInterpolate,
468 *pressure_bdQr_dualInterpolate, 3, Members->comm ) );
471 vector_ptrtype pressure_dualInterpolated (
new vector_type ( pressure_uInterpolate_FESpacePtr->map(), Repeated ) );
474 FESpace< RegionMesh, MapEpetra > pressure_hybrid_FESpace ( meshPtr, *pressure_refFE_hybrid, *pressure_qR_hybrid,
475 *pressure_bdQr_hybrid, 1, Members->comm );
478 FESpace< RegionMesh, MapEpetra > pressure_VdotN_FESpace ( meshPtr, *pressure_refFE_VdotN, *pressure_qR_VdotN,
479 *pressure_bdQr_VdotN, 1, Members->comm );
488 saturation_hyperbolic_refFE = pressure_refFE_primal;
489 saturation_hyperbolic_qR = pressure_qR_primal;
493 feSpacePtr_Type saturation_hyperbolic_FESpacePtr (
new feSpace_Type ( meshPtr, *saturation_hyperbolic_refFE,
494 *saturation_hyperbolic_qR,
495 *saturation_hyperbolic_bdQr, 1, Members->comm ) );
497 GhostHandler<RegionMesh> ghost ( fullMeshPtr, meshPart.meshPartition(), saturation_hyperbolic_FESpacePtr->mapPtr(), Members->comm );
506 saturation_darcy_refFE_primal = pressure_refFE_primal;
507 saturation_darcy_qR_primal = pressure_qR_primal;
508 saturation_darcy_bdQr_primal = pressure_bdQr_dual;
515 saturation_darcy_refFE_dual = pressure_refFE_dual;
516 saturation_darcy_qR_dual = pressure_qR_dual;
517 saturation_darcy_bdQr_dual = pressure_bdQr_dual;
525 saturation_darcy_refFE_hybrid = pressure_refFE_hybrid;
526 saturation_darcy_qR_hybrid = pressure_qR_hybrid;
527 saturation_darcy_bdQr_hybrid = pressure_bdQr_hybrid;
534 saturation_darcy_refFE_VdotN = pressure_refFE_VdotN;
535 saturation_darcy_qR_VdotN = pressure_qR_VdotN;
536 saturation_darcy_bdQr_VdotN = pressure_bdQr_VdotN;
540 FESpace< RegionMesh, MapEpetra > saturation_darcy_p_FESpace ( meshPtr, *saturation_darcy_refFE_primal,
541 *saturation_darcy_qR_primal,
542 *saturation_darcy_bdQr_primal, 1, Members->comm );
545 FESpace< RegionMesh, MapEpetra > saturation_darcy_u_FESpace ( meshPtr, *saturation_darcy_refFE_dual,
546 *saturation_darcy_qR_dual,
547 *saturation_darcy_bdQr_dual, 1, Members->comm );
550 FESpace< RegionMesh, MapEpetra > saturation_darcy_hybrid_FESpace ( meshPtr, *saturation_darcy_refFE_hybrid,
551 *saturation_darcy_qR_hybrid,
552 *saturation_darcy_bdQr_hybrid, 1, Members->comm );
555 FESpace< RegionMesh, MapEpetra > saturation_darcy_VdotN_FESpace ( meshPtr, *saturation_darcy_refFE_VdotN,
556 *saturation_darcy_qR_VdotN,
557 *saturation_darcy_bdQr_VdotN, 1, Members->comm );
561 chronoFiniteElementSpace.stop();
565 std::cout <<
"Time for create the finite element spaces " <<
566 chronoFiniteElementSpace.diff() << std::endl << std::flush;
569 chronoProblem.start();
572 ds pressureSolver ( dataPressure, *pressure_p_FESpacePtr, *pressure_u_FESpacePtr,
573 pressure_hybrid_FESpace, pressure_VdotN_FESpace, Members->comm );
578 hyper saturationHyperbolicSolver ( dataSaturationHyperbolic,
579 *saturation_hyperbolic_FESpacePtr,
580 ghost.ghostMapOnElementsP0(),
584 dstnl saturationDarcySolver ( dataSaturationDarcyNonLinear, saturation_darcy_p_FESpace,
585 saturation_darcy_u_FESpace, saturation_darcy_hybrid_FESpace,
586 saturation_darcy_VdotN_FESpace, Members->comm );
589 chronoProblem.stop();
592 pressureSolver.getDisplayer().leaderPrint (
"Time for create the problem ",
593 chronoProblem.diff(),
"\n" );
598 chronoProcess.start();
603 pressureSolver.setup();
606 inversePermeability < RegionMesh > invPermPress ( Members->getPressurePermeability(),
607 saturation_darcy_p_FESpace );
610 invPermPress.setField ( saturationDarcySolver.primalSolution() );
613 pressureSolver.setInversePermeability ( invPermPress );
616 pressureSolver.setSource ( Members->getPressureSource() );
619 pressureSolver.setBC ( bcPressure );
624 saturationHyperbolicSolver.setup();
627 GodunovNumericalFlux < RegionMesh > numericalFlux ( Members->getSaturationPhysicalFlux(),
628 Members->getSaturationFirstDerivativePhysicalFlux(),
629 *pressure_uInterpolate_FESpacePtr,
631 "impes/hyperbolic/numerical_flux/" );
634 numericalFlux.setExternalField ( pressure_dualInterpolated );
637 saturationHyperbolicSolver.setNumericalFlux ( numericalFlux );
640 saturationHyperbolicSolver.setMassTerm ( Members->getSaturationMass() );
643 saturationHyperbolicSolver.setBoundaryCondition ( bcSaturation );
648 saturationDarcySolver.setup();
651 inversePermeability < RegionMesh > invPermSat ( Members->getSaturationPermeability(),
652 saturation_darcy_p_FESpace );
655 saturationDarcySolver.setInversePermeability ( invPermSat );
658 saturationDarcySolver.setInitialPrimal ( Members->getSaturationInitialCondition() );
661 saturationDarcySolver.setSource ( Members->getSaturationSource() );
664 saturationDarcySolver.setBC ( bcSaturation );
667 std::shared_ptr< Exporter< RegionMesh > > exporter;
670 vector_ptrtype pressureExporter;
673 vector_ptrtype saturationExporter;
676 std::string
const exporterType = dataFile (
"exporter/type",
"ensight");
680 if ( exporterType.compare (
"hdf5") == 0 )
682 exporter.reset (
new ExporterHDF5< RegionMesh > ( dataFile, dataFile (
"exporter/file_name",
"PressureSaturation" ) ) );
685 exporter->setPostDir ( dataFile (
"exporter/folder",
"./" ) );
687 exporter->setMeshProcId ( meshPtr, Members->comm->MyPID() );
692 if ( exporterType.compare (
"none") == 0 )
694 exporter.reset (
new ExporterEmpty< RegionMesh > ( dataFile, dataFile (
"exporter/file_name",
"PressureSaturation" ) ) );
697 exporter->setPostDir ( dataFile (
"exporter/folder",
"./" ) );
699 exporter->setMeshProcId ( meshPtr, Members->comm->MyPID() );
703 exporter.reset (
new ExporterEnsight< RegionMesh > ( dataFile, dataFile (
"exporter/file_name",
"PressureSaturation" ) ) );
706 exporter->setPostDir ( dataFile (
"exporter/folder",
"./" ) );
708 exporter->setMeshProcId ( meshPtr, Members->comm->MyPID() );
713 pressureExporter.reset (
new vector_type ( *pressureSolver.primalSolution(), exporter->mapType() ) );
716 exporter->addVariable ( ExporterData<RegionMesh>::ScalarField,
"Pressure",
717 pressure_p_FESpacePtr, pressureExporter,
718 static_cast<UInt> ( 0 ),
719 ExporterData< RegionMesh >::UnsteadyRegime,
720 ExporterData< RegionMesh >::Cell );
723 saturationExporter.reset (
new vector_type ( *saturationHyperbolicSolver.solution(), exporter->mapType() ) );
726 exporter->addVariable ( ExporterData<RegionMesh>::ScalarField,
"Saturation",
727 saturation_hyperbolic_FESpacePtr, saturationExporter,
728 static_cast<UInt> ( 0 ),
729 ExporterData< RegionMesh >::UnsteadyRegime,
730 ExporterData< RegionMesh >::Cell );
733 pressureSolver.getDisplayer().leaderPrint (
"Number of unknowns : ",
734 2.*pressure_hybrid_FESpace.map().map (Unique)->NumGlobalElements() +
735 saturation_hyperbolic_FESpacePtr->map().map (Unique)->NumGlobalElements(),
"\n" );
742 *saturationExporter = *saturationDarcySolver.primalSolution();
745 exporter->postProcess ( dataSaturationHyperbolic.dataTime()->initialTime() );
748 dataSaturationDarcyNonLinear.dataTime()->updateTime();
751 for ( ; dataSaturationDarcyNonLinear.dataTime()->canAdvance(); dataSaturationDarcyNonLinear.dataTime()->updateTime() )
755 if ( saturationDarcySolver.getDisplayer().isLeader() )
757 dataSaturationDarcyNonLinear.dataTime()->showMe();
763 pressureSolver.buildSystem();
766 pressureSolver.solve();
769 pressureSolver.computePrimalAndDual();
772 *pressure_dualInterpolated = pressure_uInterpolate_FESpacePtr->feToFEInterpolate ( *pressure_u_FESpacePtr,
773 *pressureSolver.dualSolution() );
780 saturationHyperbolicSolver.setSolution ( saturationDarcySolver.primalSolution() );
785 dataSaturationHyperbolic.dataTime()->setInitialTime ( dataSaturationDarcyNonLinear.dataTime()->time() );
788 dataSaturationHyperbolic.dataTime()->setTime ( dataSaturationDarcyNonLinear.dataTime()->time() );
791 Real innerTimeStep ( 0. );
794 dataSaturationHyperbolic.dataTime()->setEndTime ( dataSaturationDarcyNonLinear.dataTime()->nextTime() );
797 bool isLastTimeStep (
false );
800 for ( ; dataSaturationHyperbolic.dataTime()->canAdvance() && !isLastTimeStep; dataSaturationHyperbolic.dataTime()->updateTime() )
804 saturationHyperbolicSolver.getDisplayer().leaderPrint (
"Inner loop for sub-temporal iteration for the hyperbolic equation.\n" );
810 if ( dataSaturationHyperbolic.dataTime()->isLastTimeStep() )
813 innerTimeStep = dataSaturationHyperbolic.dataTime()->leftTime();
816 isLastTimeStep =
true;
823 if ( saturationHyperbolicSolver.getDisplayer().isLeader() )
825 dataSaturationHyperbolic.dataTime()->showMe();
829 saturationHyperbolicSolver.solveOneTimeStep();
836 saturationDarcySolver.setPrimalSolution ( saturationHyperbolicSolver.solution() );
837 saturationDarcySolver.updatePrimalOldSolution();
840 saturationDarcySolver.fixedPointScheme();
845 *pressureExporter = *pressureSolver.primalSolution();
848 *saturationExporter = *saturationDarcySolver.primalSolution();
851 exporter->postProcess ( dataSaturationDarcyNonLinear.dataTime()->time() );
856 chronoProcess.stop();
859 pressureSolver.getDisplayer().leaderPrint (
"Time for process ",
860 chronoProcess.diff(),
"\n" );
866 pressureSolver.getDisplayer().leaderPrint (
"Total time for the computation ",
867 chronoTotal.diff(),
"\n" );
std::shared_ptr< Epetra_Comm > comm
Real UOne(const Real &, const Real &, const Real &, const Real &, const ID &)
Vfct_type getSaturationPhysicalFlux()
FESpace - Short description here please!
LifeV::Real run()
Methods.
const QuadratureRule quadRuleTetra15pt(pt_tetra_15pt, 5, "Quadrature rule 15 points on a tetraedra", TETRA, 15, 5)
const QuadratureRule quadRuleTria4pt(pt_tria_4pt, 3, "Quadrature rule 4 points on a triangle", TRIANGLE, 4, 3)
Real UZero(const Real &, const Real &, const Real &, const Real &, const ID &)
impes(int argc, char **argv)
Constructors.
Mfct_type getPressurePermeability()
fct_type getSaturationInitialCondition()
Vfct_type getSaturationFirstDerivativePhysicalFlux()
Mfct_type getSaturationPermeability()
std::function< Vector(const Real &, const Real &, const Real &, const Real &, const std::vector< Real > &) > Vfct_type
std::function< Matrix(const Real &, const Real &, const Real &, const Real &, const std::vector< Real > &) > Mfct_type
fct_type getSaturationSource()
std::shared_ptr< std::vector< Int > > M_isOnProc
MeshData - class for handling spatial discretization.
HyperbolicSolver Implements an hyperbolic solver.
double Real
Generic real data.
std::function< Real(const Real &, const Real &, const Real &, const Real &, const ID &) > fct_type
The class for a reference Lagrangian finite element.
fct_type getPressureSource()
fct_type getSaturationMass()
std::string data_file_name
std::string discretization_section_hyperbolic
std::string discretization_section_darcy
contain the basic data for the Darcy solver.
std::string discretization_section_darcy_nonlin_trans
QuadratureRule - The basis class for storing and accessing quadrature rules.
const QuadratureRule quadRuleTria1pt(pt_tria_1pt, 1, "Quadrature rule 1 point on a triangle", TRIANGLE, 1, 1)
std::string discretization_section