LifeV
BlockJacobiPreconditioner.hpp
Go to the documentation of this file.
1 //@HEADER
2 
3 #include <boost/numeric/ublas/matrix.hpp>
4 
5 #include <Epetra_CrsMatrix.h>
6 #include <Epetra_Vector.h>
7 
8 #include <lifev/core/linear_algebra/BlockEpetra_Map.hpp>
9 #include <lifev/core/linear_algebra/LinearOperatorAlgebra.hpp>
10 
11 #include <lifev/navier_stokes_blocks/solver/NavierStokesPreconditionerOperator.hpp>
12 #include <lifev/navier_stokes_blocks/solver/aSIMPLEOperator.hpp>
13 
14 #include <lifev/navier_stokes_blocks/solver/NavierStokesOperator.hpp>
15 
16 #include <lifev/core/array/MatrixEpetra.hpp>
17 #include <lifev/core/linear_algebra/ApproximatedInvertibleRowMatrix.hpp>
18 #include <Teuchos_ParameterList.hpp>
19 #include <Teuchos_XMLParameterListHelpers.hpp>
20 
21 #include <lifev/core/interpolation/Interpolation.hpp>
22 
23 #include <lifev/core/fem/FESpace.hpp>
24 #include <lifev/core/fem/BCHandler.hpp>
25 #include <lifev/core/fem/BCManage.hpp>
26 
27 #ifndef _BlockJacobiPreconditioner_H_
28 #define _BlockJacobiPreconditioner_H_
29 
30 namespace LifeV{
31 namespace Operators
32 {
33 
35 {
36 public:
37  //! @name Public Types
38  //@{
39 
47  typedef super::comm_Type comm_Type;
48  typedef super::commPtr_Type commPtr_Type;
55 
58 
60 
61  //@}
62 
63  //! @name Constructors
64  //@{
65  //! Empty constructor
67  //@}
68  virtual ~BlockJacobiPreconditioner();
69 
70  //! @name SetUp
71  //@{
72  //! SetUp
73  /*!
74  */
75 
76  //! @name Set Methods
77  //@{
78 
79  //! set the communicator
80  void setComm ( const commPtr_Type & comm ) { M_comm = comm; };
81  //! \warning Transpose of this operator is not supported
82  int SetUseTranspose(bool UseTranspose){M_useTranspose = UseTranspose; return 0;}
83  //! set the domain map
84  void setDomainMap(const std::shared_ptr<BlockEpetra_Map> & domainMap){M_operatorDomainMap = domainMap;}
85  //! set the range map
86  void setRangeMap(const std::shared_ptr<BlockEpetra_Map> & rangeMap){M_operatorRangeMap = rangeMap;}
87  //@}
88 
89 
90  //! @name
91  //@{
92  //! \warning No method \c Apply defined for this operator. It return an error code.
93  int Apply(const vector_Type &/*X*/, vector_Type &/*Y*/) const {return -1;};
94  //! Returns the High Order Yosida approximation of the inverse pressure Schur Complement applied to \c X.
95  int ApplyInverse(const vector_Type &X, vector_Type &Y) const;
96  //! \warning Infinity norm not defined for this operator
97  double NormInf() const {return -1.0;}
98  //@}
99 
100  // @name Attribute access functions
101  //@{
102  //! Return a character string describing the operator
103  const char * Label() const {return M_label.c_str();}
104  //! Return the current UseTranspose setting \warning Not Supported Yet.
105  bool UseTranspose() const {return M_useTranspose;}
106  //! Return false.
107  bool HasNormInf() const {return false;}
108  //! return a reference to the Epetra_Comm communicator associated with this operator
109  const comm_Type & Comm() const {return *M_comm;}
110  //! Returns the Epetra_Map object associated with the domain of this operator
111  const map_Type & OperatorDomainMap() const {return *(M_monolithicMap->map(Unique));}
112  //! Returns the Epetra_Map object associated with the range of this operator
113  const map_Type & OperatorRangeMap() const {return *(M_monolithicMap->map(Unique));}
114  //@}
115 
116  // @name Set the blocks
117  //@{
118 
119  //! Set the structure block
120  void setStructureBlock ( const matrixEpetraPtr_Type & S );
121 
122  //! Set the geometry block
123  void setGeometryBlock ( const matrixEpetraPtr_Type & G );
124 
125  //! Set the fluid blocks
126  void setFluidBlocks ( const matrixEpetraPtr_Type & F,
127  const matrixEpetraPtr_Type & Btranspose,
128  const matrixEpetraPtr_Type & B);
129 
130  //! Set the fluid blocks
131  void setFluidBlocks(const matrixEpetraPtr_Type & F,
132  const matrixEpetraPtr_Type & Btranspose,
133  const matrixEpetraPtr_Type & B,
134  const matrixEpetraPtr_Type & D);
135 
136  //! Set the coupling blocks
137  void setCouplingBlocks ( const matrixEpetraPtr_Type & C1transpose,
138  const matrixEpetraPtr_Type & C2transpose,
139  const matrixEpetraPtr_Type & C2,
140  const matrixEpetraPtr_Type & C1,
141  const matrixEpetraPtr_Type & C3);
142 
143  //! Set the shape derivatives
144  void setShapeDerivativesBlocks( const matrixEpetraPtr_Type & ShapeVelocity,
145  const matrixEpetraPtr_Type & ShapePressure);
146 
147  //@}
148 
149  // @name Update approximations of the block preconditioners
150  //@{
151 
152  //! Update the approximation of the structure momentum
154 
155  //! Update the approximation of the the geometry
157 
158  //! Update the approximation of the the geometry
160 
161  //@}
162 
163  //! Show information about the class
164  void showMe();
165 
166  // @name Set the parameters
167  //@{
168 
169  //! Interface to set the parameters of each block
170  void setOptions(const Teuchos::ParameterList& solversOptions);
171 
172  //! Set the monolithic map
173  void setMonolithicMap(const mapEpetraPtr_Type& monolithicMap);
174 
175  //! Set the use of shape derivatives
176  void setUseShapeDerivatives(const bool & useShapeDerivatives);
177 
178  //! Set the preconditioner type
179  void setFluidPreconditioner(const std::string& type);
180 
181  //! Set the blocks needed by the PCD preconditioner
182  void setPCDBlocks(const matrixEpetraPtr_Type & Fp, const matrixEpetraPtr_Type & Mp, const matrixEpetraPtr_Type & Mu);
183 
184  const char * preconditionerTypeFluid() const { return M_FluidPrec->Label(); }
185 
186  void setSubiterateFluidDirichlet(const bool & subiterateFluidDirichlet);
187 
188  //! Copy the pointer of the interpolation objects
189  void setCouplingOperators_nonconforming( interpolationPtr_Type fluidToStructure, interpolationPtr_Type structureToFluid, mapEpetraPtr_Type lagrangeMap);
190 
191  //! Copy the pointer of the fluid velocity fespace
192  void setVelocityFESpace( const FESpacePtr_Type& fluid_vel_FESpace) { M_velocityFESpace = fluid_vel_FESpace; };
193 
194  //! Copy the pointer of the fluid velocity fespace
195  void setBC( const BCHandlerPtr_Type& bc) { M_myBC = bc; };
196 
197  //! Copy the value of the timestep
198  void setTimeStep( Real dt) { M_timeStep = dt; };
199 
200  void setGamma (Real gamma){ M_gamma = gamma;};
201 
202  void setBeta (Real beta){ M_beta = beta;};
203 
204  void setBDFcoeff (Real coef){ M_bdfCoef = coef; M_useBDFStructure = true; };
205 
206  //@}
207 
208 private:
209 
210  // @name Set the parameters
211  //@{
212 
213  //! Set the list of the structure momentum
215 
216  //! Set the list of the geometry
217  void setGeometryOptions(const parameterListPtr_Type & _oList);
218 
219  //! Set the list of the fluid momentum
220  void setFluidMomentumOptions(const parameterListPtr_Type & _oList);
221 
222  //! Set the list of the shur complement of the fluid
223  void setSchurOptions(const parameterListPtr_Type & _oList);
224 
225  //! Set the list of the shur complement of the fluid
226  void setPressureMassOptions(const parameterListPtr_Type & _oList);
227 
228  //@}
229 
230  //! Create the domain and the range maps
231  void setMaps();
232 
234  //! Range Map
236 
237  //! Communicator
238  commPtr_Type M_comm;
239 
241 
242  // @name Approximation of the blocks
243  //@{
245 
247 
249 
251 
253  //@}
254 
255  // @name Parameter list of each block
256  //@{
257 
258  //! Parameters for the structure
260 
261  //! Parameters for the geometry
263 
264  //! Parameters for the fluid momentum
266 
267  //! Parameters for the shur complent of the fluid
269 
270  //! Parameters for the shur complent of the couplig
272 
273  //! Parameters for the pressure mass of the PCD
275  //@}
276 
277  // @name Parameter list of each block
278  //@{
279 
280  //! Structure block
282 
283  //! Geometry block
285 
286  //! Fluid blocks
291 
293  // Epetra Operator needed to solve the linear system
296 
297  //! Coupling blocks
305  //@}
306 
308 
310 
313 
314  //! Label
315  const std::string M_label;
316 
318 
319  // Offsets
324 
325  //! Vectors needed for the applyInverse - input vectors associated to each part
331 
332  //! Vectors needed for the applyInverse - output vectors associated to each part
338 
339  //! PCD blocks
343 
345 
347 
351 
353 
356 
358 
360 
362 
365 };
366 
367 } /* end namespace Operators */
368 } //end namespace
369 #endif
std::shared_ptr< Teuchos::ParameterList > parameterListPtr_Type
VectorEpetra - The Epetra Vector format Wrapper.
std::shared_ptr< lumpedMatrix_Type > lumpedMatrixPtr_Type
std::shared_ptr< VectorEpetra_Type > M_Y_pressure
void setMaps()
Create the domain and the range maps.
std::shared_ptr< Operators::InvertibleOperator > M_invOper
std::shared_ptr< Operators::ApproximatedInvertibleRowMatrix > M_approximatedStructureMomentumOperator
std::shared_ptr< VectorEpetra_Type > M_X_displacement
std::shared_ptr< Operators::ApproximatedInvertibleRowMatrix > M_approximatedFluidMomentumOperator
void setPressureMassOptions(const parameterListPtr_Type &_oList)
Set the list of the shur complement of the fluid.
std::shared_ptr< VectorEpetra_Type > M_Y_displacement
void setStructureBlock(const matrixEpetraPtr_Type &S)
Set the structure block.
void importFromHDF5(std::string const &fileName, std::string const &matrixName="matrix")
Read a matrix from a HDF5 (.h5) file.
std::shared_ptr< Operators::ApproximatedInvertibleRowMatrix > M_approximatedSchurComplementCouplingOperator
matrixEpetraPtr_Type M_C1transpose
Coupling blocks.
void setOptions(const Teuchos::ParameterList &solversOptions)
Interface to set the parameters of each block.
const char * Label() const
Return a character string describing the operator.
void setUseShapeDerivatives(const bool &useShapeDerivatives)
Set the use of shape derivatives.
std::shared_ptr< Operators::ApproximatedInvertibleRowMatrix > M_approximatedSchurComplementOperator
FESpace< RegionMesh< LinearTetra >, mapEpetra_Type > FESpace_Type
parameterListPtr_Type M_structureMomentumOptions
Parameters for the structure.
parameterListPtr_Type M_geometryOptions
Parameters for the geometry.
Abstract class which defines the interface of a Linear Operator.
std::shared_ptr< BlockEpetra_Map > M_operatorRangeMap
Range Map.
void setGeometryOptions(const parameterListPtr_Type &_oList)
Set the list of the geometry.
const map_Type & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
void updateApproximatedStructureMomentumOperator()
Update the approximation of the structure momentum.
void updateInverseJacobian(const UInt &iQuadPt)
void setFluidBlocks(const matrixEpetraPtr_Type &F, const matrixEpetraPtr_Type &Btranspose, const matrixEpetraPtr_Type &B, const matrixEpetraPtr_Type &D)
Set the fluid blocks.
std::shared_ptr< VectorEpetra_Type > M_Y_velocity
Vectors needed for the applyInverse - output vectors associated to each part.
parameterListPtr_Type M_pressureMassOptions
Parameters for the pressure mass of the PCD.
std::shared_ptr< VectorEpetra_Type > M_X_pressure
void setGeometryBlock(const matrixEpetraPtr_Type &G)
Set the geometry block.
parameterListPtr_Type M_schurCouplingOptions
Parameters for the shur complent of the couplig.
int ApplyInverse(const vector_Type &X, vector_Type &Y) const
Returns the High Order Yosida approximation of the inverse pressure Schur Complement applied to X...
void setStructureMomentumOptions(const parameterListPtr_Type &_oList)
Set the list of the structure momentum.
Epetra_Import const & importer()
Getter for the Epetra_Import.
Definition: MapEpetra.cpp:394
void setDomainMap(const std::shared_ptr< BlockEpetra_Map > &domainMap)
set the domain map
void setTimeStep(Real dt)
Copy the value of the timestep.
std::shared_ptr< VectorEpetra_Type > VectorEpetraPtr_Type
int Apply(const vector_Type &, vector_Type &) const
void setVelocityFESpace(const FESpacePtr_Type &fluid_vel_FESpace)
Copy the pointer of the fluid velocity fespace.
bool UseTranspose() const
Return the current UseTranspose setting.
std::shared_ptr< VectorEpetra_Type > M_X_lambda
void setPCDBlocks(const matrixEpetraPtr_Type &Fp, const matrixEpetraPtr_Type &Mp, const matrixEpetraPtr_Type &Mu)
Set the blocks needed by the PCD preconditioner.
void setBC(const BCHandlerPtr_Type &bc)
Copy the pointer of the fluid velocity fespace.
void setCouplingOperators_nonconforming(interpolationPtr_Type fluidToStructure, interpolationPtr_Type structureToFluid, mapEpetraPtr_Type lagrangeMap)
Copy the pointer of the interpolation objects.
parameterListPtr_Type M_schurOptions
Parameters for the shur complent of the fluid.
std::shared_ptr< Operators::NavierStokesOperator > M_oper
double Real
Generic real data.
Definition: LifeV.hpp:175
void showMe()
Show information about the class.
std::shared_ptr< VectorEpetra_Type > M_X_velocity
Vectors needed for the applyInverse - input vectors associated to each part.
void setFluidBlocks(const matrixEpetraPtr_Type &F, const matrixEpetraPtr_Type &Btranspose, const matrixEpetraPtr_Type &B)
Set the fluid blocks.
void setFluidPreconditioner(const std::string &type)
Set the preconditioner type.
std::shared_ptr< VectorEpetra_Type > M_Y_geometry
parameterListPtr_Type M_fluidMomentumOptions
Parameters for the fluid momentum.
const map_Type & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
void setRangeMap(const std::shared_ptr< BlockEpetra_Map > &rangeMap)
set the range map
std::shared_ptr< Operators::ApproximatedInvertibleRowMatrix > M_approximatedGeometryOperator
const comm_Type & Comm() const
return a reference to the Epetra_Comm communicator associated with this operator
void setFluidMomentumOptions(const parameterListPtr_Type &_oList)
Set the list of the fluid momentum.
void setComm(const commPtr_Type &comm)
set the communicator
std::shared_ptr< VectorEpetra_Type > M_Y_lambda
void setSchurOptions(const parameterListPtr_Type &_oList)
Set the list of the shur complement of the fluid.
void updateApproximatedGeometryOperator()
Update the approximation of the the geometry.
void setShapeDerivativesBlocks(const matrixEpetraPtr_Type &ShapeVelocity, const matrixEpetraPtr_Type &ShapePressure)
Set the shape derivatives.
std::shared_ptr< Interpolation > interpolationPtr_Type
void setSubiterateFluidDirichlet(const bool &subiterateFluidDirichlet)
void updateApproximatedFluidOperator()
Update the approximation of the the geometry.
std::shared_ptr< mapEpetra_Type > mapEpetraPtr_Type
std::shared_ptr< VectorEpetra_Type > M_X_geometry
void setCouplingBlocks(const matrixEpetraPtr_Type &C1transpose, const matrixEpetraPtr_Type &C2transpose, const matrixEpetraPtr_Type &C2, const matrixEpetraPtr_Type &C1, const matrixEpetraPtr_Type &C3)
Set the coupling blocks.
std::shared_ptr< BlockEpetra_Map > M_operatorDomainMap
std::shared_ptr< matrixEpetra_Type > matrixEpetraPtr_Type
void setMonolithicMap(const mapEpetraPtr_Type &monolithicMap)
Set the monolithic map.
std::shared_ptr< Operators::NavierStokesPreconditionerOperator > M_FluidPrec