OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
NodeCoupling.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
36
37#ifndef OPENSWMM_ENGINE_2D_NODE_COUPLING_HPP
38#define OPENSWMM_ENGINE_2D_NODE_COUPLING_HPP
39
40#include <unordered_map>
41
42#include "../data/MeshData.hpp"
45
46// Forward declaration — avoid pulling in full SimulationContext
47namespace openswmm {
49struct NodeData;
50}
51
52namespace openswmm::twoD {
53
61 double cd;
62 double area;
68 bool area_authored = true;
69};
70
81std::vector<CouplingPoint> buildCouplingPoints(const MeshData& mesh,
82 const SimulationContext& ctx);
83
96 const MeshData& mesh,
97 const SurfaceStateData& state,
98 const NodeData& nodes,
99 const SolverOptions2D& opts) noexcept;
100
101
102
119int accumulateOutfallDischargeStep(const std::vector<CouplingPoint>& cps,
120 const MeshData& mesh,
121 const SurfaceStateData& state,
122 const SimulationContext& ctx,
123 const SolverOptions2D& opts,
124 double dt,
125 std::vector<double>& accum_m3,
126 std::vector<double>& cell_budget_m3,
127 double* sample_row);
128
148void injectAccumulatedExchange(const std::vector<CouplingPoint>& cps,
149 const MeshData& mesh,
150 SurfaceStateData& state,
151 const std::vector<double>& accum_m3,
152 double window_dt,
153 double sign,
154 const std::vector<double>* node_conc = nullptr);
155
182double computeNodeCouplingQ(const CouplingPoint& cp,
183 const MeshData& mesh,
184 const SurfaceStateData& state,
185 const NodeData& nodes,
186 const SolverOptions2D& opts,
187 const double* provisional_vol_m3 = nullptr,
188 double h1d_offset_m = 0.0) noexcept;
189
200void scatterCouplingToYdot(const MeshData& mesh,
201 const SurfaceStateData& state,
202 const CouplingPoint& cp,
203 double Q,
204 double* ydot) noexcept;
205
219void updateOutfallBoundaries(const std::vector<CouplingPoint>& cps,
220 const MeshData& mesh,
221 const SurfaceStateData& state,
223 const SolverOptions2D& opts);
224
225
226} // namespace openswmm::twoD
227
228#endif // OPENSWMM_ENGINE_2D_NODE_COUPLING_HPP
Structure-of-Arrays (SoA) storage for 2D triangular mesh geometry.
Configuration options for the 2D surface routing solver.
Structure-of-Arrays (SoA) storage for 2D surface routing state.
Definition NodeCoupling.cpp:16
double computeNodeCouplingQ(const CouplingPoint &cp, const MeshData &mesh, const SurfaceStateData &state, const NodeData &nodes, const SolverOptions2D &opts, const double *provisional_vol_m3, double h1d_offset_m) noexcept
Live node-coupling orifice flux for ONE non-outfall coupling point.
Definition NodeCoupling.cpp:180
int accumulateOutfallDischargeStep(const std::vector< CouplingPoint > &cps, const MeshData &mesh, const SurfaceStateData &state, const SimulationContext &ctx, const SolverOptions2D &opts, double dt, std::vector< double > &accum_m3, std::vector< double > &cell_budget_m3, double *sample_row)
Per-routing-step outfall discharge accumulation.
Definition NodeCoupling.cpp:626
void scatterCouplingToYdot(const MeshData &mesh, const SurfaceStateData &state, const CouplingPoint &cp, double Q, double *ydot) noexcept
Scatter a signed volumetric exchange Q (m³/s) directly onto the cell derivatives ydot[] of the 2D vol...
Definition NodeCoupling.cpp:328
void injectAccumulatedExchange(const std::vector< CouplingPoint > &cps, const MeshData &mesh, SurfaceStateData &state, const std::vector< double > &accum_m3, double window_dt, double sign, const std::vector< double > *node_conc)
Inject a per-point accumulated exchange volume into the 2D window source field.
Definition NodeCoupling.cpp:670
std::vector< CouplingPoint > buildCouplingPoints(const MeshData &mesh, const SimulationContext &ctx)
Build the list of coupling points from mesh coupling maps.
Definition NodeCoupling.cpp:372
void updateOutfallBoundaries(const std::vector< CouplingPoint > &cps, const MeshData &mesh, const SurfaceStateData &state, SimulationContext &ctx, const SolverOptions2D &opts)
Update outfall boundary depths from 2D surface heads.
Definition NodeCoupling.cpp:452
double computeNodeCouplingDQdh1d(const CouplingPoint &cp, const MeshData &mesh, const SurfaceStateData &state, const NodeData &nodes, const SolverOptions2D &opts) noexcept
Head sensitivity G = −∂Q/∂h_1d ≥ 0 of the coupling orifice at a point (SI: m³/s per m of 1D head,...
Definition NodeCoupling.cpp:280
Definition NodeCoupling.cpp:16
@ Q
flow (cfs)
Definition ReactionTokens.hpp:43
Structure-of-Arrays storage for all nodes.
Definition NodeData.hpp:130
Central, reentrant simulation context.
Definition SimulationContext.hpp:353
Descriptor for a single coupling point between 2D and 1D.
Definition NodeCoupling.hpp:57
double area
Effective exchange area (m²)
Definition NodeCoupling.hpp:62
bool is_outfall
True if the SWMM node is an outfall.
Definition NodeCoupling.hpp:63
bool has_flap_gate
Definition NodeCoupling.hpp:64
int vertex_idx
Vertex index (-1 if triangle-centroid coupling)
Definition NodeCoupling.hpp:59
int cell_idx
Triangle index in the 2D mesh.
Definition NodeCoupling.hpp:58
int node_idx
SWMM node index.
Definition NodeCoupling.hpp:60
double cd
Discharge coefficient.
Definition NodeCoupling.hpp:61
bool area_authored
Definition NodeCoupling.hpp:68
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