OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
InfraData.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
29
30#ifndef OPENSWMM_ENGINE_INFRA_DATA_HPP
31#define OPENSWMM_ENGINE_INFRA_DATA_HPP
32
33#include <vector>
34#include <string>
35
36namespace openswmm {
37
38// ============================================================================
39// Transect definitions (from [TRANSECTS] section)
40// ============================================================================
41
43 int count() const { return static_cast<int>(names.size()); }
44
45 std::vector<std::string> names;
46 std::vector<std::string> comments;
47 std::vector<double> n_left;
48 std::vector<double> n_right;
49 std::vector<double> n_channel;
50 std::vector<double> x_left_bank;
51 std::vector<double> x_right_bank;
56 std::vector<double> x_left_encroachment;
57 std::vector<double> x_right_encroachment;
58 std::vector<double> x_factor;
59 std::vector<double> y_factor;
60 std::vector<double> length_factor;
62 std::vector<std::vector<double>> stations;
63 std::vector<std::vector<double>> elevations;
64};
65
66// ============================================================================
67// Street definitions (from [STREETS] section)
68// ============================================================================
69
71 int count() const { return static_cast<int>(names.size()); }
72
73 std::vector<std::string> names;
74 std::vector<double> t_crown;
75 std::vector<double> h_curb;
76 std::vector<double> sx;
77 std::vector<double> n_road;
78 std::vector<double> gutter_depres;
79 std::vector<double> gutter_width;
80 std::vector<int> sides;
81 std::vector<double> back_width;
82 std::vector<double> back_slope;
83 std::vector<double> back_n;
84};
85
86// ============================================================================
87// Inlet definitions (from [INLETS] section)
88// ============================================================================
89
104 int count() const { return static_cast<int>(names.size()); }
105
106 std::vector<std::string> names;
107 std::vector<std::string> inlet_type;
108 std::vector<double> length;
109 std::vector<double> width;
110 std::vector<std::string> grate_type;
111 std::vector<double> open_area;
112 std::vector<double> splash_veloc;
113 std::vector<double> curb_length;
114 std::vector<double> curb_height;
115 std::vector<int> curb_throat;
116 std::vector<std::string> curve_id;
117 std::vector<int> curve_index;
118 std::vector<int> curve_kind;
119 std::vector<std::string> comments;
120
122 int add_row(const std::string& name, const std::string& type) {
123 names.push_back(name);
124 inlet_type.push_back(type);
125 length.push_back(0.0);
126 width.push_back(0.0);
127 grate_type.push_back("");
128 open_area.push_back(0.0);
129 splash_veloc.push_back(0.0);
130 curb_length.push_back(0.0);
131 curb_height.push_back(0.0);
132 curb_throat.push_back(2);
133 curve_id.push_back("");
134 curve_index.push_back(-1);
135 curve_kind.push_back(0);
136 comments.push_back("");
137 return count() - 1;
138 }
139
140 void erase_row(int idx) {
141 auto u = static_cast<std::size_t>(idx);
142 names.erase(names.begin() + static_cast<std::ptrdiff_t>(u));
143 inlet_type.erase(inlet_type.begin() + static_cast<std::ptrdiff_t>(u));
144 length.erase(length.begin() + static_cast<std::ptrdiff_t>(u));
145 width.erase(width.begin() + static_cast<std::ptrdiff_t>(u));
146 grate_type.erase(grate_type.begin() + static_cast<std::ptrdiff_t>(u));
147 open_area.erase(open_area.begin() + static_cast<std::ptrdiff_t>(u));
148 splash_veloc.erase(splash_veloc.begin() + static_cast<std::ptrdiff_t>(u));
149 curb_length.erase(curb_length.begin() + static_cast<std::ptrdiff_t>(u));
150 curb_height.erase(curb_height.begin() + static_cast<std::ptrdiff_t>(u));
151 curb_throat.erase(curb_throat.begin() + static_cast<std::ptrdiff_t>(u));
152 curve_id.erase(curve_id.begin() + static_cast<std::ptrdiff_t>(u));
153 curve_index.erase(curve_index.begin() + static_cast<std::ptrdiff_t>(u));
154 curve_kind.erase(curve_kind.begin() + static_cast<std::ptrdiff_t>(u));
155 comments.erase(comments.begin() + static_cast<std::ptrdiff_t>(u));
156 }
157};
158
159// ============================================================================
160// Inlet usage (from [INLET_USAGE] section)
161// ============================================================================
162
169 int count() const { return static_cast<int>(design_index.size()); }
170
171 std::vector<int> link_index;
172 std::vector<int> node_host;
173 std::vector<int> design_index;
174 std::vector<int> node_index;
175 std::vector<int> num_inlets;
176 std::vector<int> placement;
177 std::vector<double> clog_factor;
178 std::vector<double> flow_limit;
179 std::vector<double> local_depress;
180 std::vector<double> local_width;
181 std::vector<int> street_index;
185 std::vector<std::string> pending_design_name;
186 std::vector<std::string> pending_capture_name;
187
189 int add_row(int link_idx, int node_host_idx, int design_idx, int capture_node_idx) {
190 link_index.push_back(link_idx);
191 node_host.push_back(node_host_idx);
192 design_index.push_back(design_idx);
193 node_index.push_back(capture_node_idx);
194 num_inlets.push_back(1);
195 placement.push_back(0);
196 clog_factor.push_back(1.0);
197 flow_limit.push_back(0.0);
198 local_depress.push_back(0.0);
199 local_width.push_back(0.0);
200 street_index.push_back(-1);
201 pending_design_name.emplace_back();
202 pending_capture_name.emplace_back();
203 return count() - 1;
204 }
205
206 void erase_row(int idx) {
207 auto e = [idx](auto& v) {
208 if (static_cast<std::size_t>(idx) < v.size())
209 v.erase(v.begin() + static_cast<std::ptrdiff_t>(idx));
210 };
215 }
216
218 int find_by_link(int link_idx) const {
219 for (int i = 0; i < count(); ++i)
220 if (link_index[static_cast<std::size_t>(i)] == link_idx) return i;
221 return -1;
222 }
223
224 int find_by_node_host(int node_idx) const {
225 for (int i = 0; i < count(); ++i)
226 if (node_host[static_cast<std::size_t>(i)] == node_idx) return i;
227 return -1;
228 }
229
230 // Stats (populated by InletSolver::gatherStats() before reporting)
231 std::vector<double> stat_capture_vol;
232 std::vector<double> stat_bypass_vol;
233 std::vector<double> stat_backflow_vol;
234 std::vector<double> stat_peak_flow;
235
236 void resize_stats(int n) {
237 auto un = static_cast<std::size_t>(n);
238 stat_capture_vol.assign(un, 0.0);
239 stat_bypass_vol.assign(un, 0.0);
240 stat_backflow_vol.assign(un, 0.0);
241 stat_peak_flow.assign(un, 0.0);
242 }
243};
244
245// ============================================================================
246// Control rule text (from [CONTROLS] section)
247// ============================================================================
248
250 int count() const { return static_cast<int>(rule_text.size()); }
251
254 std::vector<std::string> rule_text;
255};
256
257} // namespace openswmm
258
259#endif // OPENSWMM_ENGINE_INFRA_DATA_HPP
Definition NodeCoupling.cpp:16
Definition InfraData.hpp:249
int count() const
Definition InfraData.hpp:250
std::vector< std::string > rule_text
Definition InfraData.hpp:254
Definition InfraData.hpp:103
std::vector< double > open_area
GENERIC only: open-area fraction (0,1].
Definition InfraData.hpp:111
std::vector< int > curve_index
CUSTOM: resolved curve index (-1 until PostParseResolver)
Definition InfraData.hpp:117
std::vector< double > width
grate or slotted width
Definition InfraData.hpp:109
std::vector< std::string > curve_id
CUSTOM: capture curve name.
Definition InfraData.hpp:116
void erase_row(int idx)
Definition InfraData.hpp:140
std::vector< double > curb_height
CURB/DROP_CURB/COMBO.
Definition InfraData.hpp:114
std::vector< std::string > grate_type
P_BAR-50, P_BAR-50x100, P_BAR-30, CURVED_VANE, TILT_BAR-45, TILT_BAR-30, RETICULINE,...
Definition InfraData.hpp:110
std::vector< std::string > comments
optional description (round-tripped as ';' comment)
Definition InfraData.hpp:119
int count() const
Definition InfraData.hpp:104
std::vector< double > curb_length
CURB/DROP_CURB/COMBO.
Definition InfraData.hpp:113
std::vector< double > splash_veloc
GENERIC only: splash-over velocity.
Definition InfraData.hpp:112
int add_row(const std::string &name, const std::string &type)
Append a fully defaulted row; returns its index.
Definition InfraData.hpp:122
std::vector< std::string > inlet_type
GRATE/CURB/COMBO/SLOTTED/DROP_GRATE/DROP_CURB/CUSTOM.
Definition InfraData.hpp:107
std::vector< double > length
grate or slotted length
Definition InfraData.hpp:108
std::vector< int > curb_throat
0=HORIZONTAL 1=INCLINED 2=VERTICAL (legacy ThroatAngleWords order); default 2
Definition InfraData.hpp:115
std::vector< std::string > names
Definition InfraData.hpp:106
std::vector< int > curve_kind
CUSTOM: 0=unresolved, 1=DIVERSION (captured vs approach flow), 2=RATING (captured vs depth)
Definition InfraData.hpp:118
Definition InfraData.hpp:168
std::vector< int > num_inlets
Number of inlets per side.
Definition InfraData.hpp:175
std::vector< int > street_index
Definition InfraData.hpp:181
int find_by_link(int link_idx) const
Row index of the usage hosted by conduit link_idx, or -1.
Definition InfraData.hpp:218
std::vector< std::string > pending_design_name
Definition InfraData.hpp:185
std::vector< std::string > pending_capture_name
Definition InfraData.hpp:186
std::vector< int > design_index
Index into InletStore.
Definition InfraData.hpp:173
std::vector< double > stat_capture_vol
Total captured volume (ft³)
Definition InfraData.hpp:231
std::vector< double > flow_limit
Max capture flow per inlet (user flow units), 0=unlimited.
Definition InfraData.hpp:178
void erase_row(int idx)
Definition InfraData.hpp:206
std::vector< int > node_index
Capture (receiving / underdrain) node index.
Definition InfraData.hpp:174
std::vector< int > node_host
Host inlet-junction node index (-1 for a conduit usage)
Definition InfraData.hpp:172
int add_row(int link_idx, int node_host_idx, int design_idx, int capture_node_idx)
Append a defaulted row; returns its index.
Definition InfraData.hpp:189
int find_by_node_host(int node_idx) const
Row index of the usage hosted by inlet-junction node node_idx, or -1.
Definition InfraData.hpp:224
std::vector< double > local_width
Local depression width (user length units)
Definition InfraData.hpp:180
std::vector< double > local_depress
Local gutter depression (user length units)
Definition InfraData.hpp:179
std::vector< double > stat_peak_flow
Peak captured flow (cfs)
Definition InfraData.hpp:234
std::vector< int > placement
0=auto, 1=on_grade, 2=on_sag
Definition InfraData.hpp:176
std::vector< double > clog_factor
1.0 - pctClogged/100
Definition InfraData.hpp:177
int count() const
Definition InfraData.hpp:169
std::vector< int > link_index
Host conduit link index (-1 for an inlet junction)
Definition InfraData.hpp:171
std::vector< double > stat_backflow_vol
Total backflow volume (ft³)
Definition InfraData.hpp:233
void resize_stats(int n)
Definition InfraData.hpp:236
std::vector< double > stat_bypass_vol
Total bypassed volume (ft³)
Definition InfraData.hpp:232
Definition InfraData.hpp:70
std::vector< double > gutter_depres
Definition InfraData.hpp:78
std::vector< double > h_curb
Definition InfraData.hpp:75
std::vector< double > back_slope
Definition InfraData.hpp:82
std::vector< double > sx
Cross slope (%)
Definition InfraData.hpp:76
std::vector< double > back_n
Definition InfraData.hpp:83
std::vector< double > back_width
Definition InfraData.hpp:81
std::vector< double > gutter_width
Definition InfraData.hpp:79
int count() const
Definition InfraData.hpp:71
std::vector< double > t_crown
Definition InfraData.hpp:74
std::vector< int > sides
Definition InfraData.hpp:80
std::vector< std::string > names
Definition InfraData.hpp:73
std::vector< double > n_road
Definition InfraData.hpp:77
Definition InfraData.hpp:42
std::vector< std::string > comments
Free-form description per transect (DA-ENG-09)
Definition InfraData.hpp:46
std::vector< double > x_left_encroachment
Definition InfraData.hpp:56
std::vector< double > x_left_bank
Definition InfraData.hpp:50
std::vector< double > y_factor
Definition InfraData.hpp:59
std::vector< double > x_right_bank
Definition InfraData.hpp:51
std::vector< double > n_left
Definition InfraData.hpp:47
std::vector< std::vector< double > > stations
Station-elevation pairs per transect.
Definition InfraData.hpp:62
std::vector< double > x_factor
Definition InfraData.hpp:58
std::vector< double > n_channel
Definition InfraData.hpp:49
std::vector< std::vector< double > > elevations
Definition InfraData.hpp:63
std::vector< double > length_factor
Definition InfraData.hpp:60
int count() const
Definition InfraData.hpp:43
std::vector< double > x_right_encroachment
Definition InfraData.hpp:57
std::vector< std::string > names
Definition InfraData.hpp:45
std::vector< double > n_right
Definition InfraData.hpp:48