SpECTRE  2021.08.02
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 creatable_classes = Registration::registrants< LinearSolverRegistrars >
 

Public Member Functions

void pup (PUP::er &p) noexcept override
 
bool has_preconditioner () const noexcept
 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... Args>
Convergence::HasConverged solve (gsl::not_null< VarsType * > initial_guess_in_solution_out, const LinearOperator &linear_operator, const SourceType &source, Args &&... args) const noexcept
 Solve the linear equation \(Ax=b\) where \(A\) is the linear_operator and \(b\) is the source. More...
 
template<typename LinearOperator , typename VarsType , typename SourceType , typename... Args>
Convergence::HasConverged solve (const gsl::not_null< VarsType * > initial_guess_in_solution_out, const LinearOperator &linear_operator, const SourceType &source, Args &&... args) const noexcept
 

Protected Member Functions

 PreconditionedLinearSolver (PreconditionedLinearSolver &&)=default
 
PreconditionedLinearSolveroperator= (PreconditionedLinearSolver &&)=default
 
 PreconditionedLinearSolver (std::optional< PreconditionerType > local_preconditioner) noexcept
 
 PreconditionedLinearSolver (const PreconditionedLinearSolver &rhs) noexcept
 
PreconditionedLinearSolveroperator= (const PreconditionedLinearSolver &rhs) noexcept
 
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 noexcept
 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 noexcept
 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 () noexcept
 Copy the preconditioner. Useful to implement get_clone when the preconditioner has an abstract type.
 
void reset () noexcept 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 virtualnoexcept

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

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