LifeV
RowMatrixPreconditioner.hpp
Go to the documentation of this file.
1 /*
2  * RowMatrixPreconditioner.hpp
3  *
4  * Created on: Oct 8, 2011
5  * Author: uvilla
6  */
7 /*!
8  * \file RowMatrixPreconditoner.hpp
9  * \author Umberto Villa
10  * \date 2011-10-08
11  * Abstract class to construct preconditioners from a matrix in Epetra_CsrFormat.
12  */
13 
14 #ifndef ROW_MATRIX_PRECONDITIONER_HPP_
15 #define ROW_MATRIX_PRECONDITIONER_HPP_
16 
17 #include <Epetra_CrsMatrix.h>
18 #include <Teuchos_ParameterList.hpp>
19 
20 #include <lifev/core/linear_algebra/LinearOperatorAlgebra.hpp>
21 #include <lifev/core/util/FactorySingleton.hpp>
22 #include <lifev/core/util/Factory.hpp>
23 
24 namespace LifeV
25 {
26 
27 namespace Operators
28 {
29 //! @class
30 /*!
31  * @brief Abstract class to construct preconditioners from a matrix in Epetra_CsrFormat.
32  *
33  * This class implementents all public methods of the parent class \c LinearOperator, and additionally introduce
34  * the following public methods"
35  * <ul>
36  * <li> \c SetRowMatrix to specify the matrix in Epetra_CsrMatrix format
37  * <li> \c SetParameterList to specify the list of parameter to be used in the preconditioner
38  * <li> \c Compute do all the operator to compute the preconditioner. This method assert that the parameter are
39  * set correctly and then it calls the protected abstract method myCompute.
40  * </ul>
41  *
42  * Concrete instances of the \c RowMatrixPreconditioner class should implement the protected method \c myCompute.
43  */
44 
46 {
47 public:
48 
49  //@name Typdefs
50  //@{
54  //@}
55 
56  //! Empty constructor
58 
59 
60  //! Destructor
61  virtual ~RowMatrixPreconditioner() {};
62 
63  //! @name Attribute set methods
64  //@{
65  //! Set the row matrix
66  void SetRowMatrix(const rowMatrixPtr_Type & rowMatrix)
67  {
68  ASSERT_PRE(rowMatrix.get() != 0, "RowMatrixPreconditioner::SetRowMatrix(): rowMatrix can not be a null Pointer");
69  M_rowMatrix = rowMatrix;
70  }
71 
72  //! Set the list of paramenters
73  void SetParameterList(const pList_Type pList)
74  {
75  M_pList = pList;
76  }
77 
78  //! Transposition
79  virtual int SetUseTranspose(bool UseTranspose)
80  {
81  return M_prec->SetUseTranspose(UseTranspose);
82  }
83  //@}
84 
85  //! Compute the preconditioner.
86  /*!
87  * Derived classes should implement the protected method myCompute called by this function.
88  * @return: 0 success, negative number error, positive number warning
89  */
90  int Compute()
91  {
92  ASSERT_PRE(M_rowMatrix.get()!= 0, "RowMatrixPreconditioner::Compute(): You need to SetRowMatrix first \n");
93  return myCompute();
94  }
95 
96  //! @name Mathematical functions
97  //@{
98  virtual int Apply(const vector_Type& X, vector_Type& Y) const
99  {
100  return M_prec->Apply(X,Y);
101  }
102 
103  virtual int ApplyInverse(const vector_Type& X, vector_Type& Y) const
104  {
105  return M_prec->ApplyInverse(X,Y);
106  }
107 
108  virtual double NormInf() const
109  {
110  return M_prec->NormInf();
111  }
112  //@}
113 
114  //! @name Attribute access functions
115  //@{
116 
117  //! Returns a character string describing the operator
118  virtual const char * Label() const
119  {
120  return M_prec->Label();
121  }
122 
123  //! Returns the current UseTranspose setting.
124  virtual bool UseTranspose() const
125  {
126  return M_prec->UseTranspose();
127  }
128 
129  //! Returns true if the \e this object can provide an approximate Inf-norm, false otherwise.
130  virtual bool HasNormInf() const
131  {
132  return M_prec->HasNormInf();
133  }
134 
135  //! Returns a pointer to the Epetra_Comm communicator associated with this operator.
136  virtual const comm_Type & Comm() const
137  {
138  return M_prec->Comm();
139  }
140 
141  //! Returns the raw_map object associated with the domain of this operator.
142  virtual const map_Type & OperatorDomainMap() const
143  {
144  return M_prec->OperatorDomainMap();
145  }
146 
147  //! Returns the raw_map object associated with the range of this operator.
148  virtual const map_Type & OperatorRangeMap() const
149  {
150  return M_prec->OperatorRangeMap();
151  }
152  //@}
153 
154 protected:
155  //! Abstract method myCompute implemented by the derived class
156  virtual int myCompute() = 0;
157 
161 
162 
163 };
164 
165 //! @typedef
166 /*!
167  * @brief \c RowMatrixPreconditionerFactory should be used for the creation of concrete instances of \c RowMatrixPreconditioner
168  */
170 
171 } /* end Operator namespace */
172 } /* end LifeV namespace */
173 
174 #endif /* ROW_MATRIX_PRECONDITIONER_HPP_ */
virtual bool UseTranspose() const
Returns the current UseTranspose setting.
FactorySingleton< Factory< RowMatrixPreconditioner, std::string > > RowMatrixPreconditionerFactory
RowMatrixPreconditionerFactory should be used for the creation of concrete instances of RowMatrixPrec...
void SetParameterList(const pList_Type pList)
Set the list of paramenters.
Abstract class which defines the interface of a Linear Operator.
virtual int SetUseTranspose(bool UseTranspose)
Transposition.
void updateInverseJacobian(const UInt &iQuadPt)
virtual double NormInf() const
Returns the infinity norm of the global matrix.
virtual const comm_Type & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
void SetRowMatrix(const rowMatrixPtr_Type &rowMatrix)
Set the row matrix.
#define ASSERT_PRE(X, A)
Definition: LifeAssert.hpp:96
virtual int myCompute()=0
Abstract method myCompute implemented by the derived class.
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.
std::shared_ptr< rowMatrix_Type > rowMatrixPtr_Type
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.
virtual bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
virtual const char * Label() const
Returns a character string describing the operator.
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.
Abstract class to construct preconditioners from a matrix in Epetra_CsrFormat.
std::shared_ptr< operator_Type > operatorPtr_Type