Loading...
Searching...
No Matches
gridfire::trigger::solver::CVODE::TimestepCollapseTrigger Class Referencefinal

Triggers when the timestep deviates from its recent average beyond a threshold. More...

`#include <engine_partitioning_trigger.h>`

Inheritance diagram for gridfire::trigger::solver::CVODE::TimestepCollapseTrigger:
[legend]
Collaboration diagram for gridfire::trigger::solver::CVODE::TimestepCollapseTrigger:
[legend]

## Public Member Functions

| TimestepCollapseTrigger (double threshold, bool relative)
| Construct with threshold and relative/absolute mode; window size defaults to 1.
| TimestepCollapseTrigger (double threshold, bool relative, size_t windowSize)
| Construct with threshold, mode, and window size.
bool | check (const gridfire::solver::PointSolverTimestepContext &ctx) const override
| Evaluate whether the current dt deviates sufficiently from recent average.
void | update (const gridfire::solver::PointSolverTimestepContext &ctx) override
| Update sliding window with the most recent dt and increment update counter.
void | step (const gridfire::solver::PointSolverTimestepContext &ctx) override
| similar to update but intended to be run on every step not just those where the trigger triggered
void | reset () override
| Reset counters and clear the dt window.
std::string | name () const override
| Stable human-readable name.
TriggerResult | why (const gridfire::solver::PointSolverTimestepContext &ctx) const override
| Structured explanation of the evaluation outcome.
std::string | describe () const override
| Textual description including threshold, mode, and window size.
size_t | numTriggers () const override
| Number of true evaluations since last reset.
size_t | numMisses () const override
| Number of false evaluations since last reset.
Public Member Functions inherited from gridfire::trigger::Trigger< gridfire::solver::PointSolverTimestepContext >
virtual | ~Trigger ()=default
| Virtual destructor for polymorphic use.

## Private Attributes

quill::Logger * | m_logger = fourdst::logging::LogManager::getInstance().getLogger("log")
| Logger used for trace/error diagnostics.
double | m_threshold
| Threshold for absolute or relative deviation.
bool | m_relative
| When true, use relative deviation; otherwise absolute deviation.
size_t | m_windowSize
| Number of dt samples to maintain in the moving window.
std::deque< double > | m_timestep_window
| Sliding window of recent timesteps (most recent at back).
Diagnostics counters
size_t | m_hits = 0
size_t | m_misses = 0
size_t | m_updates = 0
size_t | m_resets = 0

## Detailed Description

Triggers when the timestep deviates from its recent average beyond a threshold.

- Maintains a sliding window of recent dt values (size = windowSize).
- check(ctx):
  - If the window is empty, returns false.
  - Computes the arithmetic mean of values in the window and compares either:
    - relative: |dt - mean| / mean >= threshold
    - absolute: |dt - mean| >= threshold
- update(ctx): pushes ctx.dt into the fixed-size window (dropping oldest when full).

Constraints/Errors:
  - threshold must be >= 0.
  - If relative==true, threshold must be in [0, 1]. Violations throw std::invalid_argument.

Note
  - With windowSize==1, the mean is the most recent prior dt.
  - Counter fields are mutable to allow updates during const check().

See also: engine_partitioning_trigger.cpp for exact logic and logging.

## Constructor & Destructor Documentation

## TimestepCollapseTrigger() [1/2]

gridfire::trigger::solver::CVODE::TimestepCollapseTrigger::TimestepCollapseTrigger | ( | double | threshold,
|  | bool | relative )

explicit

Construct with threshold and relative/absolute mode; window size defaults to 1.

Parameters

  threshold | Non-negative threshold; if relative, must be in [0, 1].
  relative | If true, use relative deviation; otherwise use absolute deviation.

Exceptions

  std::invalid_argument | on invalid threshold constraints.

## TimestepCollapseTrigger() [2/2]

gridfire::trigger::solver::CVODE::TimestepCollapseTrigger::TimestepCollapseTrigger | ( | double | threshold,
|  | bool | relative,
|  | size_t | windowSize )

explicit

Construct with threshold, mode, and window size.

Parameters

  threshold | Non-negative threshold; if relative, must be in [0, 1].
  relative | If true, use relative deviation; otherwise use absolute deviation.
  windowSize | Number of dt samples to average over (>= 1 recommended).

Exceptions

  std::invalid_argument | on invalid threshold constraints.

## Member Function Documentation

## check()

bool gridfire::trigger::solver::CVODE::TimestepCollapseTrigger::check | ( | const gridfire::solver::PointSolverTimestepContext & | ctx | ) | const

overridevirtual

