SpECTRE  v2024.04.12
LinearSolver::Actions::MakeIdentityIfSkipped< LinearSolverType, ProceedLabel > 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 Parallel::iterable_action_return_t apply (db::DataBox< DbTagsList > &box, const tuples::TaggedTuple< InboxTags... > &, const Parallel::GlobalCache< Metavariables > &, const ArrayIndex &, const ActionList, const ParallelComponent *const)
 

Detailed Description

template<typename LinearSolverType, typename ProceedLabel = void>
struct LinearSolver::Actions::MakeIdentityIfSkipped< LinearSolverType, ProceedLabel >

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>>,
Make the iterative linear solve the identity operation on the source vector if no iterations were per...
Definition: MakeIdentityIfSkipped.hpp:77

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.

To run additional actions after this action has triggered, i.e. when the linear solver is skipped, place them after this action and follow them by an Actions::Label<ProceedLabel>, where ProceedLabel is a type used for identification. Pass the ProceedLabel as the second template parameter to this action. Then, the actions between this action and the label will run only when the linear solver is skipped. This is useful to set DataBox tags that are usually updated by the linear solver.

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: