DOLFIN
DOLFIN C++ interface
EigenLUSolver.h
1 // Copyright (C) 2015 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 #ifndef __DOLFIN_EIGEN_LU_SOLVER_H
19 #define __DOLFIN_EIGEN_LU_SOLVER_H
20 
21 #include <map>
22 #include <memory>
23 
24 #include <dolfin/common/types.h>
25 #include <Eigen/Dense>
26 #include "GenericLinearSolver.h"
27 
28 namespace dolfin
29 {
31  class EigenMatrix;
32  class EigenVector;
33  class GenericLinearOperator;
34  class GenericVector;
35 
38 
40  {
41  public:
42 
44  EigenLUSolver(std::string method="default");
45 
47  EigenLUSolver(std::shared_ptr<const EigenMatrix> A,
48  std::string method="default");
49 
52 
54  void set_operator(std::shared_ptr<const GenericLinearOperator> A);
55 
57  void set_operator(std::shared_ptr<const EigenMatrix> A);
58 
60  const GenericLinearOperator& get_operator() const;
61 
63  std::size_t solve(GenericVector& x, const GenericVector& b);
64 
66  std::size_t solve(const GenericLinearOperator& A, GenericVector& x,
67  const GenericVector& b);
68 
70  std::size_t solve(const EigenMatrix& A, EigenVector& x,
71  const EigenVector& b);
72 
74  std::string str(bool verbose) const;
75 
77  static std::map<std::string, std::string> methods();
78 
81 
83  std::string parameter_type() const
84  { return "lu_solver"; }
85 
86  private:
87  // Eigen LU implementation class
88  class EigenLUImplBase;
89  std::unique_ptr<EigenLUImplBase> _impl;
90 
91  // Available LU solvers and descriptions
92  static const std::map<std::string, std::string> _methods_descr;
93 
94  // Current selected method
95  std::string _method;
96 
97  // Select LU solver type
98  std::string select_solver(const std::string method) const;
99 
100  // Operator (the matrix)
101  std::shared_ptr<const EigenMatrix> _matA;
102 
103  };
104 
105 }
106 
107 #endif
const GenericLinearOperator & get_operator() const
Get operator (matrix)
Definition: EigenLUSolver.cpp:198
void set_operator(std::shared_ptr< const GenericLinearOperator > A)
Set operator (matrix)
Definition: EigenLUSolver.cpp:178
Definition: adapt.h:29
static Parameters default_parameters()
Default parameter values.
Definition: EigenLUSolver.cpp:141
std::string str(bool verbose) const
Return informal string representation (pretty-print)
Definition: EigenLUSolver.cpp:319
Definition: GenericLinearOperator.h:42
Definition: EigenLUSolver.cpp:60
Definition: EigenMatrix.h:46
std::string parameter_type() const
Return parameter type: "krylov_solver" or "lu_solver".
Definition: EigenLUSolver.h:83
~EigenLUSolver()
Destructor.
Definition: EigenLUSolver.cpp:173
Definition: Parameters.h:94
EigenLUSolver(std::string method="default")
Constructor.
Definition: EigenLUSolver.cpp:148
Definition: EigenLUSolver.h:39
static std::map< std::string, std::string > methods()
Return a list of available solver methods.
Definition: EigenLUSolver.cpp:136
Definition: EigenVector.h:45
This class provides a general solver for linear systems Ax = b.
Definition: GenericLinearSolver.h:37
This class defines a common interface for vectors.
Definition: GenericVector.h:47
std::size_t solve(GenericVector &x, const GenericVector &b)
Solve linear system Ax = b.
Definition: EigenLUSolver.cpp:209