Stateful policy for the solver fallback chain.
More...
#include <CD_EllipticSolverChain.H>
|
| int | startIndex (const Vector< SolverType > &a_solvers) |
| | Start index into a_solvers for this solve, advancing the re-probe counter. Call exactly once per solve.
|
| void | recordOutcome (const bool a_gmgAttempted, const bool a_gmgConverged, const int a_krylovIters=-1, const int a_verbosity=-1, const std::string &a_name="") |
| | Record the outcome of this solve and update the latch.
|
| bool | isLatched () const |
| | Whether the policy is currently latched onto the Krylov fallback.
|
|
|
int | retryInterval = 1 |
| | Re-probe GMG every this many solves while latched. Clamped to >= 1; 1 reproduces always-retry behaviour.
|
|
int | reprobeIters = 0 |
| | Adaptive early re-probe: re-probe GMG on the next solve whenever the Krylov fallback converged in this many iterations or fewer (a strong preconditioner is a sign that GMG alone may now succeed). 0 disables it, so only the periodic retryInterval applies.
|
|
| int | firstNonGmg (const Vector< SolverType > &a_solvers) const |
| | Index of the first non-GMG solver in the chain, or 0 if there is none.
|
|
|
bool | m_latched = false |
| | Whether a failed GMG attempt has latched us onto the Krylov fallback.
|
|
int | m_sinceProbe = 0 |
| | Solves since the last GMG attempt while latched.
|
|
bool | m_reprobeNext = false |
| | Whether a cheap Krylov solve has armed an adaptive early re-probe of GMG on the next solve.
|
Stateful policy for the solver fallback chain.
When the leading stand-alone multigrid (GMG) entry of a chain such as gmg gmres fails, the chain falls back to the Krylov solver. Without memory the next solve pays a full failed GMG attempt again, which is wasteful when the failure is persistent (e.g. a fixed, hard field operator). This policy latches onto the Krylov fallback after a GMG failure and only re-probes GMG every retryInterval solves, reclaiming multigrid's speed whenever the problem becomes tractable again. retryInterval == 1 reproduces the memoryless "always retry GMG first" behaviour; a large value approaches a permanent latch. Optionally, reprobeIters arms an adaptive early re-probe: if the Krylov fallback converges in very few iterations the preconditioner is clearly strong, so GMG alone is likely to succeed and is re-probed on the next solve without waiting for retryInterval.
- Note
- The state is deliberately decoupled from regridding: hold an instance as a host-solver member and do not reset it when the operators are rebuilt (regrids may be far more frequent than the desired re-probe cadence). The counter advances per solve, so the re-probe cadence is measured in solves, not necessarily time steps.
◆ firstNonGmg()
| int EllipticSolverChain::FallbackPolicy::firstNonGmg |
( |
const Vector< SolverType > & | a_solvers | ) |
const |
|
inlineprotected |
Index of the first non-GMG solver in the chain, or 0 if there is none.
- Parameters
-
| [in] | a_solvers | The fallback chain. |
- Returns
- Start index that skips a leading GMG.
◆ isLatched()
| bool EllipticSolverChain::FallbackPolicy::isLatched |
( |
| ) |
const |
|
inline |
Whether the policy is currently latched onto the Krylov fallback.
- Returns
- True if latched.
◆ recordOutcome()
| void EllipticSolverChain::FallbackPolicy::recordOutcome |
( |
const bool | a_gmgAttempted, |
|
|
const bool | a_gmgConverged, |
|
|
const int | a_krylovIters = -1, |
|
|
const int | a_verbosity = -1, |
|
|
const std::string & | a_name = "" ) |
|
inline |
Record the outcome of this solve and update the latch.
Latching (a failed GMG attempt) is already announced by the host's fallback-chain message; this method additionally announces the release (a successful re-probe) at verbosity >= 1, since that transition is otherwise silent. While latched and skipping GMG, a Krylov solve that converged in <= reprobeIters iterations arms an adaptive early re-probe of GMG on the next solve.
- Parameters
-
| [in] | a_gmgAttempted | Whether a stand-alone GMG attempt was made this solve. |
| [in] | a_gmgConverged | Whether that GMG attempt converged. |
| [in] | a_krylovIters | Iterations taken by the Krylov fallback this solve, or < 0 if none ran. |
| [in] | a_verbosity | Host verbosity; a release message is printed when >= 1. |
| [in] | a_name | Host solver name, used to prefix the release message. |
◆ startIndex()
| int EllipticSolverChain::FallbackPolicy::startIndex |
( |
const Vector< SolverType > & | a_solvers | ) |
|
|
inline |
Start index into a_solvers for this solve, advancing the re-probe counter. Call exactly once per solve.
Returns 0 (include the leading GMG) when unlatched, when the periodic re-probe is due, or when an adaptive early re-probe was armed by a cheap Krylov solve; otherwise returns the index of the first non-GMG solver so the persistently-failing GMG attempt is skipped.
- Parameters
-
| [in] | a_solvers | The configured fallback chain. |
- Returns
- Start index into a_solvers.
The documentation for this struct was generated from the following file: