OGS
MathLib::EigenLinearSolverBase Class Referenceabstract

Detailed Description

Definition at line 36 of file EigenLinearSolver.cpp.

Inheritance diagram for MathLib::EigenLinearSolverBase:
[legend]

Public Types

using Vector = EigenVector::RawVectorType
 
using Matrix = EigenMatrix::RawMatrixType
 

Public Member Functions

virtual ~EigenLinearSolverBase ()=default
 
bool solve (Vector &b, Vector &x, EigenOption &opt)
 
bool compute (Matrix &A, EigenOption &opt, MathLib::LinearSolverBehaviour linear_solver_behaviour)
 

Protected Member Functions

virtual bool solveImpl (Vector const &b, Vector &x, EigenOption &opt)=0
 
virtual bool computeImpl (Matrix &A, EigenOption &opt, MathLib::LinearSolverBehaviour const linear_solver_behaviour)=0
 

Private Attributes

bool is_first_compute_call_ = true
 

Member Typedef Documentation

◆ Matrix

◆ Vector

Constructor & Destructor Documentation

◆ ~EigenLinearSolverBase()

virtual MathLib::EigenLinearSolverBase::~EigenLinearSolverBase ( )
virtualdefault

Member Function Documentation

◆ compute()

bool MathLib::EigenLinearSolverBase::compute ( Matrix & A,
EigenOption & opt,
MathLib::LinearSolverBehaviour linear_solver_behaviour )
inline

Definition at line 65 of file EigenLinearSolver.cpp.

67 {
68 if (linear_solver_behaviour == MathLib::LinearSolverBehaviour::REUSE)
69 {
70 // Checking if this is the first compute() call should work both for
71 // direct solvers (that factorize the matrix A) and for iterative
72 // solvers (that store a reference to A in the preconditioner).
74 {
75 // There is nothing there, yet, to be reused. Hence, we compute
76 // and store the result.
77 linear_solver_behaviour =
79 }
80 else
81 {
82 return true;
83 }
84 }
85
86 // TODO (CL) That might not work under all circumstances, e.g., if the
87 // linear solver fails subsequently. Time will tell.
89
90#ifdef USE_EIGEN_UNSUPPORTED
91 if (opt.scaling)
92 {
93 INFO("-> scale");
94 scaling_ = std::make_unique<
95 Eigen::IterScaling<EigenMatrix::RawMatrixType>>();
96 scaling_->computeRef(A);
97 }
98#endif
99
100 return computeImpl(A, opt, linear_solver_behaviour);
101 }
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
virtual bool computeImpl(Matrix &A, EigenOption &opt, MathLib::LinearSolverBehaviour const linear_solver_behaviour)=0

References computeImpl(), INFO(), is_first_compute_call_, MathLib::RECOMPUTE_AND_STORE, and MathLib::REUSE.

Referenced by MathLib::details::EigenIterativeLinearSolver< T_SOLVER >::computeImpl().

◆ computeImpl()

virtual bool MathLib::EigenLinearSolverBase::computeImpl ( Matrix & A,
EigenOption & opt,
MathLib::LinearSolverBehaviour const linear_solver_behaviour )
protectedpure virtual

◆ solve()

bool MathLib::EigenLinearSolverBase::solve ( Vector & b,
Vector & x,
EigenOption & opt )
inline

Definition at line 44 of file EigenLinearSolver.cpp.

45 {
46#ifdef USE_EIGEN_UNSUPPORTED
47 if (scaling_)
48 {
49 b = scaling_->LeftScaling().cwiseProduct(b);
50 }
51#endif
52
53 auto const success = solveImpl(b, x, opt);
54
55#ifdef USE_EIGEN_UNSUPPORTED
56 if (scaling_)
57 {
58 x = scaling_->RightScaling().cwiseProduct(x);
59 }
60#endif
61
62 return success;
63 }
virtual bool solveImpl(Vector const &b, Vector &x, EigenOption &opt)=0

References solveImpl().

◆ solveImpl()

virtual bool MathLib::EigenLinearSolverBase::solveImpl ( Vector const & b,
Vector & x,
EigenOption & opt )
protectedpure virtual

Member Data Documentation

◆ is_first_compute_call_

bool MathLib::EigenLinearSolverBase::is_first_compute_call_ = true
private

Definition at line 115 of file EigenLinearSolver.cpp.

Referenced by compute().


The documentation for this class was generated from the following file: