OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
ISurfaceSolver.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
38
39#ifndef OPENSWMM_ENGINE_2D_I_SURFACE_SOLVER_HPP
40#define OPENSWMM_ENGINE_2D_I_SURFACE_SOLVER_HPP
41
42#include <vector>
43
44namespace openswmm::twoD {
45
46// Forward declarations — passed by reference, no definitions needed here.
47struct MeshData;
48struct SurfaceStateData;
49struct SolverOptions2D;
50
64public:
65 virtual ~ISurfaceSolver() = default;
66
68 virtual void initialize(MeshData& mesh, SurfaceStateData& state,
69 SolverOptions2D& opts) = 0;
70
73 virtual double advance(double t_current, double t_target) = 0;
74
76 virtual void reinitialize(double t0) = 0;
77
84 virtual void resyncFromVolumes(double t0) { reinitialize(t0); }
85
87 virtual void finalize() = 0;
88
90 virtual long last_num_steps() const noexcept = 0;
91
93 virtual double last_step_size() const noexcept = 0;
94
98 virtual const std::vector<double>& last_coupling_exchange() const noexcept {
99 static const std::vector<double> kEmpty;
100 return kEmpty;
101 }
102
105 struct RunStats {
106 long nsteps = 0;
107 long nrhs = 0;
108 double last_h = 0.0;
109 double avg_h = 0.0;
110
111 // Marcher telemetry. Guarded: n_tiers == 0 and negative fractions
112 // mean "not populated".
113 double active_frac_min = -1.0;
114 double active_frac_mean = -1.0;
115 double active_frac_max = -1.0;
116 long tier_cells[8] = {0};
117 int n_tiers = 0;
118 };
119
121 virtual RunStats run_stats() const noexcept { return {}; }
122
124 virtual bool is_initialized() const noexcept = 0;
125};
126
127} // namespace openswmm::twoD
128
129#endif // OPENSWMM_ENGINE_2D_I_SURFACE_SOLVER_HPP
Abstract time integrator for the 2D surface-routing ODE system.
Definition ISurfaceSolver.hpp:63
virtual void initialize(MeshData &mesh, SurfaceStateData &state, SolverOptions2D &opts)=0
One-time setup. mesh and state must outlive the solver.
virtual bool is_initialized() const noexcept=0
True once initialize() has completed and the solver is ready.
virtual double advance(double t_current, double t_target)=0
virtual void reinitialize(double t0)=0
Reinitialize the integrator at t0 after external state edits.
virtual RunStats run_stats() const noexcept
Read cumulative statistics. Default: zeros (backend has no counters).
Definition ISurfaceSolver.hpp:121
virtual void resyncFromVolumes(double t0)
Definition ISurfaceSolver.hpp:84
virtual void finalize()=0
Release all backend resources.
virtual const std::vector< double > & last_coupling_exchange() const noexcept
Definition ISurfaceSolver.hpp:98
virtual long last_num_steps() const noexcept=0
Number of internal integrator steps in the last advance() call.
virtual ~ISurfaceSolver()=default
virtual double last_step_size() const noexcept=0
Last internal step size used by the integrator.
Definition NodeCoupling.cpp:16
Definition ISurfaceSolver.hpp:105
double active_frac_mean
mean active-cell fraction
Definition ISurfaceSolver.hpp:114
int n_tiers
populated tier count (≤ 8)
Definition ISurfaceSolver.hpp:117
double last_h
last accepted internal step (s)
Definition ISurfaceSolver.hpp:108
long nsteps
internal (marcher) substeps
Definition ISurfaceSolver.hpp:106
double active_frac_min
min active-cell fraction (rebuild samples)
Definition ISurfaceSolver.hpp:113
double active_frac_max
max active-cell fraction
Definition ISurfaceSolver.hpp:115
long nrhs
face-kernel evaluations
Definition ISurfaceSolver.hpp:107
double avg_h
sim-time / nsteps (s), filled by the caller
Definition ISurfaceSolver.hpp:109
long tier_cells[8]
cumulative rebuild-sampled cells per LTS tier
Definition ISurfaceSolver.hpp:116
SoA storage for 2D mixed triangle/quad mesh geometry and topology.
Definition MeshData.hpp:67
Configuration for the 2D surface routing solver.
Definition SolverOptions2D.hpp:208
Definition SurfaceStateData.hpp:59