DOLFIN
DOLFIN C++ interface
Loading...
Searching...
No Matches
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
35namespace dolfin
36{
37
38 // Forward declarations
39 class PETScKrylovSolver;
40 class PETScSNESSolver;
41 class VectorSpaceBasis;
42
47
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
70
76 static void set_fieldsplit(PETScKrylovSolver& solver,
77 const std::vector<std::vector<dolfin::la_index>>& fields,
78 const std::vector<std::string>& split_names);
79
82 std::string str(bool verbose) const;
83
85 static std::map<std::string, std::string> preconditioners();
86
87 friend class PETScSNESSolver;
88 friend class PETScTAOSolver;
89
90 private:
91
92 // Named preconditioner
93 std::string _type;
94
95 // Available names preconditioners
96 static const std::map<std::string, const PCType> _methods;
97
98 // Available preconditioner descriptions
99 static const std::map<std::string, std::string>
100 _methods_descr;
101
102 // Operator row coordinates
103 std::vector<double> _coordinates;
104
105 // Geometric dimension associates with coordinates
106 std::size_t gdim;
107
108 };
109
110}
111
112#endif
113
114#endif
Definition PETScKrylovSolver.h:55
Definition PETScObject.h:34
Definition PETScPreconditioner.h:49
static 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
virtual ~PETScPreconditioner()
Destructor.
Definition PETScPreconditioner.cpp:131
std::string str(bool verbose) const
Definition PETScPreconditioner.cpp:254
static std::map< std::string, std::string > preconditioners()
Return a list of available preconditioners.
Definition PETScPreconditioner.cpp:80
static void set_type(PETScKrylovSolver &solver, std::string type)
Select type by name.
Definition PETScPreconditioner.cpp:85
virtual void set(PETScKrylovSolver &solver)
Set the preconditioner type and parameters.
Definition PETScPreconditioner.cpp:136
Definition PETScSNESSolver.h:46
Definition PETScTAOSolver.h:52
Common base class for DOLFIN variables.
Definition Variable.h:36
Definition adapt.h:30