OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
SubcatchData.hpp
Go to the documentation of this file.
1
18#ifndef OPENSWMM_ENGINE_SUBCATCH_DATA_HPP
19#define OPENSWMM_ENGINE_SUBCATCH_DATA_HPP
20
21#include <vector>
22#include <string>
23#include <cstdint>
24
25namespace openswmm {
26
27// ============================================================================
28// SubcatchData — SoA layout
29// ============================================================================
30
40
41 // -----------------------------------------------------------------------
42 // Static properties — set at parse time
43 // -----------------------------------------------------------------------
44
51 std::vector<int> outlet_node;
52
57 std::vector<int> outlet_subcatch;
58
64 std::vector<std::string> outlet_name;
65
70 std::vector<int> gage;
71
76 std::vector<double> area;
77
82 std::vector<double> width;
83
88 std::vector<double> slope;
89
94 std::vector<double> curb_length;
95
100 std::vector<double> frac_imperv;
101
106 std::vector<double> frac_imperv_no_store;
107
112 std::vector<double> n_imperv;
113
118 std::vector<double> n_perv;
119
124 std::vector<double> ds_imperv;
125
130 std::vector<double> ds_perv;
131
132 // -----------------------------------------------------------------------
133 // Inter-subarea routing (from [SUBAREAS] section)
134 // -----------------------------------------------------------------------
135
143 std::vector<int> subarea_routing;
144
151 std::vector<double> pct_routed;
152
153 // -----------------------------------------------------------------------
154 // Infiltration parameters (per subcatchment)
155 // -----------------------------------------------------------------------
156
158 std::vector<int> infil_model;
159
161 std::vector<double> infil_p1;
163 std::vector<double> infil_p2;
165 std::vector<double> infil_p3;
167 std::vector<double> infil_p4;
169 std::vector<double> infil_p5;
170
171 // -----------------------------------------------------------------------
172 // State variables — updated each timestep
173 // -----------------------------------------------------------------------
174
179 std::vector<double> runoff;
180
185 std::vector<double> rainfall;
186
191 std::vector<double> evap_loss;
192
197 std::vector<double> infil_loss;
198
203 std::vector<double> ponded_depth;
204
209 std::vector<double> gw_flow;
210
211 // -----------------------------------------------------------------------
212 // Previous-step state
213 // -----------------------------------------------------------------------
214
216 std::vector<double> old_runoff;
217
218 // -----------------------------------------------------------------------
219 // Cumulative statistics
220 // -----------------------------------------------------------------------
221
226 std::vector<double> stat_precip_vol;
227 std::vector<double> stat_evap_vol;
228 std::vector<double> stat_infil_vol;
229 std::vector<double> stat_imperv_vol;
230 std::vector<double> stat_perv_vol;
231
236 std::vector<double> stat_runoff_vol;
237
242 std::vector<double> stat_max_runoff;
243
244 // -----------------------------------------------------------------------
245 // Groundwater parameters (from [GROUNDWATER] section)
246 // -----------------------------------------------------------------------
247
249 std::vector<int> gw_aquifer;
250
252 std::vector<int> gw_node;
253
255 std::vector<double> gw_surf_elev;
256
258 std::vector<double> gw_a1;
259
261 std::vector<double> gw_b1;
262
264 std::vector<double> gw_a2;
265
267 std::vector<double> gw_b2;
268
270 std::vector<double> gw_a3;
271
273 std::vector<double> gw_tw;
274
276 std::vector<double> gw_hstar;
277
278 // -----------------------------------------------------------------------
279 // Snowpack assignment (index into SnowpackStore, -1 = none)
280 // -----------------------------------------------------------------------
281
283 std::vector<int> snowpack;
284
285 // -----------------------------------------------------------------------
286 // Cumulative pollutant washoff loads — flat 2D: [subcatch * n_pollutants + pollutant]
287 // -----------------------------------------------------------------------
288
293 std::vector<double> total_load;
294
297
298 void resize_total_load(int n_sc, int n_poll) {
300 total_load.assign(
301 static_cast<std::size_t>(n_sc) * static_cast<std::size_t>(n_poll), 0.0);
302 }
303
304 // -----------------------------------------------------------------------
305 // Land-use coverage — flat 2D: [subcatch * n_landuses + landuse]
306 // -----------------------------------------------------------------------
307
312 std::vector<double> coverage;
313
316
322 void resize_coverage(int n_sc, int n_lu) {
323 coverage_n_landuses = n_lu;
324 coverage.assign(
325 static_cast<std::size_t>(n_sc) * static_cast<std::size_t>(n_lu),
326 0.0);
327 }
328
329 // -----------------------------------------------------------------------
330 // Capacity management
331 // -----------------------------------------------------------------------
332
333 int count() const noexcept { return static_cast<int>(area.size()); }
334
335 void resize(int n) {
336 const auto un = static_cast<std::size_t>(n);
337
338 outlet_node.assign(un, -1);
339 outlet_subcatch.assign(un, -1);
340 outlet_name.resize(un);
341 gage.assign(un, -1);
342 area.assign(un, 0.0);
343 width.assign(un, 0.0);
344 slope.assign(un, 0.0);
345 curb_length.assign(un, 0.0);
346 frac_imperv.assign(un, 0.0);
347 frac_imperv_no_store.assign(un, 0.0);
348 n_imperv.assign(un, 0.013);
349 n_perv.assign(un, 0.1);
350 ds_imperv.assign(un, 0.0);
351 ds_perv.assign(un, 0.0);
352 subarea_routing.assign(un, 0); // TO_OUTLET
353 pct_routed.assign(un, 0.0);
354
355 infil_model.assign(un, 0);
356 infil_p1.assign(un, 0.0);
357 infil_p2.assign(un, 0.0);
358 infil_p3.assign(un, 0.0);
359 infil_p4.assign(un, 0.0);
360 infil_p5.assign(un, 0.0);
361
362 runoff.assign(un, 0.0);
363 rainfall.assign(un, 0.0);
364 evap_loss.assign(un, 0.0);
365 infil_loss.assign(un, 0.0);
366 ponded_depth.assign(un, 0.0);
367 gw_flow.assign(un, 0.0);
368 old_runoff.assign(un, 0.0);
369
370 stat_precip_vol.assign(un, 0.0);
371 stat_evap_vol.assign(un, 0.0);
372 stat_infil_vol.assign(un, 0.0);
373 stat_imperv_vol.assign(un, 0.0);
374 stat_perv_vol.assign(un, 0.0);
375 stat_runoff_vol.assign(un, 0.0);
376 stat_max_runoff.assign(un, 0.0);
377
378 gw_aquifer.assign(un, -1);
379 gw_node.assign(un, -1);
380 gw_surf_elev.assign(un, 0.0);
381 gw_a1.assign(un, 0.0);
382 gw_b1.assign(un, 0.0);
383 gw_a2.assign(un, 0.0);
384 gw_b2.assign(un, 0.0);
385 gw_a3.assign(un, 0.0);
386 gw_tw.assign(un, 0.0);
387 gw_hstar.assign(un, 0.0);
388 snowpack.assign(un, -1);
389 }
390
391 void save_state() noexcept {
393 }
394
395 void reset_state() noexcept {
396 std::fill(runoff.begin(), runoff.end(), 0.0);
397 std::fill(rainfall.begin(), rainfall.end(), 0.0);
398 std::fill(evap_loss.begin(), evap_loss.end(), 0.0);
399 std::fill(infil_loss.begin(), infil_loss.end(), 0.0);
400 std::fill(ponded_depth.begin(), ponded_depth.end(), 0.0);
401 std::fill(old_runoff.begin(), old_runoff.end(), 0.0);
402 }
403};
404
405} /* namespace openswmm */
406
407#endif /* OPENSWMM_ENGINE_SUBCATCH_DATA_HPP */
Definition Controls.cpp:24
Structure-of-Arrays storage for all subcatchments.
Definition SubcatchData.hpp:39
std::vector< int > gage
Rain gage index for this subcatchment.
Definition SubcatchData.hpp:70
void reset_state() noexcept
Definition SubcatchData.hpp:395
std::vector< int > infil_model
Infiltration model: 0=HORTON, 1=MOD_HORTON, 2=GREEN_AMPT, 3=MOD_GREEN_AMPT, 4=CURVE_NUMBER.
Definition SubcatchData.hpp:158
std::vector< double > gw_b2
Groundwater flow exponent B2.
Definition SubcatchData.hpp:267
int total_load_n_pollutants
Number of pollutants in total_load matrix.
Definition SubcatchData.hpp:296
std::vector< double > stat_precip_vol
Total precipitation volume (project volume units).
Definition SubcatchData.hpp:226
std::vector< double > gw_surf_elev
Surface elevation for groundwater calculations.
Definition SubcatchData.hpp:255
std::vector< double > slope
Average slope of catchment (fraction).
Definition SubcatchData.hpp:88
std::vector< double > infil_p1
Infiltration param 1: f0 (Horton), suction (GA), CN (CN).
Definition SubcatchData.hpp:161
std::vector< int > snowpack
Snowpack index for this subcatchment (-1 = none).
Definition SubcatchData.hpp:283
std::vector< double > gw_tw
Threshold groundwater table elevation.
Definition SubcatchData.hpp:273
std::vector< double > evap_loss
Current evaporation loss rate (project length/time units).
Definition SubcatchData.hpp:191
std::vector< double > old_runoff
Runoff at the previous timestep.
Definition SubcatchData.hpp:216
std::vector< double > stat_infil_vol
Cumulative infiltration volume (ft3)
Definition SubcatchData.hpp:228
std::vector< double > gw_flow
Groundwater outflow rate (project flow units).
Definition SubcatchData.hpp:209
std::vector< double > stat_evap_vol
Cumulative evaporation volume (ft3)
Definition SubcatchData.hpp:227
std::vector< double > stat_perv_vol
Cumulative pervious runoff volume (ft3)
Definition SubcatchData.hpp:230
std::vector< double > area
Subcatchment area (project area units).
Definition SubcatchData.hpp:76
std::vector< double > gw_a3
Groundwater flow coefficient A3.
Definition SubcatchData.hpp:270
std::vector< int > outlet_subcatch
Index of the subcatch that receives overflow (-1 if none).
Definition SubcatchData.hpp:57
std::vector< double > gw_hstar
Water table elevation at which lateral GW flow ceases.
Definition SubcatchData.hpp:276
int coverage_n_landuses
Number of landuses stored in the coverage matrix.
Definition SubcatchData.hpp:315
std::vector< double > stat_runoff_vol
Total runoff volume (project volume units).
Definition SubcatchData.hpp:236
std::vector< double > n_imperv
Manning's n for impervious area.
Definition SubcatchData.hpp:112
std::vector< double > n_perv
Manning's n for pervious area.
Definition SubcatchData.hpp:118
std::vector< double > infil_p4
Infiltration param 4: dry time (Horton), 0 (GA/CN).
Definition SubcatchData.hpp:167
void resize_coverage(int n_sc, int n_lu)
Resize the coverage matrix.
Definition SubcatchData.hpp:322
std::vector< double > gw_a2
Groundwater flow coefficient A2.
Definition SubcatchData.hpp:264
std::vector< std::string > outlet_name
Outlet name string for deferred resolution.
Definition SubcatchData.hpp:64
std::vector< double > stat_imperv_vol
Cumulative impervious runoff volume (ft3)
Definition SubcatchData.hpp:229
std::vector< double > pct_routed
Fraction of runoff routed between subareas (0–1).
Definition SubcatchData.hpp:151
std::vector< double > infil_p2
Infiltration param 2: fmin (Horton), conductivity (GA), 0 (CN).
Definition SubcatchData.hpp:163
std::vector< double > gw_a1
Groundwater flow coefficient A1.
Definition SubcatchData.hpp:258
void resize(int n)
Definition SubcatchData.hpp:335
std::vector< double > ds_perv
Depression storage depth for pervious area (project length units).
Definition SubcatchData.hpp:130
std::vector< double > width
Width of overland flow path (project length units).
Definition SubcatchData.hpp:82
std::vector< double > infil_loss
Current infiltration loss rate (project length/time units).
Definition SubcatchData.hpp:197
std::vector< double > frac_imperv_no_store
Fraction of impervious area with no depression storage (0–1).
Definition SubcatchData.hpp:106
int count() const noexcept
Definition SubcatchData.hpp:333
void resize_total_load(int n_sc, int n_poll)
Definition SubcatchData.hpp:298
std::vector< int > gw_aquifer
Aquifer index for this subcatchment (-1 = none).
Definition SubcatchData.hpp:249
std::vector< int > outlet_node
Index of the drain-to node or subcatchment.
Definition SubcatchData.hpp:51
std::vector< double > runoff
Current total runoff flow rate (project flow units).
Definition SubcatchData.hpp:179
std::vector< double > coverage
Coverage fraction per (subcatchment x landuse).
Definition SubcatchData.hpp:312
std::vector< double > stat_max_runoff
Maximum reported runoff rate (project flow units).
Definition SubcatchData.hpp:242
std::vector< double > infil_p5
Infiltration param 5: max infil (Horton), 0 (GA/CN).
Definition SubcatchData.hpp:169
std::vector< double > rainfall
Current total rainfall depth rate (project length/time units).
Definition SubcatchData.hpp:185
std::vector< double > ponded_depth
Current total ponded depth over subcatchment (project length units).
Definition SubcatchData.hpp:203
void save_state() noexcept
Definition SubcatchData.hpp:391
std::vector< double > frac_imperv
Fraction of area that is impervious (0–1).
Definition SubcatchData.hpp:100
std::vector< int > gw_node
Receiving node index for groundwater flow (-1 = none).
Definition SubcatchData.hpp:252
std::vector< double > gw_b1
Groundwater flow exponent B1.
Definition SubcatchData.hpp:261
std::vector< double > infil_p3
Infiltration param 3: decay (Horton), initial deficit (GA), 0 (CN).
Definition SubcatchData.hpp:165
std::vector< double > total_load
Total washoff load per (subcatchment x pollutant) (mass units).
Definition SubcatchData.hpp:293
std::vector< double > ds_imperv
Depression storage depth for impervious area (project length units).
Definition SubcatchData.hpp:124
std::vector< int > subarea_routing
Inter-subarea routing mode.
Definition SubcatchData.hpp:143
std::vector< double > curb_length
Total curb length (project length units).
Definition SubcatchData.hpp:94