LifeV
PreconditionerPCD.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 PreconditionerPCD
30 
31  @author Gwenol Grandperrin <gwenol.grandperrin@epfl.ch>
32  @maintainer Gwenol Grandperrin <gwenol.grandperrin@epfl.ch>
33 
34  @date 29-11-2010
35  */
36 
37 #ifndef PRECONDITIONERPCD_HPP
38 #define PRECONDITIONERPCD_HPP 1
39 
40 #include <boost/shared_ptr.hpp>
41 
42 #include <Teuchos_ParameterList.hpp>
43 
44 #include <lifev/core/filter/GetPot.hpp>
45 #include <lifev/core/array/MatrixEpetra.hpp>
46 #include <lifev/core/array/VectorEpetra.hpp>
47 #include <lifev/core/algorithm/PreconditionerComposition.hpp>
48 #include <lifev/core/array/MatrixEpetraStructured.hpp>
49 #include <lifev/core/solver/ADRAssembler.hpp>
50 #include <lifev/core/fem/FESpace.hpp>
51 #include <lifev/core/fem/BCBase.hpp>
52 #include <lifev/core/mesh/RegionMesh.hpp>
53 
54 namespace LifeV
55 {
56 
57 //! PreconditionerPCD
58 /*!
59  * @author Gwenol Grandperrin
60  *
61  * The PreconditionerPCD class provides the PCD block preconditioner
62  */
65 {
66 public:
67 
68  /** @name Public Types
69  */
70  //@{
79 
82 
83  typedef ComposedOperator<Preconditioner> preconditioner_Type;
85 
88 
90  //@}
91 
92 
93  //! @name Constructors, destructor
94  //@{
95  //! default constructor
96 #ifdef HAVE_MPI
98 #else
99  PreconditionerPCD ( std::shared_ptr<Epetra_Comm> comm = std::shared_ptr<Epetra_Comm> ( new Epetra_SerialComm ) );
100 #endif
101 
102  //! constructor from matrix A.
103  //! @param A EpetraMatrix<double> matrix upon which construct the preconditioner
104  // IfpackPreconditioner( matrixPtr_type& A );
105 
106  //! default destructor
107  virtual ~PreconditionerPCD();
108 
109  //@}
110 
111  //! @name Methods
112  //@{
113  void createParametersList ( list_Type& list,
114  const GetPot& dataFile,
115  const std::string& section,
116  const std::string& subsection = "PCD" );
117 
118  //! Return an estimation of the conditionement number of the preconditioner
119  double condest ();
120 
121  //! Update the vector beta of the convective term in Fp
122  /*!
123  This method updates the value of beta.
124  @param beta New vector beta to be used to built the convective term
125  */
126  void updateBeta ( const vector_Type& beta );
127 
128 
129  //! Build the preconditioner
131 
132  //@}
133 
134  //! @name Get Methods
135  //@{
136  int numBlocksRows() const;
137  int numBlocksColumns() const;
138  //@}
139 
140  //! @name Set Methods
141  //@{
142  //! Setter using GetPot
143  /*!
144  This method use GetPot to load data from a file and then set
145  the preconditioner.
146  @param dataFile is a GetPot dataFile
147  @param section is the section containing the data
148  */
149  void setDataFromGetPot ( const GetPot& dataFile,
150  const std::string& section );
151 
152  //! Method to setup the solver using Teuchos::ParameterList
153  /*!
154  @param list Teuchos::ParameterList object
155  */
156  virtual void setParameters ( Teuchos::ParameterList& list );
157 
158  //! Setter for the FESpace
159  /*!
160  This method set the pointer for the FESpaces needed
161  for the construction of the operators Ap, Fp and Mp.
162  @param uFESpace std::shared_ptr on the FESpace for the velocity
163  @param pFESpace std::shared_ptr on the FESpace for the pressure
164  */
165  void setFESpace ( FESpacePtr_Type uFESpace, FESpacePtr_Type pFESpace );
166 
167  //! Setter for the BCHandler
168  /*!
169  This method set the pointer for the FESpaces needed
170  for the construction of the operators Ap, Fp and Mp.
171  @param bchPtr pointer to a BCHandler boject
172  */
173  void setBCHandler ( BCHandlerPtr_Type bchPtr );
174 
175  //! Setter for the timestep
176  /*!
177  This method set the timestep used to compute Fp.
178  @param timestep Timestep used to compute the solution of the Navier-Stokes equations
179  */
180  void setTimestep ( const Real& timestep );
181 
182  //! Setter for the viscosity
183  /*!
184  This method set the viscosity used to compute Fp.
185  @param viscosity Viscosity used to compute the solution of the Navier-Stokes equations
186  */
187  void setViscosity ( const Real& viscosity );
188 
189  //! Setter for the density
190  /*!
191  This method set the density used to compute Fp.
192  @param density Density used to compute the solution of the Navier-Stokes equations
193  */
194  void setDensity ( const Real& density );
195 
196  //! Setter to know if we used B or -B in the discretization of the Navier-Stokes equations
197  /*!
198  @param useMinusDivergence is true if -B has been used.
199  */
200  void setUseMinusDivergence ( const bool& useMinusDivergence );
201 
202  //@}
203 
204 protected:
205 
210 
215 
218 
219  // todo: Remove the member dataFile (bad programmation)
222  std::string M_fluidPrec;
226  std::string M_pressureMassPrec;
239 
240  std::string M_inflowBoundaryType;
243 
245 
246 private:
250 
251  void computeNormalVectors();
252 
254 
255  static Real fZero ( const Real& /* t */,
256  const Real& /* x */,
257  const Real& /* y */,
258  const Real& /* z */,
259  const ID& /* i */ )
260  {
261  return 0.0;
262  }
263 
264  void setBCByBoundaryType ( matrixPtr_type Ap, UInt ApOffset,
265  matrixPtr_type Fp, UInt FpOffset,
266  matrixPtr_type Mp, UInt MpOffset );
267 
268 };
269 
271 {
272  return new PreconditionerPCD();
273 }
274 namespace
275 {
277 }
278 
279 } // namespace LifeV
280 
281 #endif /* PRECONDITIONERPCD_HPP */
VectorEpetra - The Epetra Vector format Wrapper.
MatrixEpetraStructured< Real > matrixBlock_Type
PreconditionerPCD(std::shared_ptr< Epetra_Comm > comm=std::shared_ptr< Epetra_Comm >(new Epetra_MpiComm(MPI_COMM_WORLD)))
default constructor
std::shared_ptr< vector_Type > vectorPtr_Type
virtual void setParameters(Teuchos::ParameterList &list)
Method to setup the solver using Teuchos::ParameterList.
std::shared_ptr< BCHandler > BCHandlerPtr_Type
double condest()
Return an estimation of the conditionement number of the preconditioner.
void importFromHDF5(std::string const &fileName, std::string const &matrixName="matrix")
Read a matrix from a HDF5 (.h5) file.
void setFESpace(FESpacePtr_Type uFESpace, FESpacePtr_Type pFESpace)
Setter for the FESpace.
void updateInverseJacobian(const UInt &iQuadPt)
void setDataFromGetPot(const GetPot &dataFile, const std::string &section)
Setter using GetPot.
RegionMesh< LinearTetra > mesh_Type
BCHandlerPtr_Type M_bcHandlerPtr
int buildPreconditioner(matrixPtr_type &A)
Build the preconditioner.
Preconditioner * createPCD()
PreconditionerComposition(std::shared_ptr< Epetra_Comm > comm=std::shared_ptr< Epetra_Comm >(new Epetra_MpiComm(MPI_COMM_WORLD)))
Constructor.
void setUseMinusDivergence(const bool &useMinusDivergence)
Setter to know if we used B or -B in the discretization of the Navier-Stokes equations.
Epetra_Import const & importer()
Getter for the Epetra_Import.
Definition: MapEpetra.cpp:394
std::shared_ptr< matrix_Type > matrixPtr_type
uint32_type ID
IDs.
Definition: LifeV.hpp:194
ADRAssembler< mesh_Type, matrixBlock_Type, vector_Type > M_adrVelocityAssembler
void setTimestep(const Real &timestep)
Setter for the timestep.
PreconditionerPCD(const PreconditionerPCD &P)
virtual ~PreconditionerPCD()
constructor from matrix A.
void setBCByBoundaryType(matrixPtr_type Ap, UInt ApOffset, matrixPtr_type Fp, UInt FpOffset, matrixPtr_type Mp, UInt MpOffset)
void setBCHandler(BCHandlerPtr_Type bchPtr)
Setter for the BCHandler.
std::shared_ptr< FESpace< mesh_Type, map_Type > > FESpacePtr_Type
vectorPtr_Type computeRobinCoefficient()
MatrixEpetraStructuredView - class representing a block in a MatrixEpetraStructured.
double Real
Generic real data.
Definition: LifeV.hpp:175
Preconditioner - Abstract preconditioner class.
void createParametersList(list_Type &list, const GetPot &dataFile, const std::string &section, const std::string &subsection="PCD")
Create the list of parameters of the preconditioner.
void setViscosity(const Real &viscosity)
Setter for the viscosity.
void setDensity(const Real &density)
Setter for the density.
ADRAssembler< mesh_Type, matrixBlock_Type, vector_Type > M_adrPressureAssembler
MatrixEpetraStructured - class of block matrix.
MatrixEpetra< Real > matrix_Type
static Real fZero(const Real &, const Real &, const Real &, const Real &, const ID &)
Teuchos::ParameterList list_Type
PreconditionerPCD(const std::shared_ptr< PreconditionerPCD > &)
std::shared_ptr< super_Type > superPtr_Type
void updateBeta(const vector_Type &beta)
Update the vector beta of the convective term in Fp.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
std::shared_ptr< preconditioner_Type > preconditionerPtr_Type
ComposedOperator< Preconditioner > preconditioner_Type
std::string M_pressureLaplacianPrecDataSection
MatrixEpetraStructuredView< Real > matrixBlockView_Type