Static Public Member Functions | List of all members
LinearSolver::Actions::MakeIdentityIfSkipped< LinearSolverType > Struct Template Reference

Make the iterative linear solve the identity operation on the source vector if no iterations were performed at all. Useful for disabling a preconditioner by setting its number of iterations to zero. More...

#include <MakeIdentityIfSkipped.hpp>

Static Public Member Functions

template<typename DbTagsList , typename... InboxTags, typename Metavariables , typename ArrayIndex , typename ActionList , typename ParallelComponent >
static std::tuple< db::DataBox< DbTagsList > && > apply (db::DataBox< DbTagsList > &box, const tuples::TaggedTuple< InboxTags... > &, const Parallel::GlobalCache< Metavariables > &, const ArrayIndex &, const ActionList, const ParallelComponent *const) noexcept
 

Detailed Description

template<typename LinearSolverType>
struct LinearSolver::Actions::MakeIdentityIfSkipped< LinearSolverType >

Make the iterative linear solve the identity operation on the source vector if no iterations were performed at all. Useful for disabling a preconditioner by setting its number of iterations to zero.

When the linear solve is skipped, i.e. when it performs no iterations because its number of iterations is set to zero, this action assumes \(A=1\) so \(Ax=b\) solves to \(x=b\). This is useful when the solver is used as preconditioner, because then we can disable preconditioning by just not iterating the preconditioner, i.e. by setting its number of iterations to zero in the input file.

To use this action, insert it into the action list just after iterating the linear solver, i.e. after its solve action list:

typename Preconditioner::template solve<ComputeOperatorAction<
typename Preconditioner::operand_tag>>,

This action will set the LinearSolverType::fields_tag to the LinearSolverType::source_tag whenever the linear solver has converged with the reason Convergence::Reason::NumIterations or Convergence::Reason::MaxIterations without actually having performed any iterations.

Details:
The standard behaviour of most linear solvers (i.e. when not using this action) is to keep the fields at their initial guess \(x=x_0\) when it performs no iterations. That behaviour is not handled well when the solver is used as preconditioner and its parent always makes it start at \(x_0=0\). This is a reasonable choice to start the preconditioner but it also means that the preconditioner doesn't reduce to the identity when it performs no iterations. Using this action means not iterating the preconditioner at all essentially disables preconditioning, switching the parent solver to an unpreconditioned solve with some runtime and memory overhead associated with initializing the preconditioner.

The documentation for this struct was generated from the following file:
LinearSolver::Actions::MakeIdentityIfSkipped
Make the iterative linear solve the identity operation on the source vector if no iterations were per...
Definition: MakeIdentityIfSkipped.hpp:66