20#ifndef LIBMESH_EIGEN_SPARSE_LINEAR_SOLVER_H
21#define LIBMESH_EIGEN_SPARSE_LINEAR_SOLVER_H
23#include "libmesh/libmesh_common.h"
25#ifdef LIBMESH_HAVE_EIGEN
30#include "libmesh/linear_solver.h"
31#include "libmesh/eigen_sparse_vector.h"
32#include "libmesh/eigen_sparse_matrix.h"
33#include "libmesh/enum_convergence_flags.h"
64 virtual void clear ()
override;
69 virtual void init (
const char * name=
nullptr)
override;
74 virtual std::pair<unsigned int, Real>
78 const std::optional<double> tol = std::nullopt,
79 const std::optional<unsigned int> m_its = std::nullopt)
override;
84 virtual std::pair<unsigned int, Real>
88 const std::optional<double> tol = std::nullopt,
89 const std::optional<unsigned int> m_its = std::nullopt)
override;
94 virtual std::pair<unsigned int, Real>
99 const std::optional<double> tol = std::nullopt,
100 const std::optional<unsigned int> m_its = std::nullopt)
override;
105 virtual std::pair<unsigned int, Real>
109 const std::optional<double> tol = std::nullopt,
110 const std::optional<unsigned int> m_its = std::nullopt)
override;
117 virtual std::pair<unsigned int, Real>
122 const std::optional<double> tol = std::nullopt,
123 const std::optional<unsigned int> m_its = std::nullopt)
override;
152 static std::map<Eigen::ComputationInfo, LinearConvergenceReason>
build_map()
154 std::map<Eigen::ComputationInfo, LinearConvergenceReason> ret;
169std::map<Eigen::ComputationInfo, LinearConvergenceReason>
185std::pair<unsigned int, Real>
190 const std::optional<double>,
191 const std::optional<unsigned int>)
193 libmesh_error_msg(
"ERROR: Eigen does not support a user-supplied preconditioner!");
195 return std::pair<unsigned int, Real>();
This class provides an interface to Eigen iterative solvers that is compatible with the libMesh Linea...
virtual LinearConvergenceReason get_converged_reason() const override
Eigen::ComputationInfo _comp_info
Store the result of the last solve.
~EigenSparseLinearSolver()
Destructor.
virtual void init(const char *name=nullptr) override
Initialize data structures if not done so already.
virtual std::pair< unsigned int, Real > solve(SparseMatrix< T > &matrix, NumericVector< T > &solution, NumericVector< T > &rhs, const std::optional< double > tol=std::nullopt, const std::optional< unsigned int > m_its=std::nullopt) override
Call the Eigen solver.
static std::map< Eigen::ComputationInfo, LinearConvergenceReason > build_map()
Static function used to initialize _convergence_reasons map.
virtual std::pair< unsigned int, Real > adjoint_solve(SparseMatrix< T > &matrix, NumericVector< T > &solution, NumericVector< T > &rhs, const std::optional< double > tol=std::nullopt, const std::optional< unsigned int > m_its=std::nullopt) override
Call the Eigen solver to solve A^T x = b.
void set_eigen_preconditioner_type()
Tells Eigen to use the user-specified preconditioner stored in _preconditioner_type.
virtual void clear() override
Release all memory and clear data structures.
static std::map< Eigen::ComputationInfo, LinearConvergenceReason > _convergence_reasons
Static map between Eigen ComputationInfo enumerations and libMesh LinearConvergenceReason enumeration...
This base class can be inherited from to provide interfaces to linear solvers from different packages...
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
Generic shell matrix, i.e.
The libMesh namespace provides an interface to certain functionality in the library.
LinearConvergenceReason
Linear solver convergence flags (taken from the PETSc flags).