Evaluate whether the current dt deviates sufficiently from recent average.

Parameters

  ctx | CVODE timestep context providing current dt.

Returns
  true if deviation exceeds the configured threshold; false otherwise.

Postcondition
  increments hit/miss counters and may emit trace logs.

Implements gridfire::trigger::Trigger< gridfire::solver::PointSolverTimestepContext >.

## describe()

std::string gridfire::trigger::solver::CVODE::TimestepCollapseTrigger::describe | ( |  | ) | const

overridevirtual

Textual description including threshold, mode, and window size.

Implements gridfire::trigger::Trigger< gridfire::solver::PointSolverTimestepContext >.

## name()

std::string gridfire::trigger::solver::CVODE::TimestepCollapseTrigger::name | ( |  | ) | const

overridevirtual

Stable human-readable name.

Implements gridfire::trigger::Trigger< gridfire::solver::PointSolverTimestepContext >.

## numMisses()

size_t gridfire::trigger::solver::CVODE::TimestepCollapseTrigger::numMisses | ( |  | ) | const

overridevirtual

Number of false evaluations since last reset.

Implements gridfire::trigger::Trigger< gridfire::solver::PointSolverTimestepContext >.

## numTriggers()

size_t gridfire::trigger::solver::CVODE::TimestepCollapseTrigger::numTriggers | ( |  | ) | const

overridevirtual

Number of true evaluations since last reset.

Implements gridfire::trigger::Trigger< gridfire::solver::PointSolverTimestepContext >.

## reset()

void gridfire::trigger::solver::CVODE::TimestepCollapseTrigger::reset | ( |  | ) |

overridevirtual

Reset counters and clear the dt window.

Implements gridfire::trigger::Trigger< gridfire::solver::PointSolverTimestepContext >.

## step()

void gridfire::trigger::solver::CVODE::TimestepCollapseTrigger::step | ( | const gridfire::solver::PointSolverTimestepContext & | ctx | ) |

overridevirtual

similar to update but intended to be run on every step not just those where the trigger triggered

Parameters

  ctx | Context snapshot used to update state.

Implements gridfire::trigger::Trigger< gridfire::solver::PointSolverTimestepContext >.

## update()

void gridfire::trigger::solver::CVODE::TimestepCollapseTrigger::update | ( | const gridfire::solver::PointSolverTimestepContext & | ctx | ) |

overridevirtual

Update sliding window with the most recent dt and increment update counter.

Parameters

  ctx | CVODE timestep context.

Implements gridfire::trigger::Trigger< gridfire::solver::PointSolverTimestepContext >.

## why()

TriggerResult gridfire::trigger::solver::CVODE::TimestepCollapseTrigger::why | ( | const gridfire::solver::PointSolverTimestepContext & | ctx | ) | const

overridevirtual

Structured explanation of the evaluation outcome.

Implements gridfire::trigger::Trigger< gridfire::solver::PointSolverTimestepContext >.

## Member Data Documentation

## m_hits

size_t gridfire::trigger::solver::CVODE::TimestepCollapseTrigger::m_hits = 0

mutableprivate

## m_logger

quill::Logger* gridfire::trigger::solver::CVODE::TimestepCollapseTrigger::m_logger = fourdst::logging::LogManager::getInstance().getLogger("log")

private

Logger used for trace/error diagnostics.

## m_misses

size_t gridfire::trigger::solver::CVODE::TimestepCollapseTrigger::m_misses = 0

mutableprivate

## m_relative

bool gridfire::trigger::solver::CVODE::TimestepCollapseTrigger::m_relative

private

When true, use relative deviation; otherwise absolute deviation.

## m_resets

size_t gridfire::trigger::solver::CVODE::TimestepCollapseTrigger::m_resets = 0

mutableprivate

## m_threshold

double gridfire::trigger::solver::CVODE::TimestepCollapseTrigger::m_threshold

private

Threshold for absolute or relative deviation.

## m_timestep_window

std::deque<double> gridfire::trigger::solver::CVODE::TimestepCollapseTrigger::m_timestep_window

private

Sliding window of recent timesteps (most recent at back).

## m_updates

size_t gridfire::trigger::solver::CVODE::TimestepCollapseTrigger::m_updates = 0

mutableprivate

## m_windowSize

size_t gridfire::trigger::solver::CVODE::TimestepCollapseTrigger::m_windowSize

private

Number of dt samples to maintain in the moving window.

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

- src/include/gridfire/solver/strategies/triggers/engine_partitioning_trigger.h
- src/lib/solver/strategies/triggers/engine_partitioning_trigger.cpp