LifeV
aSIMPLEOperator.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 SIMPLE preconditioner for Navier-Stokes 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 #include <Epetra_CrsMatrix.h>
39 #include <Epetra_Vector.h>
40 
41 #include <lifev/core/linear_algebra/BlockEpetra_Map.hpp>
42 #include <lifev/navier_stokes_blocks/solver/NavierStokesPreconditionerOperator.hpp>
43 
44 #include <lifev/core/array/MatrixEpetra.hpp>
45 #include <lifev/core/linear_algebra/ApproximatedInvertibleRowMatrix.hpp>
46 #include <Teuchos_ParameterList.hpp>
47 #include <Teuchos_XMLParameterListHelpers.hpp>
48 
49 #include <lifev/core/array/VectorEpetra.hpp>
50 #include <lifev/core/array/MapEpetra.hpp>
51 
52 
53 
54 #ifndef _aSIMPLEOPERATOR_H_
55 #define _aSIMPLEOPERATOR_H_ 1
56 
57 namespace LifeV
58 {
59 namespace Operators
60 {
61 
62 class aSIMPLEOperator: public NavierStokesPreconditionerOperator
63 {
64 public:
65  //! @name Public Types
66  //@{
67 
68  typedef Epetra_MultiVector vector_Type;
69  typedef std::shared_ptr<vector_Type> vectorPtr_Type;
70  typedef Epetra_Map map_Type;
71  typedef std::shared_ptr<map_Type> mapPtr_Type;
72  typedef LinearOperatorAlgebra super;
73  typedef Epetra_CrsMatrix matrix_Type;
74  typedef std::shared_ptr<matrix_Type> matrixPtr_Type;
75  typedef MatrixEpetra<Real> matrixEpetra_Type;
76  typedef std::shared_ptr<matrixEpetra_Type> matrixEpetraPtr_Type;
77  typedef Epetra_Vector lumpedMatrix_Type;
78  typedef std::shared_ptr<lumpedMatrix_Type> lumpedMatrixPtr_Type;
79  typedef super::comm_Type comm_Type;
80  typedef super::commPtr_Type commPtr_Type;
81  typedef std::shared_ptr<Teuchos::ParameterList> parameterListPtr_Type;
82  typedef MapEpetra mapEpetra_Type;
83  typedef std::shared_ptr<mapEpetra_Type> mapEpetraPtr_Type;
84  typedef VectorEpetra VectorEpetra_Type;
85  typedef std::shared_ptr<VectorEpetra_Type> VectorEpetraPtr_Type;
86  //@}
87 
88  //! @name Constructors and Destructors
89  //@{
90 
91  //! Empty constructor
92  aSIMPLEOperator();
93 
94  //! Destructor
95  virtual ~aSIMPLEOperator();
96 
97  //@}
98 
99  //! @name SetUp
100  //@{
101 
102  //! SetUp - case without stabilization
103  /*!
104  * @param F block(0,0) of NS matrix
105  * @param B block(1,0) of NS matrix
106  * @param Btranspose block(0,1) of NS matrix
107  */
108  void setUp(const matrixEpetraPtr_Type & F,
109  const matrixEpetraPtr_Type & B,
110  const matrixEpetraPtr_Type & Btranspose);
111 
112  //! SetUp - case with stabilization
113  /*!
114  * @param F block(0,0) of NS matrix
115  * @param B block(1,0) of NS matrix
116  * @param Btranspose block(0,1) of NS matrix
117  * @param D block(1,1) of NS matrix
118  */
119  void setUp ( const matrixEpetraPtr_Type & F,
120  const matrixEpetraPtr_Type & B,
121  const matrixEpetraPtr_Type & Btranspose,
122  const matrixEpetraPtr_Type & D );
123 
124 
125  //! @name Setters
126  //@{
127 
128  //! \warning Transpose of this operator is not supported
129  int SetUseTranspose(bool UseTranspose){M_useTranspose = UseTranspose; return 0;}
130 
131  //! set the domain map
132  void setDomainMap(const std::shared_ptr<BlockEpetra_Map> & domainMap){M_operatorDomainMap = domainMap;}
133 
134  //! set the range map
135  void setRangeMap(const std::shared_ptr<BlockEpetra_Map> & rangeMap){M_operatorRangeMap = rangeMap;}
136 
137  //! Set the momentum preconditioner options
138  void setMomentumOptions(const parameterListPtr_Type & _oList);
139 
140  //! Set the Schur Complement preconditioner options
141  void setSchurOptions(const parameterListPtr_Type & _oList);
142 
143  //@}
144 
145 
146  //! @name Methods
147  //@{
148 
149  //! \warning No method \c Apply defined for this operator. It return an error code.
150  int Apply(const vector_Type &/*X*/, vector_Type &/*Y*/) const {return -1;};
151 
152  //! Returns the High Order Yosida approximation of the inverse pressure Schur Complement applied to \c (Xu, Xp).
153  int ApplyInverse( VectorEpetra_Type const& X_velocity,
154  VectorEpetra_Type const& X_pressure,
155  VectorEpetra_Type & Y_velocity,
156  VectorEpetra_Type & Y_pressure) const;
157 
158  //! Returns the High Order Yosida approximation of the inverse pressure Schur Complement applied to \c X.
159  int ApplyInverse(const vector_Type &X, vector_Type &Y) const;
160 
161  //! \warning Infinity norm not defined for this operator
162  double NormInf() const {return -1.0;}
163 
164  //! Updates the momentum preconditioner operator
165  void updateApproximatedMomentumOperator();
166 
167  //! Updates the Schur Complement preconditioner operator
168  void updateApproximatedSchurComplementOperator();
169 
170  //@}
171 
172  // @name Attribute access functions
173  //@{
174  //! Return a character string describing the operator
175  const char * Label() const {return M_label.c_str();}
176  //! Return the current UseTranspose setting \warning Not Supported Yet.
177  bool UseTranspose() const {return M_useTranspose;}
178  //! Return false.
179  bool HasNormInf() const {return false;}
180  //! return a reference to the Epetra_Comm communicator associated with this operator
181  const comm_Type & Comm() const {return *M_comm;}
182  //! Returns the Epetra_Map object associated with the domain of this operator
183  const map_Type & OperatorDomainMap() const {return *(M_operatorDomainMap->monolithicMap());}
184  //! Returns the Epetra_Map object associated with the range of this operator
185  const map_Type & OperatorRangeMap() const {return *(M_operatorRangeMap->monolithicMap());}
186  //@}
187 
188  //! @name Getters
189  //@{
190 
191  //! Show information about the class
192  void showMe();
193 
194  //! Return the list of options being used
195  void setOptions(const Teuchos::ParameterList& solversOptions);
196 
197  //! Return the block(0,0)
198  matrixEpetraPtr_Type const& F() const { return M_F; }
199 
200  //! Return the block(0,1)
201  matrixEpetraPtr_Type const& B() const { return M_B; }
202 
203  //! Return the block(1,0)
204  matrixEpetraPtr_Type const& Btranspose() const { return M_Btranspose; }
205 
206  //@}
207 
208 private:
209 
210  //! Create the domain and the range maps
211  void setMaps();
212 
213  //! create the matrix B*diag(F)^-1*Btranspose
214  void buildShurComplement();
215 
216  std::shared_ptr<BlockEpetra_Map> M_operatorDomainMap;
217  //! Range Map
218  std::shared_ptr<BlockEpetra_Map> M_operatorRangeMap;
219 
220  matrixEpetraPtr_Type M_F;
221 
222  matrixEpetraPtr_Type M_B;
223 
224  matrixEpetraPtr_Type M_Btranspose;
225 
226  matrixEpetraPtr_Type M_D;
227 
228  matrixEpetraPtr_Type M_schurComplement;
229 
230  //! Communicator
231  commPtr_Type M_comm;
232 
233  bool M_useTranspose;
234 
235  std::shared_ptr<Operators::ApproximatedInvertibleRowMatrix> M_approximatedMomentumOperator;
236 
237  std::shared_ptr<Operators::ApproximatedInvertibleRowMatrix> M_approximatedSchurComplementOperator;
238 
239  parameterListPtr_Type M_momentumOptions;
240 
241  parameterListPtr_Type M_schurOptions;
242 
243  mapEpetraPtr_Type M_monolithicMap;
244 
245  std::shared_ptr<Epetra_Vector> M_invD;
246 
247  matrixEpetraPtr_Type M_DBT;
248 
249  //! Label
250  const std::string M_label;
251 
252  //! Vectors needed for the apply inverse
253  std::shared_ptr<VectorEpetra_Type> M_Z;
254 
255  std::shared_ptr<VectorEpetra_Type> M_X_velocity;
256  std::shared_ptr<VectorEpetra_Type> M_X_pressure;
257  std::shared_ptr<VectorEpetra_Type> M_Y_velocity;
258  std::shared_ptr<VectorEpetra_Type> M_Y_pressure;
259 
260  std::shared_ptr<mapEpetra_Type> M_domainDBT;
261  std::shared_ptr<mapEpetra_Type> M_rangeDBT;
262 
263  bool M_useStabilization;
264 
265 };
266 
267 //! Factory create function
268 inline NavierStokesPreconditionerOperator * create_aSIMPLE()
269 {
270  return new aSIMPLEOperator ();
271 }
272 namespace
273 {
275 }
276 
277 } /* end namespace Operators */
278 } //end namespace
279 #endif
VectorEpetra - The Epetra Vector format Wrapper.
void importFromHDF5(std::string const &fileName, std::string const &matrixName="matrix")
Read a matrix from a HDF5 (.h5) file.
Abstract class which defines the interface of a Linear Operator.
void updateInverseJacobian(const UInt &iQuadPt)
Epetra_Import const & importer()
Getter for the Epetra_Import.
Definition: MapEpetra.cpp:394
double Real
Generic real data.
Definition: LifeV.hpp:175