OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
TimestepController.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2//
3// Copyright 2026 Caleb Buahin
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
79
80#ifndef OPENSWMM_ENGINE_TIMESTEP_CONTROLLER_HPP
81#define OPENSWMM_ENGINE_TIMESTEP_CONTROLLER_HPP
82
83#include <algorithm>
84#include <cmath>
85
86namespace openswmm {
87 struct SimulationContext;
88}
89
90namespace openswmm::hydraulics {
91
101public:
103
104 // -----------------------------------------------------------------------
105 // Core timestep computation
106 // -----------------------------------------------------------------------
107
127 static double compute_next(const SimulationContext& ctx, double dt_cfl) noexcept;
128
129 // -----------------------------------------------------------------------
130 // Timer management
131 // -----------------------------------------------------------------------
132
146 static void advance(SimulationContext& ctx, double dt_taken) noexcept;
147
157 static void reset_output_timer(SimulationContext& ctx) noexcept;
158
159 // -----------------------------------------------------------------------
160 // State queries
161 // -----------------------------------------------------------------------
162
173 static bool output_due(const SimulationContext& ctx) noexcept;
174
179 static bool simulation_complete(const SimulationContext& ctx) noexcept;
180
181 // -----------------------------------------------------------------------
182 // Constants
183 // -----------------------------------------------------------------------
184
185
187 static constexpr double SEC_PER_DAY = 86400.0;
188};
189
190} /* namespace openswmm::hydraulics */
191
192#endif /* OPENSWMM_ENGINE_TIMESTEP_CONTROLLER_HPP */
static void advance(SimulationContext &ctx, double dt_taken) noexcept
Advance internal timers by dt_taken seconds.
Definition TimestepController.cpp:99
static double compute_next(const SimulationContext &ctx, double dt_cfl) noexcept
Compute the next simulation timestep.
Definition TimestepController.cpp:43
static bool output_due(const SimulationContext &ctx) noexcept
Returns true when the clock has reached the next report instant.
Definition TimestepController.cpp:135
static bool simulation_complete(const SimulationContext &ctx) noexcept
Returns true when the simulation has reached or passed end_time.
Definition TimestepController.cpp:144
static void reset_output_timer(SimulationContext &ctx) noexcept
Advance the report grid to the next period.
Definition TimestepController.cpp:124
static constexpr double SEC_PER_DAY
Seconds per day (exact).
Definition TimestepController.hpp:187
Definition TimestepController.cpp:37
Definition NodeCoupling.cpp:16
Central, reentrant simulation context.
Definition SimulationContext.hpp:353