Static utility class for explicit timestep computation.
More...
#include <TimestepController.hpp>
|
| static constexpr double | OUTPUT_EPSILON = 1.0e-6 |
| | Epsilon for output-time floating-point comparison (seconds).
|
| |
| static constexpr double | SEC_PER_DAY = 86400.0 |
| | Seconds per day (exact).
|
| |
Static utility class for explicit timestep computation.
All methods are pure static functions that operate on a SimulationContext reference. This class has no state.
◆ TimestepController()
| openswmm::hydraulics::TimestepController::TimestepController |
( |
| ) |
|
|
delete |
◆ advance()
| void openswmm::hydraulics::TimestepController::advance |
( |
SimulationContext & |
ctx, |
|
|
double |
dt_taken |
|
) |
| |
|
staticnoexcept |
Advance internal timers by dt_taken seconds.
Updates:
ctx.current_time += dt_taken / 86400.0 (decimal days)
ctx.dt_output_remaining -= dt_taken
ctx.dt_controls_remaining -= dt_taken
- Parameters
-
| ctx | Simulation context (mutated). |
| dt_taken | Timestep just completed, in seconds. |
◆ compute_next()
| double openswmm::hydraulics::TimestepController::compute_next |
( |
const SimulationContext & |
ctx, |
|
|
double |
dt_cfl |
|
) |
| |
|
staticnoexcept |
Compute the next simulation timestep.
Result is the minimum of:
ctx.dt_output_remaining (time to next output boundary)
dt_cfl (CFL-limited hydraulic step from DynamicWave)
ctx.dt_controls_remaining (next control rule event)
ctx.options.routing_step (user-configured max step)
- NOT less than
ctx.options.min_routing_step (minimum floor)
- Parameters
-
| ctx | Simulation context (reads dt_output_remaining, options). |
| dt_cfl | CFL-limited timestep from the DynamicWave solver (seconds). Pass ctx.options.routing_step if not using dynamic wave. |
- Returns
- dt_next in seconds, guaranteed > 0.
- Precondition
- ctx.dt_output_remaining > 0.
- Postcondition
- Return value <= dt_cfl.
-
Return value <= ctx.dt_output_remaining.
-
Return value >= ctx.options.min_routing_step.
◆ output_due()
| bool openswmm::hydraulics::TimestepController::output_due |
( |
const SimulationContext & |
ctx | ) |
|
|
staticnoexcept |
Returns true when simulation clock has reached an output boundary.
A small epsilon (1e-6 seconds) is used for floating-point comparison to avoid missing an output due to floating-point rounding.
- Parameters
-
- Returns
- true if dt_output_remaining <= EPSILON.
◆ reset_output_timer()
| void openswmm::hydraulics::TimestepController::reset_output_timer |
( |
SimulationContext & |
ctx | ) |
|
|
staticnoexcept |
Reset the output countdown timer to the full report step.
Call this immediately after posting a snapshot to the IO thread.
- Parameters
-
| ctx | Simulation context (dt_output_remaining reset to report_step). |
◆ simulation_complete()
| bool openswmm::hydraulics::TimestepController::simulation_complete |
( |
const SimulationContext & |
ctx | ) |
|
|
staticnoexcept |
Returns true when the simulation has reached or passed end_time.
- Parameters
-
◆ OUTPUT_EPSILON
| constexpr double openswmm::hydraulics::TimestepController::OUTPUT_EPSILON = 1.0e-6 |
|
staticconstexpr |
Epsilon for output-time floating-point comparison (seconds).
◆ SEC_PER_DAY
| constexpr double openswmm::hydraulics::TimestepController::SEC_PER_DAY = 86400.0 |
|
staticconstexpr |
The documentation for this class was generated from the following files: