petsc_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_PETSC_PRECONDITIONER_H
21 #define LIBMESH_PETSC_PRECONDITIONER_H
22 
23 #include "libmesh/libmesh_config.h"
24 
25 #ifdef LIBMESH_HAVE_PETSC
26 
27 // Local includes
28 #include "libmesh/preconditioner.h"
29 #include "libmesh/libmesh_common.h"
33 #include "libmesh/libmesh.h"
34 #include "libmesh/petsc_macro.h"
35 
36 // Petsc includes
37 EXTERN_C_FOR_PETSC_BEGIN
38 #include "petscpc.h"
39 EXTERN_C_FOR_PETSC_END
40 
41 // C++ includes
42 
43 namespace libMesh
44 {
45 
46 // forward declarations
47 template <typename T> class AutoPtr;
48 template <typename T> class SparseMatrix;
49 template <typename T> class NumericVector;
50 template <typename T> class ShellMatrix;
51 
59 template <typename T>
61 {
62 public:
63 
68  LIBMESH_CAN_DEFAULT_TO_COMMWORLD);
69 
73  virtual ~PetscPreconditioner ();
74 
79  virtual void apply(const NumericVector<T> & x, NumericVector<T> & y);
80 
84  virtual void clear ();
85 
89  virtual void init ();
90 
95  PC pc() { return _pc; }
96 
100  static void set_petsc_preconditioner_type (const PreconditionerType & preconditioner_type, PC & pc);
101 
102 protected:
103 
107  PC _pc;
108 
113  Mat _mat;
114 
115 private:
123 #if PETSC_VERSION_LESS_THAN(3,0,0)
124  // In Petsc 2.3.3, PCType was #define'd as const char*
125  static void set_petsc_subpreconditioner_type(PCType type, PC& pc);
126 #else
127  // In later versions, PCType is #define'd as char*, so we need the const
128  static void set_petsc_subpreconditioner_type(const PCType type, PC& pc);
129 #endif
130 };
131 
132 
133 
134 
135 /*----------------------- inline functions ----------------------------------*/
136 template <typename T>
137 inline
139  Preconditioner<T>(comm),
140  _pc(PETSC_NULL)
141 {
142 }
143 
144 
145 
146 template <typename T>
147 inline
149 {
150  this->clear ();
151 }
152 
153 } // namespace libMesh
154 
155 #endif // #ifdef LIBMESH_HAVE_PETSC
156 #endif // LIBMESH_PETSC_PRECONDITIONER_H

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

Hosted By:
SourceForge.net Logo