LifeV
BlockOperator.hpp
Go to the documentation of this file.
1 /*
2  * BlockOperator.hpp
3  *
4  * Created on: Sep 20, 2010
5  * Author: uvilla
6  */
7 
8 #ifndef BLOCKOPERATOR_HPP_
9 #define BLOCKOPERATOR_HPP_
10 
11 #include <Epetra_Import.h>
12 #include <boost/numeric/ublas/matrix.hpp>
13 
14 #include <lifev/core/linear_algebra/BlockEpetra_Map.hpp>
15 #include <lifev/core/linear_algebra/BlockEpetra_MultiVector.hpp>
16 #include <lifev/core/linear_algebra/LinearOperatorAlgebra.hpp>
17 
18 namespace LifeV
19 {
20 
21 namespace Operators
22 {
23 //! @class BlockOperator
24 /*! @brief A abstract class for handling n-by-m block operators
25  * This class inherits from LifeV::LinearOperatorAlgebra.
26  *
27  * The Transpose is not supported yet.
28  */
29 
31 {
32 public:
33 
34  //! @name Public Typedefs
35  //@{
37  typedef super::comm_Type comm_Type;
38  typedef super::commPtr_Type commPtr_Type;
39  typedef super::map_Type map_Type;
40  typedef super::mapPtr_Type mapPtr_Type;
41  typedef super::operator_Type operator_Type;
42  typedef super::operatorPtr_Type operatorPtr_Type;
43  typedef super::vector_Type vector_Type;
44  typedef super::vectorPtr_Type vectorPtr_Type;
45 
49 
50  enum Structure
51  {
52  Diagonal = 1,
60  };
61  //@}
62 
63  //! Empty Constructor
64  BlockOperator();
65 
66  //! @name Set Methods
67  //@{
68  //! SetUp for a "square operator"
69  /*!
70  * @param domainMap: the map of a vector in the domain of \e this
71  * is obtained by concatenating the block maps in
72  * domainMap.
73  * rangeMap is assumed to be the same of domainMap.
74  * @param comm: the communicator.
75  */
76  void setUp (const boost::shared_ptr<BlockEpetra_Map> & map, const commPtr_Type & comm);
77 
78  //! SetUp for a "rectangular operator"
79  /*!
80  * @param domainMap: the map of a vector in the domain of \e this
81  * is obtained by concatenating the block maps in
82  * domainMap.
83  * @param rangeMap: the map of a vector in the range of \e this
84  * is obtained by concatenating the block maps in
85  * rangeMap.
86  * @param comm: the communicator.
87  */
88  void setUp (const boost::shared_ptr<BlockEpetra_Map> & domainMap,
89  const boost::shared_ptr<BlockEpetra_Map> & rangeMap,
90  const commPtr_Type & comm);
91 
92  //! SetUp when the operator is given like a boost::matrix
93  /*!
94  * @param blockOper: a dense matrix to describe the block operator
95  * @param comm: the communicator
96  */
97  void setUp (const operatorPtrContainer_Type & blockOper, const commPtr_Type & comm);
98 
99  //! set a component of the block operator
100  /*!
101  * @param iblock, jblock: The position of the block is (iblock, jblock).
102  * @param operBlock : an operator_ptr representing the block
103  */
104  void setBlock (UInt iblock, UInt jblock, const operatorPtr_Type & operBlock);
105 
106  //! Complete the block matrix with null operators
107  void fillComplete ();
108 
109  //! If true the transpose of the operator will be computed.
110  /*
111  * Not Supported yet
112  */
113  int SetUseTranspose(bool useTranspose);
114 
115  //! Compute Y = Op*X;
116  virtual int Apply(const vector_Type & X, vector_Type & Y) const;
117  //! Compute Y = Op\X;
118  /*!
119  * ApplyInverse is implemented for the matrices with block diagonal, lowerTriangular, upperTriangular form
120  */
121  virtual int ApplyInverse(const vector_Type & X, vector_Type & Y) const;
122 
123  //! Compute the Inf norm of the operator
124  /*!
125  * Not implemented yet.
126  */
127  double NormInf() const {return -1;}
128 
129  //! Returns a character string describing the operator
130  virtual const char * Label() const {return M_name.c_str();}
131 
132  //! Returns the current UseTranspose setting.
133  bool UseTranspose() const {return M_useTranspose;}
134 
135  //! Returns true if the \e this object can provide an approximate Inf-norm, false otherwise.
136  bool HasNormInf() const {return false;}
137 
138  //! Returns a pointer to the Epetra_Comm communicator associated with this operator.
139  const comm_Type & Comm() const {return *M_comm;}
140 
141  //! Returns a const pointer to the (i,j) block
142  const operatorPtr_Type& block (UInt iblock, UInt jblock) const;
143 
144  //! Returns the Epetra_Map object associated with the domain of this operator.
145  const map_Type & OperatorDomainMap() const {return *(M_domainMap->monolithicMap());}
146  //! Returns the Epetra_Map object associated with the domain of this operator as a pointer
147  const mapPtr_Type & OperatorDomainMap_ptr() const {return M_domainMap->monolithicMap();}
148  const boost::shared_ptr<BlockEpetra_Map> & OperatorDomainBlockMapPtr() const {return M_domainMap;}
149 
150  //! Returns the Epetra_Map object associated with the range of this operator.
151  const map_Type & OperatorRangeMap() const {return *(M_rangeMap->monolithicMap());}
152  //! Returns the Epetra_Map object associated with the range of this operator as a pointer
153  const mapPtr_Type & OperatorRangeMap_ptr() const {return M_rangeMap->monolithicMap();}
154  const boost::shared_ptr<BlockEpetra_Map> & OperatorRangeBlockMapPtr() const {return M_rangeMap;}
155 
156 protected:
157  //! Compute Y = Op*X;
158  int applyNoTranspose(const vector_Type & X, vector_Type & Y) const;
159  //! Compute Y = Op'*X;
160  int applyTranspose(const vector_Type & X, vector_Type & Y) const;
161  //! Y = diag(block(i,i)^-1)*X
162  int blockJacobi(const vector_Type & X, vector_Type & Y) const;
163  //! Y = backwardsubstitution(X)
164  int blockUpperTriangularSolve(const vector_Type & X, vector_Type & Y) const;
165  //! Y = forwardsubstitution(X)
166  int blockLowerTriangularSolve(const vector_Type & X, vector_Type & Y) const;
167  //! Change the name of the operator, (available for derivate classes).
168  void setName(const std::string & name){M_name =name;}
169 private:
170 
171  //! Number of blocks in each row
173  //! Number of blocks in each column
175 
176  //! Name of the object
177  std::string M_name;
178  //! Communicator
179  commPtr_Type M_comm;
180 
181  //! @name Maps
182  //@{
183  //! Domain Map
185  //! Range Map
187  //@}
188 
189  //! block operator represented like a dense matrix of pointers to Operators
191 
192  //! whenever transpose should be used
194 
195  //! structure of the block operator
197 };
198 
199 } /*end namespace Operators*/
200 } /*end namespace */
201 #endif /* BLOCKOPERATOR_HPP_ */
void setUp(const operatorPtrContainer_Type &blockOper, const commPtr_Type &comm)
SetUp when the operator is given like a boost::matrix.
std::vector< vectorPtr_Type > vectorPtrContainer_Type
This class handles block access to parallel monolithic Vectors with an underling block structure...
int applyTranspose(const vector_Type &X, vector_Type &Y) const
Compute Y = Op&#39;*X;.
void setUp(const boost::shared_ptr< BlockEpetra_Map > &domainMap, const boost::shared_ptr< BlockEpetra_Map > &rangeMap, const commPtr_Type &comm)
SetUp for a "rectangular operator".
boost::shared_ptr< BlockEpetra_Map > M_domainMap
Domain Map.
int SetUseTranspose(bool useTranspose)
If true the transpose of the operator will be computed.
UInt M_nBlockCols
Number of blocks in each column.
void setBlock(UInt iblock, UInt jblock, const operatorPtr_Type &operBlock)
set a component of the block operator
virtual const char * Label() const
Returns a character string describing the operator.
Structure M_structure
structure of the block operator
boost::shared_ptr< BlockEpetra_Map > M_rangeMap
Range Map.
Abstract class which defines the interface of a Linear Operator.
operatorPtrContainer_Type M_oper
block operator represented like a dense matrix of pointers to Operators
const comm_Type & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
const mapPtr_Type & OperatorDomainMap_ptr() const
Returns the Epetra_Map object associated with the domain of this operator as a pointer.
const operatorPtr_Type & block(UInt iblock, UInt jblock) const
Returns a const pointer to the (i,j) block.
void updateInverseJacobian(const UInt &iQuadPt)
std::string M_name
Name of the object.
LinearOperatorAlgebra super
int blockUpperTriangularSolve(const vector_Type &X, vector_Type &Y) const
Y = backwardsubstitution(X)
void fillComplete()
Complete the block matrix with null operators.
int blockJacobi(const vector_Type &X, vector_Type &Y) const
Y = diag(block(i,i)^-1)*X.
A abstract class for handling n-by-m block operators This class inherits from LifeV::LinearOperatorAl...
commPtr_Type M_comm
Communicator.
const map_Type & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
std::vector< mapPtr_Type > mapPtrContainer_Type
const mapPtr_Type & OperatorRangeMap_ptr() const
Returns the Epetra_Map object associated with the range of this operator as a pointer.
boost::numeric::ublas::matrix< operatorPtr_Type > operatorPtrContainer_Type
void setName(const std::string &name)
Change the name of the operator, (available for derivate classes).
UInt M_nBlockRows
Number of blocks in each row.
double NormInf() const
Compute the Inf norm of the operator.
const boost::shared_ptr< BlockEpetra_Map > & OperatorDomainBlockMapPtr() const
int applyNoTranspose(const vector_Type &X, vector_Type &Y) const
Compute Y = Op*X;.
int blockLowerTriangularSolve(const vector_Type &X, vector_Type &Y) const
Y = forwardsubstitution(X)
bool UseTranspose() const
Returns the current UseTranspose setting.
const map_Type & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
virtual int ApplyInverse(const vector_Type &X, vector_Type &Y) const
Compute Y = Op;.
virtual int Apply(const vector_Type &X, vector_Type &Y) const
Compute Y = Op*X;.
void setUp(const boost::shared_ptr< BlockEpetra_Map > &map, const commPtr_Type &comm)
SetUp for a "square operator".
std::shared_ptr< vector_Type > vectorPtr_Type
const boost::shared_ptr< BlockEpetra_Map > & OperatorRangeBlockMapPtr() const
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
std::shared_ptr< operator_Type > operatorPtr_Type
bool M_useTranspose
whenever transpose should be used
BlockOperator()
Empty Constructor.