SpECTRE
v2025.03.17
|
Base class for serial linear solvers that supports factory-creation. More...
#include <LinearSolver.hpp>
Public Types | |
using | registrars = LinearSolverRegistrars |
using | creatable_classes = Registration::registrants< LinearSolverRegistrars > |
Public Member Functions | |
virtual std::unique_ptr< LinearSolver< LinearSolverRegistrars > > | get_clone () const =0 |
template<typename LinearOperator , typename VarsType , typename SourceType , typename... OperatorArgs, typename... Args> | |
Convergence::HasConverged | solve (gsl::not_null< VarsType * > initial_guess_in_solution_out, const LinearOperator &linear_operator, const SourceType &source, const std::tuple< OperatorArgs... > &operator_args, Args &&... args) const |
Solve the linear equation linear_operator and source . More... | |
virtual void | reset ()=0 |
Discard caches from previous solves. Use before solving a different linear operator. More... | |
template<typename LinearOperator , typename VarsType , typename SourceType , typename... OperatorArgs, typename... Args> | |
Convergence::HasConverged | solve (const gsl::not_null< VarsType * > initial_guess_in_solution_out, const LinearOperator &linear_operator, const SourceType &source, const std::tuple< OperatorArgs... > &operator_args, Args &&... args) const |
Base class for serial linear solvers that supports factory-creation.
Derive linear solvers from this class so they can be factory-created. If your linear solver supports preconditioning, derive from PreconditionedLinearSolver
instead to inherit utility that allows using any other factor-creatable linear solver as preconditioner.
|
pure virtual |
Discard caches from previous solves. Use before solving a different linear operator.
Implemented in LinearSolver::Serial::PreconditionedLinearSolver< Preconditioner, LinearSolverRegistrars >.
Convergence::HasConverged LinearSolver::Serial::LinearSolver< LinearSolverRegistrars >::solve | ( | gsl::not_null< VarsType * > | initial_guess_in_solution_out, |
const LinearOperator & | linear_operator, | ||
const SourceType & | source, | ||
const std::tuple< OperatorArgs... > & | operator_args, | ||
Args &&... | args | ||
) | const |
Solve the linear equation linear_operator
and source
.
initial_guess_in_solution_out
buffer, which also serves to provide an initial guess for linear_operator
must be an invocable that takes a VarsType
as const-ref argument and returns a SourceType
by reference. It also takes all OperatorArgs
as const-ref arguments.Each solve may mutate the private state of the solver, for example to cache quantities to accelerate successive solves for the same operator. Invoke reset
to discard these caches.