OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
openswmm::hydraulics::TimestepController Class Reference

Static utility class for explicit timestep computation. More...

#include <TimestepController.hpp>

Collaboration diagram for openswmm::hydraulics::TimestepController:

Public Member Functions

 TimestepController ()=delete
 

Static Public Member Functions

static double compute_next (const SimulationContext &ctx, double dt_cfl) noexcept
 Compute the next simulation timestep.
 
static void advance (SimulationContext &ctx, double dt_taken) noexcept
 Advance internal timers by dt_taken seconds.
 
static void reset_output_timer (SimulationContext &ctx) noexcept
 Reset the output countdown timer to the full report step.
 
static bool output_due (const SimulationContext &ctx) noexcept
 Returns true when simulation clock has reached an output boundary.
 
static bool simulation_complete (const SimulationContext &ctx) noexcept
 Returns true when the simulation has reached or passed end_time.
 

Static Public Attributes

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).
 

Detailed Description

Static utility class for explicit timestep computation.

All methods are pure static functions that operate on a SimulationContext reference. This class has no state.

Constructor & Destructor Documentation

◆ TimestepController()

openswmm::hydraulics::TimestepController::TimestepController ( )
delete

Member Function Documentation

◆ 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
ctxSimulation context (mutated).
dt_takenTimestep 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
ctxSimulation context (reads dt_output_remaining, options).
dt_cflCFL-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
ctxSimulation context.
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
ctxSimulation 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
ctxSimulation context.

Member Data Documentation

◆ 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

Seconds per day (exact).


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