44 #ifndef _MONOLITHIC_HPP 45 #define _MONOLITHIC_HPP 47 #include <EpetraExt_MatrixMatrix.h> 51 #include <lifev/core/util/LifeChrono.hpp> 52 #include <lifev/core/fem/FESpace.hpp> 53 #include <lifev/fsi/solver/FSIOperator.hpp> 55 #include <lifev/core/algorithm/PreconditionerComposed.hpp> 56 #include <lifev/core/algorithm/ComposedOperator.hpp> 57 #ifdef HAVE_TRILINOS_ANASAZI 58 #include <lifev/core/algorithm/EigenSolver.hpp> 61 #include <lifev/fsi/solver/MonolithicBlockMatrix.hpp> 62 #include <lifev/fsi/solver/MonolithicBlockComposed.hpp> 64 #include <life/lifealg/PreconditionerPCD.hpp> 68 #include <lifev/core/array/MatrixEpetraStructured.hpp> 69 #include <lifev/core/array/MatrixEpetraStructuredUtility.hpp> 70 #include <lifev/core/array/MatrixEpetraStructuredView.hpp> 71 #include <lifev/core/array/VectorEpetraStructured.hpp> 72 #include <lifev/core/array/VectorEpetraStructuredView.hpp> 78 class WRONG_PREC_EXCEPTION;
102 class FSIMonolithic :
public FSIOperator
109 typedef FSIOperator super_Type;
110 typedef FSIOperator::fluid_Type::matrix_Type matrix_Type;
111 typedef std::shared_ptr<matrix_Type> matrixPtr_Type;
112 typedef super_Type::solution_Type solution_Type;
113 typedef super_Type::solutionPtr_Type solutionPtr_Type;
114 typedef MonolithicBlock prec_Type;
115 typedef std::shared_ptr<prec_Type> precPtr_Type;
116 typedef MonolithicBlockMatrix blockMatrix_Type;
117 typedef std::shared_ptr<blockMatrix_Type> blockMatrixPtr_Type;
118 typedef FactorySingleton< Factory< FSIMonolithic, std::string > > factory_Type;
119 typedef SolverAztecOO solver_Type;
122 typedef MatrixEpetraStructured<
Real> matrixBlock_Type;
123 typedef MatrixEpetraStructuredView<
Real> matrixBlockView_Type;
124 typedef std::shared_ptr<matrixBlock_Type> matrixBlockPtr_Type;
149 virtual void setupDOF (
void );
155 void setupDOF ( meshFilter_Type& filterMesh );
162 virtual void setupSystem( );
171 virtual void setup (
const GetPot& dataFile );
177 virtual void setupFluidSolid();
184 virtual void setupFluidSolid (
UInt const fluxes );
197 void monolithicToInterface ( vector_Type& lambdaSolid,
const vector_Type& sol) ;
209 void monolithicToX (
const vector_Type& disp, vector_Type& dispFluid, MapEpetra& map,
UInt offset = (
UInt) 0);
222 void mergeBCHandlers()
226 M_BCh_u->merge (*M_BCh_flux);
230 M_BCh_u = M_BCh_flux;
237 #ifdef HAVE_TRILINOS_ANASAZI 243 LifeV::Real& computeMaxSingularValue();
251 void computeFluidNormals ( vector_Type& normals);
261 virtual void evalResidual (vector_Type& res,
262 const vector_Type& sol,
263 const UInt iter) = 0 ;
289 virtual void solveJac (vector_Type& muk,
290 const vector_Type& res,
291 const Real linearRelTol);
297 virtual void updateSystem();
303 void enableStressComputation (
UInt flag);
308 vectorPtr_Type computeStress();
317 precPtr_Type& precPtrView()
323 blockMatrixPtr_Type& operatorPtrView()
325 return M_monolithicMatrix;
331 virtual void setSolidBC (
const fluidBchandlerPtr_Type& bc_solid )
333 super_Type::setSolidBC (bc_solid);
342 void setFluidBC (
const fluidBchandlerPtr_Type& bc_fluid )
344 super_Type::setFluidBC (bc_fluid);
348 UInt nfluxes (M_BChs[1]->numberOfBCWithType (Flux) );
350 M_fluxOffset.resize (nfluxes);
351 M_BCFluxNames = M_BChs[1]->findAllBCWithType (Flux);
352 for (
UInt i = 0; i < nfluxes; ++i)
354 const BCBase* bc = M_BChs[1]->findBCWithName (M_BCFluxNames[i]);
355 M_fluxOffset[i] = bc->offset();
357 M_BChs[1] = bc_fluid;
358 M_monolithicMatrix->setConditions (M_BChs);
359 M_precPtr->setConditions (M_BChs);
368 return nDimensions * M_monolithicMatrix->interface();
384 void exportSolidDisplacement ( vector_Type& solidDisplacement )
386 solidDisplacement.subset ( M_fluidTimeAdvance->singleElement (0), M_offset );
387 solidDisplacement *= M_solid->rescaleFactor();
395 void exportSolidVelocity ( vector_Type& solidVelocity )
397 solidVelocity.subset ( M_solidTimeAdvance->firstDerivative(), M_offset );
398 solidVelocity *= M_solid->rescaleFactor();
406 void exportSolidAcceleration ( vector_Type& solidAcceleration )
408 solidAcceleration.subset ( M_solidTimeAdvance->secondDerivative(), M_offset );
409 solidAcceleration *= M_solid->rescaleFactor();
416 void exportFluidVelocity ( vector_Type& fluidVelocity )
418 fluidVelocity.subset ( M_fluidTimeAdvance->singleElement (0), 0 );
425 void exportFluidPressure ( vector_Type& fluidPressure )
427 fluidPressure.subset ( M_fluidTimeAdvance->singleElement (0),
static_cast<UInt> (3 * M_uFESpace->dof().numTotalDof() ) );
436 void exportFluidVelocityAndPressure ( vector_Type& fluidVelocityAndPressure )
438 fluidVelocityAndPressure = M_fluidTimeAdvance->singleElement (0);
442 virtual std::shared_ptr<MapEpetra>& couplingVariableMap()
444 return M_monolithicMap;
448 virtual const vector_Type& solution()
const = 0;
454 virtual void updateSolution (
const vector_Type& solution )
456 this->M_fluidTimeAdvance->shiftRight (solution);
457 if (M_data->dataFluid()->conservativeFormulation() )
459 this->M_fluidMassTimeAdvance->shiftRight (M_fluid->matrixMass() *solution);
461 this->M_solidTimeAdvance->shiftRight (solution);
475 void setVectorInStencils (
const vectorPtr_Type& vel,
476 const vectorPtr_Type& pressure,
477 const vectorPtr_Type& solidDisp,
481 void setFluidVectorInStencil (
const vectorPtr_Type& vel,
const vectorPtr_Type& pressure,
const UInt iter);
483 void setSolidVectorInStencil (
const vectorPtr_Type& solidDisp,
const UInt iter);
485 virtual void setALEVectorInStencil (
const vectorPtr_Type& fluidDisp,
const UInt iter,
const bool lastVector) = 0;
487 void finalizeRestart();
489 void initializeMonolithicOperator ( std::vector< vectorPtr_Type> u0, std::vector< vectorPtr_Type> ds0, std::vector< vectorPtr_Type> df0);
501 virtual void createOperator ( std::string& operType ) = 0;
506 void iterateMonolithic (
const vector_Type& rhs, vector_Type& step);
513 void couplingRhs ( vectorPtr_Type rhs);
522 void evalResidual (
const vector_Type& sol,
const vectorPtr_Type& rhs, vector_Type& res,
bool diagonalScaling =
false);
527 return (!M_reusePrec || M_resetPrec);
531 void updateSolidSystem (vectorPtr_Type& rhsFluidCoupling);
536 void diagonalScale (vector_Type& rhs, matrixPtr_Type matrFull);
546 void solidInit (std::string
const& dOrder);
553 void variablesInit (std::string
const& dOrder);
556 virtual void setupBlockPrec();
564 void assembleSolidBlock (
UInt iter,
const vector_Type& solution);
572 void assembleFluidBlock (
UInt iter,
const vector_Type& solution);
580 void checkIfChangedFluxBC ( precPtr_Type oper );
587 std::shared_ptr<MapEpetra> M_monolithicMap;
588 std::shared_ptr< MapEpetra > M_interfaceMap;
589 std::shared_ptr<vector_Type> M_beta;
590 std::shared_ptr<MonolithicBlockMatrix > M_monolithicMatrix;
591 precPtr_Type M_precPtr;
592 std::shared_ptr<vector_Type> M_rhsFull;
594 fluidBchandlerPtr_Type M_BCh_flux;
595 solidBchandlerPtr_Type M_BChWS;
596 BCFunctionRobin M_bcfWs;
599 FSIOperator::fluid_Type::matrixPtr_Type M_fluidBlock;
600 matrixPtr_Type M_solidBlockPrec;
601 matrixPtr_Type M_robinCoupling;
602 matrixPtr_Type M_boundaryMass;
603 std::shared_ptr<solver_Type> M_linearSolver;
604 std::shared_ptr<vector_Type> M_numerationInterface;
605 std::vector<fluidBchandlerPtr_Type> M_BChs;
606 std::vector<std::shared_ptr<FESpace<mesh_Type, MapEpetra> > > M_FESpaces;
607 bool M_diagonalScale;
618 std::shared_ptr<ComposedOperator<Epetra_Operator> > M_preconditionedSymmetrizedMatrix;
619 std::shared_ptr<vector_Type> M_stress;
621 std::vector<bcName_Type> M_BCFluxNames;
622 std::vector<UInt> M_fluxOffset;
627 class WRONG_PREC_EXCEPTION
632 WRONG_PREC_EXCEPTION() {}
633 virtual ~WRONG_PREC_EXCEPTION() {}
void assignFunction(bcBase_Type &base)
Assign the function to the base of the BCHandler.
int32_type Int
Generic integer data.
double Real
Generic real data.
uint32_type UInt
generic unsigned integer (used mainly for addressing)