DOLFIN
DOLFIN C++ interface
Ifpack2Preconditioner.h
1 // Copyright (C) 2014 Chris Richardson
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 
19 #ifndef __DOLFIN_IFPACK2_PRECONDITIONER_H
20 #define __DOLFIN_IFPACK2_PRECONDITIONER_H
21 
22 #ifdef HAS_TRILINOS
23 
24 #include <map>
25 #include <memory>
26 #include <Ifpack2_Factory.hpp>
27 #include <dolfin/common/types.h>
28 #include "TpetraMatrix.h"
29 #include "TpetraVector.h"
30 #include "TrilinosPreconditioner.h"
31 
32 namespace dolfin
33 {
34 
36  class BelosKrylovSolver;
37 
39 
41  {
42 
43  public:
44 
46  explicit Ifpack2Preconditioner(std::string type = "default");
47 
49  virtual ~Ifpack2Preconditioner();
50 
52  virtual void set(BelosKrylovSolver& solver);
53 
55  std::string str(bool verbose) const;
56 
58  virtual void init(std::shared_ptr<const TpetraMatrix> P);
59 
61  static std::map<std::string, std::string> preconditioners();
62 
65 
66  private:
67 
68  // name of preconditioner
69  std::string _name;
70 
71  typedef Ifpack2::Preconditioner<double, int, dolfin::la_index,
72  TpetraVector::node_type> prec_type;
73 
74  // Ifpack2 preconditioner, to be constructed from a
75  // Tpetra Operator or Matrix
76  Teuchos::RCP<prec_type> _prec;
77 
78  };
79 
80 }
81 
82 #endif
83 
84 #endif
Common base class for DOLFIN variables.
Definition: Variable.h:35
Definition: adapt.h:29
This class provides a common base for Trilinos preconditioners.
Definition: TrilinosPreconditioner.h:36
static Parameters default_parameters()
Default parameter values.
Definition: Ifpack2Preconditioner.cpp:87
Tpetra::MultiVector ::node_type node_type
Node type.
Definition: TpetraVector.h:58
Definition: BelosKrylovSolver.h:51
std::string str(bool verbose) const
Return informal string representation (pretty-print)
Definition: Ifpack2Preconditioner.cpp:78
virtual ~Ifpack2Preconditioner()
Destructor.
Definition: Ifpack2Preconditioner.cpp:58
virtual void init(std::shared_ptr< const TpetraMatrix > P)
Initialise preconditioner based on Operator P.
Definition: Ifpack2Preconditioner.cpp:62
Definition: Parameters.h:94
static std::map< std::string, std::string > preconditioners()
Return a list of available preconditioners.
Definition: Ifpack2Preconditioner.cpp:29
Ifpack2Preconditioner(std::string type="default")
Create a particular preconditioner object.
Definition: Ifpack2Preconditioner.cpp:42
PetscInt la_index
Index type for compatibility with linear algebra backend(s)
Definition: types.h:32
Implements preconditioners using Ifpack2 from Trilinos.
Definition: Ifpack2Preconditioner.h:40