LifeV
NavierStokesOperator.hpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3  *******************************************************************************
4 
5  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7 
8  This file is part of LifeV.
9 
10  LifeV is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  LifeV is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22 
23  *******************************************************************************
24  */
25 //@HEADER
26 
27 /*!
28  @file
29  @brief Navier-Stokes operator equations.
30 
31  @author Davide Forti <davide.forti@epfl.ch>
32  @contributor Umberto Villa
33  @date 08-12-2014
34 
35  @maintainer Davide Forti <davide.forti@epfl.ch>
36  */
37 
38 #ifndef NSOPERATOR_HPP_
39 #define NSOPERATOR_HPP_
40 
41 #include <Epetra_Import.h>
42 #include <boost/numeric/ublas/matrix.hpp>
43 
44 #include <lifev/core/linear_algebra/BlockEpetra_Map.hpp>
45 #include <lifev/core/linear_algebra/BlockEpetra_MultiVector.hpp>
46 #include <lifev/core/linear_algebra/LinearOperatorAlgebra.hpp>
47 
48 namespace LifeV
49 {
50 
51 namespace Operators
52 {
53 //! @class NavierStokesOperator
54 /*! @brief A abstract class for handling n-by-m block operators
55  * This class inherits from LifeV::LinearOperator.
56  *
57  * The Transpose is not supported yet.
58  */
59 
60 class NavierStokesOperator: public LinearOperatorAlgebra
61 {
62 public:
63 
64  //! @name Public Typedefs
65  //@{
66  typedef LinearOperatorAlgebra super;
67  typedef super::comm_Type comm_Type;
68  typedef super::commPtr_Type commPtr_Type;
69  typedef super::map_Type map_Type;
70  typedef super::mapPtr_Type mapPtr_Type;
71  typedef super::operator_Type operator_Type;
72  typedef super::operatorPtr_Type operatorPtr_Type;
73  typedef super::vector_Type vector_Type;
74  typedef super::vectorPtr_Type vectorPtr_Type;
75 
76  typedef boost::numeric::ublas::matrix<operatorPtr_Type> operatorPtrContainer_Type;
77  typedef std::vector<vectorPtr_Type> vectorPtrContainer_Type;
78  typedef std::vector<mapPtr_Type > mapPtrContainer_Type;
79 
80  //@}
81 
82  //! Empty Constructor
83  NavierStokesOperator();
84 
85  //! @name Set Methods
86  //@{
87  //! SetUp for a "square operator"
88  /*!
89  * @param domainMap: the map of a vector in the domain of \e this
90  * is obtained by concatenating the block maps in
91  * domainMap.
92  * rangeMap is assumed to be the same of domainMap.
93  * @param comm: the communicator.
94  */
95  void setUp (const std::shared_ptr<BlockEpetra_Map> & map, const commPtr_Type & comm);
96 
97  //! SetUp for a "rectangular operator"
98  /*!
99  * @param domainMap: the map of a vector in the domain of \e this
100  * is obtained by concatenating the block maps in
101  * domainMap.
102  * @param rangeMap: the map of a vector in the range of \e this
103  * is obtained by concatenating the block maps in
104  * rangeMap.
105  * @param comm: the communicator.
106  */
107  void setUp (const std::shared_ptr<BlockEpetra_Map> & domainMap,
108  const std::shared_ptr<BlockEpetra_Map> & rangeMap,
109  const commPtr_Type & comm);
110 
111  //! SetUp when the operator is given like a std::matrix
112  /*!
113  * @param blockOper: a dense matrix to describe the block operator
114  * @param comm: the communicator
115  */
116  void setUp (const operatorPtrContainer_Type & blockOper, const commPtr_Type & comm);
117 
118  //! set a component of the block operator
119  /*!
120  * @param iblock, jblock: The position of the block is (iblock, jblock).
121  * @param operBlock : an operator_ptr representing the block
122  */
123  void setBlock (UInt iblock, UInt jblock, const operatorPtr_Type & operBlock);
124 
125  //! Complete the block matrix with null operators
126  void fillComplete ();
127 
128  //! If true the transpose of the operator will be computed.
129  /*
130  * Not Supported yet
131  */
132  int SetUseTranspose(bool useTranspose);
133 
134  //! Compute Y = Op*X;
135  virtual int Apply(const vector_Type & X, vector_Type & Y) const;
136  //! Compute Y = Op\X;
137  /*!
138  * ApplyInverse is implemented for the matrices with block diagonal, lowerTriangular, upperTriangular form
139  */
140  virtual int ApplyInverse(const vector_Type & X, vector_Type & Y) const;
141 
142  //! Compute the Inf norm of the operator
143  /*!
144  * Not implemented yet.
145  */
146  double NormInf() const {return -1;}
147 
148  //! Returns a character string describing the operator
149  virtual const char * Label() const {return M_name.c_str();}
150 
151  //! Returns the current UseTranspose setting.
152  bool UseTranspose() const {return M_useTranspose;}
153 
154  //! Returns true if the \e this object can provide an approximate Inf-norm, false otherwise.
155  bool HasNormInf() const {return false;}
156 
157  //! Returns a pointer to the Epetra_Comm communicator associated with this operator.
158  const comm_Type & Comm() const {return *M_comm;}
159 
160  //! Returns a const pointer to the (i,j) block
161  const operatorPtr_Type& block (UInt iblock, UInt jblock) const;
162 
163  //! Returns the Epetra_Map object associated with the domain of this operator.
164  const map_Type & OperatorDomainMap() const {return *(M_domainMap->monolithicMap());}
165  //! Returns the Epetra_Map object associated with the domain of this operator as a pointer
166  const mapPtr_Type & OperatorDomainMap_ptr() const {return M_domainMap->monolithicMap();}
167  const std::shared_ptr<BlockEpetra_Map> & OperatorDomainBlockMapPtr() const {return M_domainMap;}
168 
169  //! Returns the Epetra_Map object associated with the range of this operator.
170  const map_Type & OperatorRangeMap() const {return *(M_rangeMap->monolithicMap());}
171  //! Returns the Epetra_Map object associated with the range of this operator as a pointer
172  const mapPtr_Type & OperatorRangeMap_ptr() const {return M_rangeMap->monolithicMap();}
173  const std::shared_ptr<BlockEpetra_Map> & OperatorRangeBlockMapPtr() const {return M_rangeMap;}
174 
175 protected:
176  //! Compute Y = Op*X;
177  int applyNoTranspose(const vector_Type & X, vector_Type & Y) const;
178  //! Compute Y = Op'*X;
179  int applyTranspose(const vector_Type & X, vector_Type & Y) const;
180  //! Y = diag(block(i,i)^-1)*X
181  int blockJacobi(const vector_Type & X, vector_Type & Y) const;
182  //! Y = backwardsubstitution(X)
183  int blockUpperTriangularSolve(const vector_Type & X, vector_Type & Y) const;
184  //! Y = forwardsubstitution(X)
185  int blockLowerTriangularSolve(const vector_Type & X, vector_Type & Y) const;
186  //! Change the name of the operator, (available for derivate classes).
187  void setName(const std::string & name){M_name =name;}
188 private:
189 
190  //! Number of blocks in each row
191  UInt M_nBlockRows;
192  //! Number of blocks in each column
193  UInt M_nBlockCols;
194 
195  //! Name of the object
196  std::string M_name;
197  //! Communicator
198  commPtr_Type M_comm;
199 
200  //! @name Maps
201  //@{
202  //! Domain Map
203  std::shared_ptr<BlockEpetra_Map> M_domainMap;
204  //! Range Map
205  std::shared_ptr<BlockEpetra_Map> M_rangeMap;
206  //@}
207 
208  //! block operator represented like a dense matrix of pointers to Operators
209  operatorPtrContainer_Type M_oper;
210 
211  //! whenever transpose should be used
212  bool M_useTranspose;
213 };
214 
215 } /*end namespace Operators*/
216 
217 } /*end namespace */
218 #endif /* BLOCKOPERATOR_HPP_ */
Abstract class which defines the interface of a Linear Operator.
void updateInverseJacobian(const UInt &iQuadPt)
std::shared_ptr< vector_Type > vectorPtr_Type
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
std::shared_ptr< operator_Type > operatorPtr_Type