SpECTRE  v2024.03.19
LinearSolver::Serial::LinearSolver< LinearSolverRegistrars > Class Template Referenceabstract

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 \(Ax=b\) where \(A\) is the linear_operator and \(b\) is the 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
 

Detailed Description

template<typename LinearSolverRegistrars>
class LinearSolver::Serial::LinearSolver< LinearSolverRegistrars >

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.

Member Function Documentation

◆ reset()

template<typename LinearSolverRegistrars >
virtual void LinearSolver::Serial::LinearSolver< LinearSolverRegistrars >::reset ( )
pure virtual

Discard caches from previous solves. Use before solving a different linear operator.

Implemented in LinearSolver::Serial::ExplicitInverse< LinearSolverRegistrars >, and LinearSolver::Serial::PreconditionedLinearSolver< Preconditioner, LinearSolverRegistrars >.

◆ solve()

template<typename LinearSolverRegistrars >
template<typename LinearOperator , typename VarsType , typename SourceType , typename... OperatorArgs, typename... Args>
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 \(Ax=b\) where \(A\) is the linear_operator and \(b\) is the source.

  • The (approximate) solution \(x\) is returned in the initial_guess_in_solution_out buffer, which also serves to provide an initial guess for \(x\). Not all solvers take the initial guess into account, but all expect the buffer is sized correctly.
  • The 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.


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