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
84
85#ifndef OPENSWMM_ENGINE_TIMESTEP_CONTROLLER_HPP
86#define OPENSWMM_ENGINE_TIMESTEP_CONTROLLER_HPP
87
88#include <algorithm>
89#include <cmath>
90
91namespace openswmm {
93}
94
95namespace openswmm::hydraulics {
96
106public:
111
112 // -----------------------------------------------------------------------
113 // Core timestep computation
114 // -----------------------------------------------------------------------
115
135 static double compute_next(const SimulationContext& ctx, double dt_cfl) noexcept;
136
137 // -----------------------------------------------------------------------
138 // Timer management
139 // -----------------------------------------------------------------------
140
154 static void advance(SimulationContext& ctx, double dt_taken) noexcept;
155
165 static void reset_output_timer(SimulationContext& ctx) noexcept;
166
167 // -----------------------------------------------------------------------
168 // State queries
169 // -----------------------------------------------------------------------
170
181 static bool output_due(const SimulationContext& ctx) noexcept;
182
187 static bool simulation_complete(const SimulationContext& ctx) noexcept;
188
189 // -----------------------------------------------------------------------
190 // Constants
191 // -----------------------------------------------------------------------
192
194 static constexpr double SEC_PER_DAY = 86400.0;
195};
196
197} /* namespace openswmm::hydraulics */
198
199#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:97
static double compute_next(const SimulationContext &ctx, double dt_cfl) noexcept
Compute the next simulation timestep.
Definition TimestepController.cpp:43
TimestepController()=delete
Prohibit constructing this static timestep-policy utility.
static bool output_due(const SimulationContext &ctx) noexcept
Returns true when the clock has reached the next report instant.
Definition TimestepController.cpp:131
static bool simulation_complete(const SimulationContext &ctx) noexcept
Returns true when the simulation has reached or passed end_time.
Definition TimestepController.cpp:140
static void reset_output_timer(SimulationContext &ctx) noexcept
Advance the report grid to the next period.
Definition TimestepController.cpp:120
static constexpr double SEC_PER_DAY
Seconds per day (exact).
Definition TimestepController.hpp:194
Definition AquiferLinkExchange.hpp:54
Definition ExchangeLaw.hpp:60
Central, reentrant simulation context.
Definition SimulationContext.hpp:390