OGS
MathLib::EigenLinearSolverBase Class Referenceabstract

Detailed Description

Definition at line 29 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)
bool didComputeAtLeastOnce () const

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 58 of file EigenLinearSolver.cpp.

60 {
61 if (linear_solver_behaviour == MathLib::LinearSolverBehaviour::REUSE)
62 {
63 // Checking if this is the first compute() call should work both for
64 // direct solvers (that factorize the matrix A) and for iterative
65 // solvers (that store a reference to A in the preconditioner).
67 {
68 // There is nothing there, yet, to be reused. Hence, we compute
69 // and store the result.
70 linear_solver_behaviour =
72 }
73 else
74 {
75 return true;
76 }
77 }
78
79 // TODO (CL) That might not work under all circumstances, e.g., if the
80 // linear solver fails subsequently. Time will tell.
82
83#ifdef USE_EIGEN_UNSUPPORTED
84 if (opt.scaling)
85 {
86 INFO("-> scale");
87 scaling_ = std::make_unique<
88 Eigen::IterScaling<EigenMatrix::RawMatrixType>>();
89 scaling_->computeRef(A);
90 }
91#endif
92
93 return computeImpl(A, opt, linear_solver_behaviour);
94 }
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:28
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

◆ didComputeAtLeastOnce()

bool MathLib::EigenLinearSolverBase::didComputeAtLeastOnce ( ) const
inline

Definition at line 96 of file EigenLinearSolver.cpp.

96{ return !is_first_compute_call_; }

References is_first_compute_call_.

◆ solve()

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

Definition at line 37 of file EigenLinearSolver.cpp.

38 {
39#ifdef USE_EIGEN_UNSUPPORTED
40 if (scaling_)
41 {
42 b = scaling_->LeftScaling().cwiseProduct(b);
43 }
44#endif
45
46 auto const success = solveImpl(b, x, opt);
47
48#ifdef USE_EIGEN_UNSUPPORTED
49 if (scaling_)
50 {
51 x = scaling_->RightScaling().cwiseProduct(x);
52 }
53#endif
54
55 return success;
56 }
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 110 of file EigenLinearSolver.cpp.

Referenced by compute(), and didComputeAtLeastOnce().


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