OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
TimestepController.hpp
Go to the documentation of this file.
1
57#ifndef OPENSWMM_ENGINE_TIMESTEP_CONTROLLER_HPP
58#define OPENSWMM_ENGINE_TIMESTEP_CONTROLLER_HPP
59
60#include <algorithm>
61#include <cmath>
62
63namespace openswmm {
64 struct SimulationContext;
65}
66
67namespace openswmm::hydraulics {
68
78public:
80
81 // -----------------------------------------------------------------------
82 // Core timestep computation
83 // -----------------------------------------------------------------------
84
105 static double compute_next(const SimulationContext& ctx, double dt_cfl) noexcept;
106
107 // -----------------------------------------------------------------------
108 // Timer management
109 // -----------------------------------------------------------------------
110
122 static void advance(SimulationContext& ctx, double dt_taken) noexcept;
123
131 static void reset_output_timer(SimulationContext& ctx) noexcept;
132
133 // -----------------------------------------------------------------------
134 // State queries
135 // -----------------------------------------------------------------------
136
146 static bool output_due(const SimulationContext& ctx) noexcept;
147
152 static bool simulation_complete(const SimulationContext& ctx) noexcept;
153
154 // -----------------------------------------------------------------------
155 // Constants
156 // -----------------------------------------------------------------------
157
159 static constexpr double OUTPUT_EPSILON = 1.0e-6;
160
162 static constexpr double SEC_PER_DAY = 86400.0;
163};
164
165} /* namespace openswmm::hydraulics */
166
167#endif /* OPENSWMM_ENGINE_TIMESTEP_CONTROLLER_HPP */
Static utility class for explicit timestep computation.
Definition TimestepController.hpp:77
static void advance(SimulationContext &ctx, double dt_taken) noexcept
Advance internal timers by dt_taken seconds.
Definition TimestepController.cpp:64
static double compute_next(const SimulationContext &ctx, double dt_cfl) noexcept
Compute the next simulation timestep.
Definition TimestepController.cpp:25
static constexpr double OUTPUT_EPSILON
Epsilon for output-time floating-point comparison (seconds).
Definition TimestepController.hpp:159
static bool output_due(const SimulationContext &ctx) noexcept
Returns true when simulation clock has reached an output boundary.
Definition TimestepController.cpp:94
static bool simulation_complete(const SimulationContext &ctx) noexcept
Returns true when the simulation has reached or passed end_time.
Definition TimestepController.cpp:102
static void reset_output_timer(SimulationContext &ctx) noexcept
Reset the output countdown timer to the full report step.
Definition TimestepController.cpp:86
static constexpr double SEC_PER_DAY
Seconds per day (exact).
Definition TimestepController.hpp:162
Definition TimestepController.cpp:19
Definition Controls.cpp:24
Central, reentrant simulation context.
Definition SimulationContext.hpp:141