DOLFIN
DOLFIN C++ interface
Loading...
Searching...
No Matches
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
28namespace 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
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 // Eigen LU implementation class
87 class EigenLUImplBase;
88
89 private:
90 std::unique_ptr<EigenLUImplBase> _impl;
91
92 // Available LU solvers and descriptions
93 static const std::map<std::string, std::string> _methods_descr;
94
95 // Current selected method
96 std::string _method;
97
98 // Select LU solver type
99 std::string select_solver(const std::string method) const;
100
101 // Operator (the matrix)
102 std::shared_ptr<const EigenMatrix> _matA;
103
104 };
105
106}
107
108#endif
Definition EigenLUSolver.h:40
EigenLUSolver(std::string method="default")
Constructor.
Definition EigenLUSolver.cpp:149
const GenericLinearOperator & get_operator() const
Get operator (matrix)
Definition EigenLUSolver.cpp:199
std::string str(bool verbose) const
Return informal string representation (pretty-print)
Definition EigenLUSolver.cpp:320
static Parameters default_parameters()
Default parameter values.
Definition EigenLUSolver.cpp:142
std::size_t solve(GenericVector &x, const GenericVector &b)
Solve linear system Ax = b.
Definition EigenLUSolver.cpp:210
void set_operator(std::shared_ptr< const GenericLinearOperator > A)
Set operator (matrix)
Definition EigenLUSolver.cpp:179
static std::map< std::string, std::string > methods()
Return a list of available solver methods.
Definition EigenLUSolver.cpp:137
~EigenLUSolver()
Destructor.
Definition EigenLUSolver.cpp:174
std::string parameter_type() const
Return parameter type: "krylov_solver" or "lu_solver".
Definition EigenLUSolver.h:83
Definition EigenMatrix.h:47
Definition EigenVector.h:46
Definition GenericLinearOperator.h:43
This class provides a general solver for linear systems Ax = b.
Definition GenericLinearSolver.h:38
This class defines a common interface for vectors.
Definition GenericVector.h:48
Definition Parameters.h:95
Definition adapt.h:30