OpenSWMM Engine  6.0.0-alpha.3
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.3)
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
 Advance the report grid to the next period.
 
static bool output_due (const SimulationContext &ctx) noexcept
 Returns true when the clock has reached the next report instant.
 
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 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 (seconds)
  • ctx.current_date (decompose-recompose from current_time)
  • ctx.old_elapsed_ms = ctx.elapsed_ms; ctx.elapsed_ms += 1000.0 * dt_taken (legacy ms clock)
  • ctx.dt_controls_remaining -= dt_taken
Parameters
ctxSimulation context (mutated).
dt_takenTimestep just completed, in seconds.
Here is the call graph for this function:

◆ 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:

  • time to the next report instant (from ctx.next_report_ms; clamp scheduled for removal by the A2 reporting-parity work)
  • 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 elapsed_ms/next_report_ms, 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.
Postcondition
Return value <= dt_cfl.
Return value >= ctx.options.min_routing_step.
Here is the call graph for this function:

◆ output_due()

bool openswmm::hydraulics::TimestepController::output_due ( const SimulationContext & ctx)
staticnoexcept

Returns true when the clock has reached the next report instant.

Legacy swmm5.c:1019 — NewRoutingTime >= ReportTime, on the ms-accumulated clock (no epsilon; both sides are exact sums of the same ms quantities, as in legacy).

Parameters
ctxSimulation context.
Returns
true if elapsed_ms >= next_report_ms.

◆ reset_output_timer()

void openswmm::hydraulics::TimestepController::reset_output_timer ( SimulationContext & ctx)
staticnoexcept

Advance the report grid to the next period.

Legacy swmm5.c:1044 — ReportTime += 1000 * ReportStep. Call after handling a due report period (written or skipped by the REPORT_START gate).

Parameters
ctxSimulation context (next_report_ms advanced one period).

◆ 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

◆ SEC_PER_DAY

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: