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
48 int count() const { return static_cast<int>(names.size()); }
49
50 std::vector<std::string> names;
51 std::vector<std::string> comments;
52 std::vector<double> n_left;
53 std::vector<double> n_right;
54 std::vector<double> n_channel;
55 std::vector<double> x_left_bank;
56 std::vector<double> x_right_bank;
61 std::vector<double> x_left_encroachment;
62 std::vector<double> x_right_encroachment;
63 std::vector<double> x_factor;
64 std::vector<double> y_factor;
65 std::vector<double>
68 std::vector<std::vector<double>> stations;
69 std::vector<std::vector<double>> elevations;
70};
71
72// ============================================================================
73// Street definitions (from [STREETS] section)
74// ============================================================================
75
82 int count() const { return static_cast<int>(names.size()); }
83
84 std::vector<std::string> names;
85 std::vector<double> t_crown;
86 std::vector<double> h_curb;
87 std::vector<double> sx;
88 std::vector<double> n_road;
89 std::vector<double> gutter_depres;
90 std::vector<double> gutter_width;
91 std::vector<int> sides;
92 std::vector<double> back_width;
93 std::vector<double> back_slope;
94 std::vector<double> back_n;
95};
96
97// ============================================================================
98// Inlet definitions (from [INLETS] section)
99// ============================================================================
100
120 int count() const { return static_cast<int>(names.size()); }
121
122 std::vector<std::string> names;
123 std::vector<std::string> inlet_type;
124 std::vector<double> length;
125 std::vector<double> width;
126 std::vector<std::string>
128 std::vector<double> open_area;
129 std::vector<double> splash_veloc;
130 std::vector<double> curb_length;
131 std::vector<double> curb_height;
132 std::vector<int>
134 std::vector<std::string> curve_id;
135 std::vector<int> curve_index;
136 std::vector<int>
138 std::vector<std::string> comments;
139
150 int add_row(const std::string& name, const std::string& type) {
151 names.push_back(name);
152 inlet_type.push_back(type);
153 length.push_back(0.0);
154 width.push_back(0.0);
155 grate_type.push_back("");
156 open_area.push_back(0.0);
157 splash_veloc.push_back(0.0);
158 curb_length.push_back(0.0);
159 curb_height.push_back(0.0);
160 curb_throat.push_back(2);
161 curve_id.push_back("");
162 curve_index.push_back(-1);
163 curve_kind.push_back(0);
164 comments.push_back("");
165 return count() - 1;
166 }
167
176 void erase_row(int idx) {
177 auto u = static_cast<std::size_t>(idx);
178 names.erase(names.begin() + static_cast<std::ptrdiff_t>(u));
179 inlet_type.erase(inlet_type.begin() + static_cast<std::ptrdiff_t>(u));
180 length.erase(length.begin() + static_cast<std::ptrdiff_t>(u));
181 width.erase(width.begin() + static_cast<std::ptrdiff_t>(u));
182 grate_type.erase(grate_type.begin() + static_cast<std::ptrdiff_t>(u));
183 open_area.erase(open_area.begin() + static_cast<std::ptrdiff_t>(u));
184 splash_veloc.erase(splash_veloc.begin() + static_cast<std::ptrdiff_t>(u));
185 curb_length.erase(curb_length.begin() + static_cast<std::ptrdiff_t>(u));
186 curb_height.erase(curb_height.begin() + static_cast<std::ptrdiff_t>(u));
187 curb_throat.erase(curb_throat.begin() + static_cast<std::ptrdiff_t>(u));
188 curve_id.erase(curve_id.begin() + static_cast<std::ptrdiff_t>(u));
189 curve_index.erase(curve_index.begin() + static_cast<std::ptrdiff_t>(u));
190 curve_kind.erase(curve_kind.begin() + static_cast<std::ptrdiff_t>(u));
191 comments.erase(comments.begin() + static_cast<std::ptrdiff_t>(u));
192 }
193};
194
195// ============================================================================
196// Inlet usage (from [INLET_USAGE] section)
197// ============================================================================
198
210 int count() const { return static_cast<int>(design_index.size()); }
211
212 std::vector<int> link_index;
213 std::vector<int> node_host;
214 std::vector<int> design_index;
215 std::vector<int> node_index;
216 std::vector<int> num_inlets;
217 std::vector<int> placement;
218 std::vector<double> clog_factor;
219 std::vector<double> flow_limit;
220 std::vector<double> local_depress;
221 std::vector<double> local_width;
222 std::vector<int>
227 std::vector<std::string> pending_design_name;
228 std::vector<std::string> pending_capture_name;
229
243 int add_row(int link_idx, int node_host_idx, int design_idx, int capture_node_idx) {
244 link_index.push_back(link_idx);
245 node_host.push_back(node_host_idx);
246 design_index.push_back(design_idx);
247 node_index.push_back(capture_node_idx);
248 num_inlets.push_back(1);
249 placement.push_back(0);
250 clog_factor.push_back(1.0);
251 flow_limit.push_back(0.0);
252 local_depress.push_back(0.0);
253 local_width.push_back(0.0);
254 street_index.push_back(-1);
255 pending_design_name.emplace_back();
256 pending_capture_name.emplace_back();
257 return count() - 1;
258 }
259
268 void erase_row(int idx) {
269 auto e = [idx](auto& v) {
270 if (static_cast<std::size_t>(idx) < v.size())
271 v.erase(v.begin() + static_cast<std::ptrdiff_t>(idx));
272 };
273 e(link_index);
274 e(node_host);
275 e(design_index);
276 e(node_index);
277 e(num_inlets);
278 e(placement);
279 e(clog_factor);
280 e(flow_limit);
281 e(local_depress);
282 e(local_width);
283 e(street_index);
290 }
291
301 int find_by_link(int link_idx) const {
302 for (int i = 0; i < count(); ++i)
303 if (link_index[static_cast<std::size_t>(i)] == link_idx)
304 return i;
305 return -1;
306 }
307
316 int find_by_node_host(int node_idx) const {
317 for (int i = 0; i < count(); ++i)
318 if (node_host[static_cast<std::size_t>(i)] == node_idx)
319 return i;
320 return -1;
321 }
322
323 // Stats (populated by InletSolver::gatherStats() before reporting)
324 std::vector<double> stat_capture_vol;
325 std::vector<double> stat_bypass_vol;
326 std::vector<double> stat_backflow_vol;
327 std::vector<double> stat_peak_flow;
328
337 void resize_stats(int n) {
338 auto un = static_cast<std::size_t>(n);
339 stat_capture_vol.assign(un, 0.0);
340 stat_bypass_vol.assign(un, 0.0);
341 stat_backflow_vol.assign(un, 0.0);
342 stat_peak_flow.assign(un, 0.0);
343 }
344};
345
346// ============================================================================
347// Control rule text (from [CONTROLS] section)
348// ============================================================================
349
356 int count() const { return static_cast<int>(rule_text.size()); }
357
360 std::vector<std::string> rule_text;
361};
362
363} // namespace openswmm
364
365#endif // OPENSWMM_ENGINE_INFRA_DATA_HPP
Definition ExchangeLaw.hpp:60
Definition InfraData.hpp:350
int count() const
Count stored rows from the rule_text column.
Definition InfraData.hpp:356
std::vector< std::string > rule_text
Definition InfraData.hpp:360
Definition InfraData.hpp:114
std::vector< double > open_area
GENERIC only: open-area fraction (0,1].
Definition InfraData.hpp:128
std::vector< int > curve_index
CUSTOM: resolved curve index (-1 until PostParseResolver)
Definition InfraData.hpp:135
std::vector< double > width
grate or slotted width
Definition InfraData.hpp:125
std::vector< std::string > curve_id
CUSTOM: capture curve name.
Definition InfraData.hpp:134
void erase_row(int idx)
Erase one inlet design from every owned column.
Definition InfraData.hpp:176
std::vector< double > curb_height
CURB/DROP_CURB/COMBO.
Definition InfraData.hpp:131
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:127
std::vector< std::string > comments
optional description (round-tripped as ';' comment)
Definition InfraData.hpp:138
int count() const
Count stored rows from the names column.
Definition InfraData.hpp:120
std::vector< double > curb_length
CURB/DROP_CURB/COMBO.
Definition InfraData.hpp:130
std::vector< double > splash_veloc
GENERIC only: splash-over velocity.
Definition InfraData.hpp:129
int add_row(const std::string &name, const std::string &type)
Append a copied design name/type and default parameter columns.
Definition InfraData.hpp:150
std::vector< std::string > inlet_type
GRATE/CURB/COMBO/SLOTTED/DROP_GRATE/DROP_CURB/CUSTOM.
Definition InfraData.hpp:123
std::vector< double > length
grate or slotted length
Definition InfraData.hpp:124
std::vector< int > curb_throat
0=HORIZONTAL 1=INCLINED 2=VERTICAL (legacy ThroatAngleWords order); default 2
Definition InfraData.hpp:133
std::vector< std::string > names
Definition InfraData.hpp:122
std::vector< int > curve_kind
CUSTOM: 0=unresolved, 1=DIVERSION (captured vs approach flow), 2=RATING (captured vs depth)
Definition InfraData.hpp:137
Definition InfraData.hpp:204
std::vector< int > num_inlets
Number of inlets per side.
Definition InfraData.hpp:216
std::vector< int > street_index
Definition InfraData.hpp:223
int find_by_link(int link_idx) const
Find the first usage with a matching conduit-host key.
Definition InfraData.hpp:301
std::vector< std::string > pending_design_name
Definition InfraData.hpp:227
std::vector< std::string > pending_capture_name
Definition InfraData.hpp:228
std::vector< int > design_index
Index into InletStore.
Definition InfraData.hpp:214
std::vector< double > stat_capture_vol
Total captured volume (ft³)
Definition InfraData.hpp:324
std::vector< double > flow_limit
Max capture flow per inlet (user flow units), 0=unlimited.
Definition InfraData.hpp:219
void erase_row(int idx)
Erase a usage row from each column that contains it.
Definition InfraData.hpp:268
std::vector< int > node_index
Capture (receiving / underdrain) node index.
Definition InfraData.hpp:215
std::vector< int > node_host
Host inlet-junction node index (-1 for a conduit usage)
Definition InfraData.hpp:213
int add_row(int link_idx, int node_host_idx, int design_idx, int capture_node_idx)
Append an unresolved/default inlet usage with explicit host references.
Definition InfraData.hpp:243
int find_by_node_host(int node_idx) const
Find the first usage with a matching inlet-junction host key.
Definition InfraData.hpp:316
std::vector< double > local_width
Local depression width (user length units)
Definition InfraData.hpp:221
std::vector< double > local_depress
Local gutter depression (user length units)
Definition InfraData.hpp:220
std::vector< double > stat_peak_flow
Peak captured flow (cfs)
Definition InfraData.hpp:327
std::vector< int > placement
0=auto, 1=on_grade, 2=on_sag
Definition InfraData.hpp:217
std::vector< double > clog_factor
1.0 - pctClogged/100
Definition InfraData.hpp:218
int count() const
Count stored rows from the design_index column.
Definition InfraData.hpp:210
std::vector< int > link_index
Host conduit link index (-1 for an inlet junction)
Definition InfraData.hpp:212
std::vector< double > stat_backflow_vol
Total backflow volume (ft³)
Definition InfraData.hpp:326
void resize_stats(int n)
Replace inlet usage statistics with zeroed columns.
Definition InfraData.hpp:337
std::vector< double > stat_bypass_vol
Total bypassed volume (ft³)
Definition InfraData.hpp:325
Definition InfraData.hpp:76
std::vector< double > gutter_depres
Definition InfraData.hpp:89
std::vector< double > h_curb
Definition InfraData.hpp:86
std::vector< double > back_slope
Definition InfraData.hpp:93
std::vector< double > sx
Cross slope (%)
Definition InfraData.hpp:87
std::vector< double > back_n
Definition InfraData.hpp:94
std::vector< double > back_width
Definition InfraData.hpp:92
std::vector< double > gutter_width
Definition InfraData.hpp:90
int count() const
Count stored rows from the names column.
Definition InfraData.hpp:82
std::vector< double > t_crown
Definition InfraData.hpp:85
std::vector< int > sides
Definition InfraData.hpp:91
std::vector< std::string > names
Definition InfraData.hpp:84
std::vector< double > n_road
Definition InfraData.hpp:88
Definition InfraData.hpp:42
std::vector< std::string > comments
Free-form description per transect (DA-ENG-09)
Definition InfraData.hpp:51
std::vector< double > x_left_encroachment
Definition InfraData.hpp:61
std::vector< double > x_left_bank
Definition InfraData.hpp:55
std::vector< double > y_factor
Definition InfraData.hpp:64
std::vector< double > x_right_bank
Definition InfraData.hpp:56
std::vector< double > n_left
Definition InfraData.hpp:52
std::vector< std::vector< double > > stations
Station-elevation pairs per transect.
Definition InfraData.hpp:68
std::vector< double > x_factor
Definition InfraData.hpp:63
std::vector< double > n_channel
Definition InfraData.hpp:54
std::vector< std::vector< double > > elevations
Definition InfraData.hpp:69
std::vector< double > length_factor
Definition InfraData.hpp:66
int count() const
Count stored rows from the names column.
Definition InfraData.hpp:48
std::vector< double > x_right_encroachment
Definition InfraData.hpp:62
std::vector< std::string > names
Definition InfraData.hpp:50
std::vector< double > n_right
Definition InfraData.hpp:53