LifeV
ApproximatedInvertibleRowMatrix.hpp
Go to the documentation of this file.
1 /*
2  * ApproximatedInvertibleRowMatrix.h
3  *
4  * Created on: Oct 13, 2011
5  * Author: uvilla
6  */
7 
8 //@HEADER
9 
10 /*!
11  * \file ApproximatedInvertibleRowMatrix.hpp
12  * \author Umberto Villa
13  * \date 2011-10-13
14  * This file contains the definition of the class ApproximatedInvertibleRowMatrix.
15  * ApproximatedInvertibleRowMatrix is derived by the LinearOperator class, and it can be used to
16  * approximate the inverse of a Epetra_CsrMatrix, either by using the Krylov methods in Belos or AztecOO or
17  * the preconditioning techniques in ML or Ifpack.
18  */
19 
20 #ifndef APPROXIMATEDINVERTIBLEROWMATRIX_H_
21 #define APPROXIMATEDINVERTIBLEROWMATRIX_H_
22 
23 #include <lifev/core/linear_algebra/LinearOperatorAlgebra.hpp>
24 #include <lifev/core/linear_algebra/RowMatrixPreconditioner.hpp>
25 #include <lifev/core/linear_algebra/InvertibleOperator.hpp>
26 
27 namespace LifeV
28 {
29 
30 namespace Operators
31 {
32 
33 //! @class
34 /*!
35  * @brief Provide the \c ApplyInverse method for a Epetra_CrsMatrix object.
36  *
37  * ApproximatedInvertibleRowMatrix is derived by the LinearOperator class, and it can be used to
38  * approximate the inverse of a Epetra_CsrMatrix, either by using the Krylov methods in Belos or AztecOO or
39  * the preconditioning techniques in ML or Ifpack.
40  * Internally ApproximatedInvertibleRowMatrix contains pointers to a Epetra_CsrMatrix,
41  * to an InvertibleOperator object (that provides the interface to AztecOO or Belos), and RowMatrixPreconditioner
42  * (the provides the interface to Ifpack or ML).
43  *
44  * The parameters to set up the Krylov methods or the preconditioner are given by using a Teuchos Parameter List.
45  * Below how the parameter list would look like:
46  *
47  * \verbatim
48  * <ParameterList name="ApproximatedInvertibleRowMatrix">
49  * <Parameter name="use preconditioner as approximated inverse" type="bool" value="false"/>
50  * <Parameter name="preconditioner type" type="string" value="ML"/> <!-- Ifpack, ML, TwoLevel-->
51  * <ParameterList name="solver">
52  * <Parameter name="Linear Solver Type" type="string" value="Belos"/>
53  * <ParameterList name="AztecOO">
54  * <Parameter name="conv" type="string" value="r0"/>
55  * <Parameter name="max_iter" type="int" value="1500"/>
56  * <Parameter name="output" type="string" value="warnings"/>
57  * <Parameter name="scaling" type="string" value="none"/>
58  * <Parameter name="solver" type="string" value="cg"/>
59  * <Parameter name="tol" type="double" value="1e-03"/>
60  * </ParameterList>
61  * <ParameterList name="Belos">
62  * <Parameter name="Solver Type" type="string" value="RCG"/>
63  * <Parameter name="Preconditioner Side" type="string" value="Left"/>
64  * <ParameterList name="options">
65  * <Parameter name="Maximum Iterations" type="int" value="50"/>
66  * <Parameter name="Num Blocks" type="int" value="50"/>
67  * <Parameter name="Num Recycled Blocks" type="int" value="10"/>
68  * <Parameter name="Convergence Tolerance" type="double" value="1e-03"/>
69  * <Parameter name="Output Frequency" type="int" value="1"/>
70  * <Parameter name="Verbosity" type="int" value="0"/>
71  * </ParameterList>
72  * </ParameterList>
73  * </ParameterList>
74  * <ParameterList name="preconditioner">
75  * <ParameterList name="ML">
76  * <ParameterList name="options">
77  * <Parameter name="default values" type="string" value="SA"/>
78  * </ParameterList>
79  * </ParameterList>
80  * </ParameterList>
81  * </ParameterList>
82  * \endverbatim
83  *
84  *
85  */
86 
88 {
89 public:
90 
91  //! @name Public Typedef
92  //@{
96  //@}
97 
99 
101 
102  //! @name Attribute set methods
103  //@{
104  void SetRowMatrix(const rowMatrixPtr_Type & rowMatrix);
105 
106  void SetParameterList(const pList_Type pList);
107  //! not fully supported!
108  virtual int SetUseTranspose(bool UseTranspose);
109  //@}
110 
111  int Compute();
112 
114 
115  //! @name Mathematical functions
116  //@{
117  virtual int Apply(const vector_Type& X, vector_Type& Y) const;
118 
119  virtual int ApplyInverse(const vector_Type& X, vector_Type& Y) const;
120 
121  virtual double NormInf() const;
122  //@}
123 
124  //! @name Attribute access functions
125  //@{
126 
127  //! Returns a character string describing the operator
128  virtual const char * Label() const;
129 
130  //! Returns the current UseTranspose setting.
131  virtual bool UseTranspose() const;
132 
133  //! Returns true if the \e this object can provide an approximate Inf-norm, false otherwise.
134  virtual bool HasNormInf() const;
135 
136 
137  //! Returns a pointer to the Epetra_Comm communicator associated with this operator.
138  virtual const comm_Type & Comm() const;
139 
140 
141  //! Returns the raw_map object associated with the domain of this operator.
142  virtual const map_Type & OperatorDomainMap() const;
143 
144 
145  //! Returns the raw_map object associated with the range of this operator.
146  virtual const map_Type & OperatorRangeMap() const;
147 
148  //@}
149 
150 private:
151 
157 
158 };
159 
160 }
161 
162 }
163 
164 #endif /* APPROXIMATEDINVERTIBLEROWMATRIX_H_ */
std::shared_ptr< RowMatrixPreconditioner > & Preconditioner()
Abstract class which defines the interface of a Linear Operator.
void updateInverseJacobian(const UInt &iQuadPt)
virtual double NormInf() const
Returns the infinity norm of the global matrix.
virtual const map_Type & OperatorDomainMap() const
Returns the raw_map object associated with the domain of this operator.
virtual const map_Type & OperatorRangeMap() const
Returns the raw_map object associated with the range of this operator.
virtual const comm_Type & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
virtual int SetUseTranspose(bool UseTranspose)
not fully supported!
virtual bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
virtual int Apply(const vector_Type &X, vector_Type &Y) const
Returns the result of a raw_operator applied to a raw_vector X in Y.
virtual int ApplyInverse(const vector_Type &X, vector_Type &Y) const
Returns the result of a raw_operator inverse applied to an raw_vector X in Y.
Provide the ApplyInverse method for a Epetra_CrsMatrix object.
virtual const char * Label() const
Returns a character string describing the operator.
virtual bool UseTranspose() const
Returns the current UseTranspose setting.