SpECTRE  v2024.04.12
LinearSolver::Serial::PreconditionedLinearSolver< Preconditioner, LinearSolverRegistrars > Class Template Referenceabstract

Base class for serial linear solvers that supports factory-creation and nested preconditioning. More...

#include <LinearSolver.hpp>

Classes

struct  PreconditionerOption
 

Public Types

using PreconditionerType = tmpl::conditional_t< std::is_abstract_v< Preconditioner >, std::unique_ptr< Preconditioner >, Preconditioner >
 
- Public Types inherited from LinearSolver::Serial::LinearSolver< LinearSolverRegistrars >
using registrars = LinearSolverRegistrars
 
using creatable_classes = Registration::registrants< LinearSolverRegistrars >
 

Public Member Functions

void pup (PUP::er &p) override
 
bool has_preconditioner () const
 Whether or not a preconditioner is set.
 
- Public Member Functions inherited from LinearSolver::Serial::LinearSolver< LinearSolverRegistrars >
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
 

Protected Member Functions

 PreconditionedLinearSolver (PreconditionedLinearSolver &&)=default
 
PreconditionedLinearSolveroperator= (PreconditionedLinearSolver &&)=default
 
 PreconditionedLinearSolver (std::optional< PreconditionerType > local_preconditioner)
 
 PreconditionedLinearSolver (const PreconditionedLinearSolver &rhs)
 
PreconditionedLinearSolveroperator= (const PreconditionedLinearSolver &rhs)
 
template<bool Enabled = not std::is_same_v<Preconditioner, NoPreconditioner>, Requires< Enabled and not std::is_same_v< Preconditioner, NoPreconditioner > > = nullptr>
std::optional< PreconditionerType > clone_preconditioner () const
 Copy the preconditioner. Useful to implement get_clone when the preconditioner has an abstract type.
 
template<bool Enabled = not std::is_same_v<Preconditioner, NoPreconditioner>, Requires< Enabled and not std::is_same_v< Preconditioner, NoPreconditioner > > = nullptr>
const Preconditioner & preconditioner () const
 Access to the preconditioner. Check has_preconditioner() before calling this function. Calling this function when has_preconditioner() returns false is an error.
 
template<bool Enabled = not std::is_same_v<Preconditioner, NoPreconditioner>, Requires< Enabled and not std::is_same_v< Preconditioner, NoPreconditioner > > = nullptr>
Preconditioner & preconditioner ()
 Copy the preconditioner. Useful to implement get_clone when the preconditioner has an abstract type.
 
void reset () override=0
 Copy the preconditioner. Useful to implement get_clone when the preconditioner has an abstract type. More...
 

Detailed Description

template<typename Preconditioner, typename LinearSolverRegistrars>
class LinearSolver::Serial::PreconditionedLinearSolver< Preconditioner, LinearSolverRegistrars >

Base class for serial linear solvers that supports factory-creation and nested preconditioning.

To enable support for preconditioning in your derived linear solver class, pass any type that has a solve and a reset function as the Preconditioner template parameter. It can also be an abstract LinearSolver type, which means that any other linear solver can be used as preconditioner. Pass NoPreconditioner to disable support for preconditioning.

Member Function Documentation

◆ reset()

template<typename Preconditioner , typename LinearSolverRegistrars >
void LinearSolver::Serial::PreconditionedLinearSolver< Preconditioner, LinearSolverRegistrars >::reset
overridepure virtual

Copy the preconditioner. Useful to implement get_clone when the preconditioner has an abstract type.

Implements LinearSolver::Serial::LinearSolver< LinearSolverRegistrars >.


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