LifeV
PreconditionerIfpack.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 Ifpack 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 _IFPACKPRECONDITIONER_HPP_
39 #define _IFPACKPRECONDITIONER_HPP_
40 
41 
42 
43 #include <Ifpack_ConfigDefs.h>
44 #ifdef HAVE_IFPACK_DYNAMIC_FACTORY
45 #include <Ifpack_DynamicFactory.h>
46 #else
47 #include <Ifpack.h>
48 #endif
49 #include <Ifpack_Preconditioner.h>
50 #include <Ifpack_AdditiveSchwarz.h>
51 #include <Ifpack_Amesos.h>
52 #include <Ifpack_ILU.h>
53 
54 
55 #include <lifev/core/LifeV.hpp>
56 
57 #include <lifev/core/filter/GetPot.hpp>
58 #include <lifev/core/array/MatrixEpetra.hpp>
59 #include <lifev/core/algorithm/Preconditioner.hpp>
60 
61 namespace LifeV
62 {
63 
64 //! PreconditionerIfpack - Class implementing overlapping Schwarz preconditioner
65 /*!
66  @author Simone Deparis <simone.deparis@epfl.ch>
67 */
69  public Preconditioner
70 {
71 public:
72 
73  //! @name Public Types
74  //@{
75 
77 
80 
81  typedef super::operator_raw_type operator_raw_type;
82  typedef super::operator_type operator_type;
83 
84  //@}
85 
86 
87  //! @name Constructors & Destructor
88  //@{
89 
90  //! Empty constructor
91 #ifdef HAVE_MPI
93 #else
94  PreconditionerIfpack ( std::shared_ptr<Epetra_Comm> comm = std::shared_ptr<Epetra_Comm> ( new Epetra_SerialComm ) );
95 #endif
96 
97  //! Destructor
98  virtual ~PreconditionerIfpack();
99 
100  //@}
101 
102 
103  //! @name Methods
104  //@{
105 
106  //! Build a preconditioner based on the given matrix
107  /*!
108  @param matrix Matrix upon which construct the preconditioner
109  */
110  Int buildPreconditioner ( operator_type& matrix );
111 
112  //! Reset the preconditioner
113  void resetPreconditioner();
114 
115  //! Create the list of parameters of the preconditioner
116  /*!
117  @param list A Parameter list to be filled
118  @param dataFile A GetPot object containing the data about the preconditioner
119  @param section The section in "dataFile" where to find data about the preconditioner
120  @param subSection The subsection in "dataFile" where to find data about the preconditioner
121  */
122  virtual void createParametersList ( list_Type& list,
123  const GetPot& dataFile,
124  const std::string& section,
125  const std::string& subSection );
126 
127  //! Create the list of parameters of the preconditioner
128  /*!
129  @param list A Parameter list to be filled
130  @param dataFile A GetPot object containing the data about the preconditioner
131  @param section The section in "dataFile" where to find data about the preconditioner
132  @param subSection The subsection in "dataFile" where to find data about the preconditioner
133  */
134  static void createIfpackList ( list_Type& list,
135  const GetPot& dataFile,
136  const std::string& section,
137  const std::string& subSection = "ifpack",
138  const bool& verbose = true );
139 
140  //! Apply the inverse of the preconditioner on vector1 and store the result in vector2
141  /*!
142  @param vector1 Vector to which we apply the preconditioner
143  @param vector2 Vector to the store the result
144  */
145  virtual Int ApplyInverse ( const Epetra_MultiVector& vector1, Epetra_MultiVector& vector2 ) const;
146 
147  //! Apply the inverse of the preconditioner on vector1 and store the result in vector2
148  /*!
149  @param vector1 Vector to which we apply the preconditioner
150  @param vector2 Vector to the store the result
151  */
152  virtual Int Apply ( const Epetra_MultiVector& vector1, Epetra_MultiVector& vector2 ) const;
153 
154  //! Show informations about the preconditioner
155  virtual void showMe ( std::ostream& output = std::cout ) const;
156 
157  //@}
158 
159 
160  //! @name Set Methods
161  //@{
162 
163  //! Set the data of the preconditioner using a GetPot object
164  /*!
165  @param dataFile A GetPot object containing the data about the preconditioner
166  @param section The section in "dataFile" where to find data about the preconditioner
167  */
168  void setDataFromGetPot ( const GetPot& dataFile,
169  const std::string& section );
170 
171  //! Set the matrix to be used transposed (or not)
172  /*!
173  @param useTranspose If true the preconditioner is transposed
174  */
175  Int SetUseTranspose ( bool useTranspose = false );
176 
177  //@}
178 
179 
180  //! @name Get Methods
181  //@{
182 
183  //! Return An estimation of the condition number of the preconditioner
184  Real condest ();
185 
186  //! Return a raw pointer on the preconditioner
188 
189  //! Return a shared pointer on the preconditioner
191 
192  //! Return the type of preconditioner
193  std::string preconditionerType();
194 
195  //! Return the overlap level
196  const Int& getOverlapLevel() const;
197 
198  //! Return true if the preconditioner is transposed
199  bool UseTranspose();
200 
201  //! Return the Range map of the operator
202  const Epetra_Map& OperatorRangeMap() const;
203 
204  //! Return the Domain map of the operator
205  const Epetra_Map& OperatorDomainMap() const;
206 
207  //@}
208 
209 protected:
210 
213 
214 private:
215 
218 
219 };
220 
221 
223 {
224  return new PreconditionerIfpack();
225 }
226 namespace
227 {
229 }
230 
231 } // namespace LifeV
232 
233 #endif
operator_raw_type::matrix_ptrtype M_operator
std::shared_ptr< prec_raw_type > prec_type
int32_type Int
Generic integer data.
Definition: LifeV.hpp:188
virtual void showMe(std::ostream &output=std::cout) const
Show informations about the preconditioner.
void updateInverseJacobian(const UInt &iQuadPt)
Int buildPreconditioner(operator_type &matrix)
Build a preconditioner based on the given matrix.
static void createIfpackList(list_Type &list, const GetPot &dataFile, const std::string &section, const std::string &subSection="ifpack", const bool &verbose=true)
Create the list of parameters of the preconditioner.
PreconditionerIfpack(std::shared_ptr< Epetra_Comm > comm=std::shared_ptr< Epetra_Comm >(new Epetra_MpiComm(MPI_COMM_WORLD)))
Empty constructor.
Epetra_Operator prec_raw_type
Real condest()
Return An estimation of the condition number of the preconditioner.
Preconditioner * createIfpack()
virtual void createParametersList(list_Type &list, const GetPot &dataFile, const std::string &section, const std::string &subSection)
Create the list of parameters of the preconditioner.
const Epetra_Map & OperatorRangeMap() const
Return the Range map of the operator.
Ifpack_Preconditioner prec_raw_type
std::shared_ptr< Epetra_Comm > M_comm
const Int & getOverlapLevel() const
Return the overlap level.
bool UseTranspose()
Return true if the preconditioner is transposed.
MatrixEpetra< Real > operator_raw_type
super::prec_type preconditionerPtr()
Return a shared pointer on the preconditioner.
virtual ~PreconditionerIfpack()
Destructor.
double Real
Generic real data.
Definition: LifeV.hpp:175
Int SetUseTranspose(bool useTranspose=false)
Set the matrix to be used transposed (or not)
Teuchos::ParameterList list_Type
Preconditioner - Abstract preconditioner class.
const Epetra_Map & OperatorDomainMap() const
Return the Domain map of the operator.
std::shared_ptr< prec_raw_type > prec_type
void resetPreconditioner()
Reset the preconditioner.
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.
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.
void setDataFromGetPot(const GetPot &dataFile, const std::string &section)
Set the data of the preconditioner using a GetPot object.
super::prec_raw_type * preconditioner()
Return a raw pointer on the preconditioner.
std::shared_ptr< operator_raw_type > operator_type
std::string preconditionerType()
Return the type of preconditioner.