preconditioner.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_PRECONDITIONER_H
21 #define LIBMESH_PRECONDITIONER_H
22 
23 
24 // Local includes
25 #include "libmesh/libmesh_common.h"
30 #include "libmesh/libmesh.h"
32 
33 // C++ includes
34 #include <cstddef>
35 
36 namespace libMesh
37 {
38 
39 // forward declarations
40 template <typename T> class AutoPtr;
41 template <typename T> class SparseMatrix;
42 template <typename T> class NumericVector;
43 template <typename T> class ShellMatrix;
44 
45 
46 
47 
48 
61 template <typename T>
62 class Preconditioner : public ReferenceCountedObject<Preconditioner<T> >,
63  public ParallelObject
64 {
65 public:
66 
71 
75  virtual ~Preconditioner ();
76 
81  static Preconditioner<T> * build(const libMesh::Parallel::Communicator &comm
82  LIBMESH_CAN_DEFAULT_TO_COMMWORLD,
83  const SolverPackage solver_package = libMesh::default_solver_package());
84 
89  bool initialized () const { return _is_initialized; }
90 
95  virtual void apply(const NumericVector<T> & x, NumericVector<T> & y) = 0;
96 
100  virtual void clear () {}
101 
107  virtual void init () {}
108 
114  virtual void setup () {}
115 
119  void set_matrix(SparseMatrix<Number> & mat);
120 
125  { return _preconditioner_type; }
126 
130  void set_type (const PreconditionerType pct);
131 
132 protected:
133 
139 
144 
149 };
150 
151 
152 
153 
154 /*----------------------- inline functions ----------------------------------*/
155 template <typename T>
156 inline
158  ParallelObject(comm_in),
159  _matrix(NULL),
160  _preconditioner_type (ILU_PRECOND),
161  _is_initialized (false)
162 {
163 }
164 
165 
166 
167 template <typename T>
168 inline
170 {
171  this->clear ();
172 }
173 
174 template <typename T>
175 void
177 {
178  //If the matrix is changing then we (probably) need to reinitialize.
179  _is_initialized = false;
180  _matrix = &mat;
181 }
182 
183 template <typename T>
184 void
186 {
187  //If the preconditioner type changes we (probably) need to reinitialize.
188  _is_initialized = false;
189  _preconditioner_type = pct;
190 }
191 
192 } // namespace libMesh
193 
194 
195 #endif // LIBMESH_PRECONDITIONER_H

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:06 UTC

Hosted By:
SourceForge.net Logo