LifeV
Preconditioner.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 Epetra preconditioner
30 
31  @author Simone Deparis <simone.deparis@epfl.ch>
32  @contributor Gwenol Grandperrin <gwenol.grandperrin@epfl.ch>
33  @maintainer Gwenol Grandperrin <gwenol.grandperrin@epfl.ch>
34 
35  @date 09-11-2006
36  */
37 
38 #ifndef _EPETRAPRECONDITIONER_HPP_
39 #define _EPETRAPRECONDITIONER_HPP_
40 
41 
42 
43 #include <Teuchos_ParameterList.hpp>
44 
45 
46 #include <lifev/core/LifeV.hpp>
47 
48 #include <lifev/core/util/Factory.hpp>
49 #include <lifev/core/util/FactorySingleton.hpp>
50 #include <lifev/core/filter/GetPot.hpp>
51 #include <lifev/core/util/Displayer.hpp>
52 #include <lifev/core/array/MatrixEpetra.hpp>
53 
54 namespace LifeV
55 {
56 
57 // Forward declaration
58 class SolverAztecOO;
59 
60 //! Preconditioner - Abstract preconditioner class
61 /*!
62  @author Simone Deparis <simone.deparis@epfl.ch>
63 */
65 {
66 public:
67 
68  //! @name Public Types
69  //@{
70 
73 
76 
77  typedef Displayer::comm_Type comm_Type;
78  typedef Displayer::commPtr_Type commPtr_Type;
79 
81 
82  //@}
83 
84 
85  //! @name Constructors & Destructor
86  //@{
87 
88  //! Constructor
89  /*!
90  @param comm Comminicator
91  */
92  Preconditioner ( const commPtr_Type& comm = commPtr_Type() );
93 
94  //! Copy constructor
95  /*!
96  @param preconditioner Preconditioner
97  @param comm Comminicator
98  */
99  Preconditioner ( const Preconditioner& preconditioner, const commPtr_Type& comm = commPtr_Type() );
100 
101  //! Destructor
102  virtual ~Preconditioner();
103 
104  //@}
105 
106 
107  //! @name Methods
108  //@{
109 
110  //! Create the list of parameters of the preconditioner
111  /*!
112  @param list A Parameter list to be filled
113  @param dataFile A GetPot object containing the data about the preconditioner
114  @param section The section in "dataFile" where to find data about the preconditioner
115  @param subSection The subsection in "dataFile" where to find data about the preconditioner
116  */
117  virtual void createParametersList ( list_Type& list,
118  const GetPot& dataFile,
119  const std::string& section,
120  const std::string& subSection ) = 0;
121 
122  //! Build a preconditioner based on the given matrix
123  /*!
124  @param matrix Matrix upon which construct the preconditioner
125  */
126  virtual Int buildPreconditioner ( operator_type& matrix ) = 0;
127 
128  //! Reset the preconditioner
129  virtual void resetPreconditioner() = 0;
130 
131  //! Return An estimation of the condition number of the preconditioner
132  virtual Real condest() = 0;
133 
134  //! Show informations about the preconditioner
135  virtual void showMe ( std::ostream& output = std::cout ) const;
136 
137  //@}
138 
139 
140  //! @name Epetra Operator Interface Methods
141  //@{
142 
143  //! Set the matrix to be used transposed (or not)
144  /*!
145  @param useTranspose If true the preconditioner is transposed
146  */
147  virtual Int SetUseTranspose ( const bool useTranspose = false );
148 
149  //! Return true if the preconditioner is transposed
150  virtual bool UseTranspose();
151 
152  //! Apply the inverse of the preconditioner on vector1 and store the result in vector2
153  /*!
154  @param vector1 Vector to which we apply the preconditioner
155  @param vector2 Vector to the store the result
156  */
157  virtual Int Apply ( const Epetra_MultiVector& vector1, Epetra_MultiVector& vector2 ) const;
158 
159  //! Apply the inverse of the preconditioner on vector1 and store the result in vector2
160  /*!
161  @param vector1 Vector to which we apply the preconditioner
162  @param vector2 Vector to the store the result
163  */
164  virtual Int ApplyInverse ( const Epetra_MultiVector& vector1, Epetra_MultiVector& vector2 ) const;
165 
166 
167  //! Return the Range map of the operator
168  virtual const Epetra_Map& OperatorRangeMap() const;
169 
170  //! Return the Domain map of the operator
171  virtual const Epetra_Map& OperatorDomainMap() const;
172  //@}
173 
174 
175  //! @name Set Methods
176  //@{
177 
178  //! The the internal list
179  /*!
180  @param list List to be set into the preconditioner
181  */
182  void setParametersList ( const list_Type& list );
183 
184  //! Set the data of the preconditioner using a GetPot object
185  /*!
186  @param dataFile A GetPot object containing the data about the preconditioner
187  @param section The section in "dataFile" where to find data about the preconditioner
188  */
189  virtual void setDataFromGetPot ( const GetPot& dataFile, const std::string& section ) = 0;
190 
191  //! Set the internal solver
192  /*!
193  Note: the argument is unused
194  @param solver SolverAztecOO
195  */
196  virtual void setSolver ( SolverAztecOO& /*solver*/ );
197 
198  //@}
199 
200 
201  //! @name Get Methods
202  //@{
203 
204  //! Return true if the preconditioner has been created
205  const bool& preconditionerCreated();
206 
207  //! Return a raw pointer on the preconditioner
208  virtual prec_raw_type* preconditioner() = 0;
209 
210  //! Return a shared pointer on the preconditioner
211  virtual prec_type preconditionerPtr() = 0;
212 
213  //! Return the type of preconditioner
214  virtual std::string preconditionerType() = 0;
215 
216  //! Return the parameters list
217  const list_Type& parametersList() const;
218 
219  //! Return the parameters list
221 
222  //@}
223 
224 protected:
225 
226  std::string M_precType;
230 
231 };
232 
234 
235 } // namespace LifeV
236 
237 #endif
virtual Int Apply(const Epetra_MultiVector &vector1, Epetra_MultiVector &vector2) const
Apply the inverse of the preconditioner on vector1 and store the result in vector2.
virtual const Epetra_Map & OperatorRangeMap() const
Return the Range map of the operator.
const bool & preconditionerCreated()
Return true if the preconditioner has been created.
virtual void setDataFromGetPot(const GetPot &dataFile, const std::string &section)=0
Set the data of the preconditioner using a GetPot object.
SolverAztecOO - Class to wrap linear solver.
virtual void createParametersList(list_Type &list, const GetPot &dataFile, const std::string &section, const std::string &subSection)=0
Create the list of parameters of the preconditioner.
void importFromHDF5(std::string const &fileName, std::string const &matrixName="matrix")
Read a matrix from a HDF5 (.h5) file.
std::shared_ptr< comm_Type > commPtr_Type
Definition: Displayer.hpp:70
int32_type Int
Generic integer data.
Definition: LifeV.hpp:188
virtual void showMe(std::ostream &output=std::cout) const
Show informations about the preconditioner.
virtual void setSolver(SolverAztecOO &)
Set the internal solver.
virtual Real condest()=0
Return An estimation of the condition number of the preconditioner.
void updateInverseJacobian(const UInt &iQuadPt)
const list_Type & parametersList() const
Return the parameters list.
Epetra_Comm comm_Type
Definition: Displayer.hpp:69
virtual std::string preconditionerType()=0
Return the type of preconditioner.
virtual prec_raw_type * preconditioner()=0
Return a raw pointer on the preconditioner.
Epetra_Operator prec_raw_type
virtual Int SetUseTranspose(const bool useTranspose=false)
Set the matrix to be used transposed (or not)
void setParametersList(const list_Type &list)
The the internal list.
Preconditioner(const Preconditioner &preconditioner, const commPtr_Type &comm=commPtr_Type())
Copy constructor.
MatrixEpetra< Real > operator_raw_type
list_Type & parametersList()
Return the parameters list.
virtual Int ApplyInverse(const Epetra_MultiVector &vector1, Epetra_MultiVector &vector2) const
Apply the inverse of the preconditioner on vector1 and store the result in vector2.
Preconditioner(const commPtr_Type &comm=commPtr_Type())
Constructor.
double Real
Generic real data.
Definition: LifeV.hpp:175
Teuchos::ParameterList list_Type
Preconditioner - Abstract preconditioner class.
virtual Int buildPreconditioner(operator_type &matrix)=0
Build a preconditioner based on the given matrix.
std::shared_ptr< prec_raw_type > prec_type
FactorySingleton< Factory< Preconditioner, std::string > > PRECFactory
virtual ~Preconditioner()
Destructor.
virtual const Epetra_Map & OperatorDomainMap() const
Return the Domain map of the operator.
virtual bool UseTranspose()
Return true if the preconditioner is transposed.
virtual void resetPreconditioner()=0
Reset the preconditioner.
std::shared_ptr< operator_raw_type > operator_type
Displayer - This class is used to display messages in parallel simulations.
Definition: Displayer.hpp:62
virtual prec_type preconditionerPtr()=0
Return a shared pointer on the preconditioner.