OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
CheckedNetworkAdvance.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Caleb Buahin
3
12
13#pragma once
14
15#include <algorithm>
16#include <cmath>
17#include <limits>
18#include <stdexcept>
19
20#include "INetworkSolver.hpp"
21
22namespace openswmm::fv {
23
40inline double advanceNetworkChecked(INetworkSolver& solver, double start, double target,
41 const FvStepForcing& forcing) {
42 if (!std::isfinite(start) || !std::isfinite(target) || target < start)
43 throw std::invalid_argument("FV routing times must be finite and ordered.");
44 const double reached = solver.advance(start, target, forcing);
45 const double tolerance = 16.0 * std::numeric_limits<double>::epsilon() *
46 std::max({1.0, std::fabs(start), std::fabs(target)});
47 if (!std::isfinite(reached) || reached < start || std::fabs(reached - target) > tolerance)
48 throw std::runtime_error("FV backend did not reach the requested routing time; "
49 "partial results were not published.");
50 return reached;
51}
52
53} // namespace openswmm::fv
Backend-neutral interface for the explicit FV 1D network integrator.
Abstract time integrator for the explicit FV 1D network.
Definition INetworkSolver.hpp:135
virtual double advance(double t_current, double t_target, const FvStepForcing &forcing)=0
Advance bound network state across one requested routing window.
Definition AcceptedWaterVolumes.hpp:8
double advanceNetworkChecked(INetworkSolver &solver, double start, double target, const FvStepForcing &forcing)
Advance an FV backend and verify it reached the full requested time window.
Definition CheckedNetworkAdvance.hpp:40
Definition INetworkSolver.hpp:58