DOLFIN
DOLFIN C++ interface
PETScPreconditioner.h
1 // Copyright (C) 2010-2016 Garth N. Wells
2 //
3 // This file is part of DOLFIN.
4 //
5 // DOLFIN is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // DOLFIN is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // Modified by Anders Logg 2011
19 
20 #ifndef __DOLFIN_PETSC_PRECONDITIONER_H
21 #define __DOLFIN_PETSC_PRECONDITIONER_H
22 
23 #ifdef HAS_PETSC
24 
25 #include <memory>
26 #include <string>
27 #include <vector>
28 #include <petscpc.h>
29 
30 #include <dolfin/common/types.h>
31 #include <dolfin/common/Variable.h>
32 #include <dolfin/la/PETScObject.h>
33 #include <dolfin/parameter/Parameters.h>
34 
35 namespace dolfin
36 {
37 
38  // Forward declarations
39  class PETScKrylovSolver;
40  class PETScSNESSolver;
41  class VectorSpaceBasis;
42 
47 
48  class PETScPreconditioner : public PETScObject, public Variable
49  {
50  public:
51 
53  static void set_type(PETScKrylovSolver& solver, std::string type);
54 
56  explicit PETScPreconditioner(std::string type = "default");
57 
59  virtual ~PETScPreconditioner();
60 
62  virtual void set(PETScKrylovSolver& solver);
63 
68  void set_coordinates(const std::vector<double>& x, std::size_t dim);
69 
75  void
77  const std::vector<std::vector<dolfin::la_index>>& fields,
78  const std::vector<std::string>& split_names);
79 
81  std::string str(bool verbose) const;
82 
84  static std::map<std::string, std::string> preconditioners();
85 
86  friend class PETScSNESSolver;
87  friend class PETScTAOSolver;
88 
89  private:
90 
91  // Named preconditioner
92  std::string _type;
93 
94  // Available names preconditioners
95  static const std::map<std::string, const PCType> _methods;
96 
97  // Available preconditioner descriptions
98  static const std::map<std::string, std::string>
99  _methods_descr;
100 
101  // Operator row coordinates
102  std::vector<double> _coordinates;
103 
104  // Geometric dimension associates with coordinates
105  std::size_t gdim;
106 
107  };
108 
109 }
110 
111 #endif
112 
113 #endif
Common base class for DOLFIN variables.
Definition: Variable.h:35
void set_fieldsplit(PETScKrylovSolver &solver, const std::vector< std::vector< dolfin::la_index >> &fields, const std::vector< std::string > &split_names)
Definition: PETScPreconditioner.cpp:218
void set_coordinates(const std::vector< double > &x, std::size_t dim)
Definition: PETScPreconditioner.cpp:211
Definition: adapt.h:29
static void set_type(PETScKrylovSolver &solver, std::string type)
Select type by name.
Definition: PETScPreconditioner.cpp:85
Definition: PETScKrylovSolver.h:54
Definition: PETScPreconditioner.h:48
Definition: PETScTAOSolver.h:51
PETScPreconditioner(std::string type="default")
Create a particular preconditioner object.
Definition: PETScPreconditioner.cpp:117
static std::map< std::string, std::string > preconditioners()
Return a list of available preconditioners.
Definition: PETScPreconditioner.cpp:80
Definition: PETScSNESSolver.h:45
virtual ~PETScPreconditioner()
Destructor.
Definition: PETScPreconditioner.cpp:131
std::string str(bool verbose) const
Return informal string representation (pretty-print)
Definition: PETScPreconditioner.cpp:254
Definition: PETScObject.h:33