OpenSWMM Engine  6.0.0-alpha.3
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.3)
Loading...
Searching...
No Matches
InflowData.hpp
Go to the documentation of this file.
1
14
15#ifndef OPENSWMM_ENGINE_INFLOW_DATA_HPP
16#define OPENSWMM_ENGINE_INFLOW_DATA_HPP
17
18#include <vector>
19#include <string>
20
21namespace openswmm {
22
23// ============================================================================
24// External inflow definitions (from [INFLOWS] section)
25// ============================================================================
26
28 int count() const { return static_cast<int>(node_idx.size()); }
29
30 std::vector<int> node_idx;
31 std::vector<std::string> node_name;
32 std::vector<std::string> constituent;
33 std::vector<std::string> ts_name;
34 std::vector<std::string> inflow_type;
35 std::vector<double> m_factor;
36 std::vector<double> s_factor;
37 std::vector<double> baseline;
38 std::vector<std::string> pattern_name;
39
40 void add(int ni, const std::string& cons, const std::string& ts,
41 const std::string& type, double mf, double sf, double base,
42 const std::string& pat, const std::string& name = {}) {
43 node_idx.push_back(ni); node_name.push_back(name);
44 constituent.push_back(cons);
45 ts_name.push_back(ts); inflow_type.push_back(type);
46 m_factor.push_back(mf); s_factor.push_back(sf);
47 baseline.push_back(base); pattern_name.push_back(pat);
48 }
49
52 void erase(int idx) {
53 if (idx < 0 || idx >= count()) return;
54 const auto u = static_cast<std::size_t>(idx);
55 node_idx.erase(node_idx.begin() + u);
56 node_name.erase(node_name.begin() + u);
57 constituent.erase(constituent.begin() + u);
58 ts_name.erase(ts_name.begin() + u);
59 inflow_type.erase(inflow_type.begin() + u);
60 m_factor.erase(m_factor.begin() + u);
61 s_factor.erase(s_factor.begin() + u);
62 baseline.erase(baseline.begin() + u);
63 pattern_name.erase(pattern_name.begin() + u);
64 }
65};
66
67// ============================================================================
68// Dry weather flow definitions (from [DWF] section)
69// ============================================================================
70
71struct DwfData {
72 int count() const { return static_cast<int>(node_idx.size()); }
73
74 std::vector<int> node_idx;
75 std::vector<std::string> node_name;
76 std::vector<std::string> constituent;
77 std::vector<double> avg_value;
78 std::vector<std::string> pat1;
79 std::vector<std::string> pat2;
80 std::vector<std::string> pat3;
81 std::vector<std::string> pat4;
82
83 void add(int ni, const std::string& cons, double avg,
84 const std::string& p1, const std::string& p2,
85 const std::string& p3, const std::string& p4,
86 const std::string& name = {}) {
87 node_idx.push_back(ni); node_name.push_back(name);
88 constituent.push_back(cons);
89 avg_value.push_back(avg);
90 pat1.push_back(p1); pat2.push_back(p2);
91 pat3.push_back(p3); pat4.push_back(p4);
92 }
93
94 void erase(int idx) {
95 if (idx < 0 || idx >= count()) return;
96 const auto u = static_cast<std::size_t>(idx);
97 node_idx.erase(node_idx.begin() + u);
98 node_name.erase(node_name.begin() + u);
99 constituent.erase(constituent.begin() + u);
100 avg_value.erase(avg_value.begin() + u);
101 pat1.erase(pat1.begin() + u);
102 pat2.erase(pat2.begin() + u);
103 pat3.erase(pat3.begin() + u);
104 pat4.erase(pat4.begin() + u);
105 }
106};
107
108// ============================================================================
109// RDII assignments (from [RDII] section)
110// ============================================================================
111
113 int count() const { return static_cast<int>(node_idx.size()); }
114
115 std::vector<int> node_idx;
116 std::vector<std::string> node_name;
117 std::vector<std::string> uh_name;
118 std::vector<double> sewer_area;
119
120 void add(int ni, const std::string& uh, double area,
121 const std::string& name = {}) {
122 node_idx.push_back(ni); node_name.push_back(name);
123 uh_name.push_back(uh);
124 sewer_area.push_back(area);
125 }
126
127 void erase(int idx) {
128 if (idx < 0 || idx >= count()) return;
129 const auto u = static_cast<std::size_t>(idx);
130 node_idx.erase(node_idx.begin() + u);
131 node_name.erase(node_name.begin() + u);
132 uh_name.erase(uh_name.begin() + u);
133 sewer_area.erase(sewer_area.begin() + u);
134 }
135};
136
137// ============================================================================
138// Unit Hydrograph data (from [HYDROGRAPHS] section)
139// ============================================================================
140
142 std::string name;
143 std::string gage_name;
144 int month;
146 double r;
147 double t;
148 double k;
149 double dmax;
150 double drecov;
151 double dinit;
152};
153
155 int count() const { return static_cast<int>(entries.size()); }
156
157 std::vector<UnitHydEntry> entries;
158
160 std::vector<std::string> gage_assignments;
161 std::vector<std::string> gage_names;
162
163 void add_gage(const std::string& uh_name, const std::string& gage) {
164 gage_assignments.push_back(uh_name);
165 gage_names.push_back(gage);
166 }
167
168 void add(const UnitHydEntry& e) { entries.push_back(e); }
169};
170
171// ============================================================================
172// RDII exponential-decay parameters (from [RDII_DECAY] section)
173// ============================================================================
174//
175// One row per (UH group, response). Granularity is per-response, NOT per-month
176// — the whole point of the exponential model is that seasonal variation in
177// IA recovery emerges from temperature dynamics, not from a monthly lookup.
178//
179// A UH group with no row here uses the legacy linear IA recovery for every
180// response. A group with one row falls back to linear for the two unspecified
181// responses, so adoption is incremental.
182//
183// @see docs/RDII_ExpDecay_Implementation.md
184
186 std::string uh_name;
187 int response = -1;
188 double k_dep = 0.0;
189 double k_0 = 0.0;
190 double k_T = 0.0;
191 double T_ref = 10.0;
192 double theta_rec = 0.0;
193 double T_freeze = 0.0;
194};
195
197 int count() const { return static_cast<int>(entries.size()); }
198
199 std::vector<RDIIDecayEntry> entries;
200
201 void add(const RDIIDecayEntry& e) { entries.push_back(e); }
202};
203
204// ============================================================================
205// Time patterns (from [PATTERNS] section)
206// ============================================================================
207
209 int count() const { return static_cast<int>(names.size()); }
210
211 std::vector<std::string> names;
212 std::vector<int> types;
213 std::vector<std::vector<double>> factors;
214
215 void add(const std::string& name, int type, const std::vector<double>& facs) {
216 names.push_back(name); types.push_back(type);
217 factors.push_back(facs);
218 }
219};
220
221} // namespace openswmm
222
223#endif // OPENSWMM_ENGINE_INFLOW_DATA_HPP
Definition Gage.cpp:20
Definition NodeCoupling.cpp:15
Definition InflowData.hpp:71
std::vector< std::string > constituent
"FLOW" or pollutant name
Definition InflowData.hpp:76
std::vector< int > node_idx
Target node.
Definition InflowData.hpp:74
std::vector< std::string > pat1
Monthly pattern name.
Definition InflowData.hpp:78
std::vector< std::string > pat2
Daily pattern name.
Definition InflowData.hpp:79
std::vector< double > avg_value
Average value.
Definition InflowData.hpp:77
void add(int ni, const std::string &cons, double avg, const std::string &p1, const std::string &p2, const std::string &p3, const std::string &p4, const std::string &name={})
Definition InflowData.hpp:83
void erase(int idx)
Definition InflowData.hpp:94
std::vector< std::string > pat4
Weekend pattern name.
Definition InflowData.hpp:81
int count() const
Definition InflowData.hpp:72
std::vector< std::string > node_name
Raw node name from input (for post-parse re-resolution)
Definition InflowData.hpp:75
std::vector< std::string > pat3
Hourly pattern name.
Definition InflowData.hpp:80
Definition InflowData.hpp:27
std::vector< std::string > pattern_name
Baseline pattern name.
Definition InflowData.hpp:38
std::vector< std::string > constituent
"FLOW" or pollutant name
Definition InflowData.hpp:32
std::vector< int > node_idx
Target node index.
Definition InflowData.hpp:30
std::vector< double > baseline
Baseline value.
Definition InflowData.hpp:37
int count() const
Definition InflowData.hpp:28
std::vector< std::string > inflow_type
"FLOW","CONCEN","MASS"
Definition InflowData.hpp:34
std::vector< double > s_factor
Scaling factor.
Definition InflowData.hpp:36
std::vector< double > m_factor
Multiplier factor.
Definition InflowData.hpp:35
std::vector< std::string > node_name
Raw node name from input (for post-parse re-resolution)
Definition InflowData.hpp:31
std::vector< std::string > ts_name
Timeseries name ("" if none)
Definition InflowData.hpp:33
void add(int ni, const std::string &cons, const std::string &ts, const std::string &type, double mf, double sf, double base, const std::string &pat, const std::string &name={})
Definition InflowData.hpp:40
void erase(int idx)
Definition InflowData.hpp:52
Definition InflowData.hpp:208
std::vector< std::vector< double > > factors
Up to 24 multiplier values.
Definition InflowData.hpp:213
void add(const std::string &name, int type, const std::vector< double > &facs)
Definition InflowData.hpp:215
std::vector< std::string > names
Pattern name.
Definition InflowData.hpp:211
int count() const
Definition InflowData.hpp:209
std::vector< int > types
0=MONTHLY,1=DAILY,2=HOURLY,3=WEEKEND
Definition InflowData.hpp:212
Definition InflowData.hpp:112
std::vector< std::string > uh_name
Unit hydrograph name.
Definition InflowData.hpp:117
std::vector< double > sewer_area
Tributary sewer area.
Definition InflowData.hpp:118
std::vector< std::string > node_name
Raw node name from input (for post-parse re-resolution)
Definition InflowData.hpp:116
std::vector< int > node_idx
Target node.
Definition InflowData.hpp:115
int count() const
Definition InflowData.hpp:113
void erase(int idx)
Definition InflowData.hpp:127
void add(int ni, const std::string &uh, double area, const std::string &name={})
Definition InflowData.hpp:120
Definition InflowData.hpp:196
int count() const
Definition InflowData.hpp:197
void add(const RDIIDecayEntry &e)
Definition InflowData.hpp:201
std::vector< RDIIDecayEntry > entries
Definition InflowData.hpp:199
Definition InflowData.hpp:185
double k_T
Thermal recovery rate at T_ref (1/hr)
Definition InflowData.hpp:190
double k_0
Base recovery rate (1/hr)
Definition InflowData.hpp:189
double k_dep
Depletion rate (1/project rain-depth unit: 1/in or 1/mm) — temperature-independent.
Definition InflowData.hpp:188
double theta_rec
Temperature sensitivity (1/deg C)
Definition InflowData.hpp:192
int response
0=SHORT, 1=MEDIUM, 2=LONG
Definition InflowData.hpp:187
std::string uh_name
Matches UnitHydEntry::name.
Definition InflowData.hpp:186
double T_freeze
Recovery suppressed when T < T_freeze (deg C)
Definition InflowData.hpp:193
double T_ref
Reference temperature (deg C)
Definition InflowData.hpp:191
Definition InflowData.hpp:154
std::vector< std::string > gage_assignments
Rain gage names associated with each UH group (name → gage name)
Definition InflowData.hpp:160
std::vector< std::string > gage_names
Assigned rain gage names.
Definition InflowData.hpp:161
void add(const UnitHydEntry &e)
Definition InflowData.hpp:168
std::vector< UnitHydEntry > entries
Definition InflowData.hpp:157
void add_gage(const std::string &uh_name, const std::string &gage)
Definition InflowData.hpp:163
int count() const
Definition InflowData.hpp:155
Definition InflowData.hpp:141
double drecov
IA recovery rate.
Definition InflowData.hpp:150
std::string name
UH group name.
Definition InflowData.hpp:142
double t
Time to peak (hours)
Definition InflowData.hpp:147
int response
0=SHORT, 1=MEDIUM, 2=LONG
Definition InflowData.hpp:145
double dmax
Max initial abstraction depth.
Definition InflowData.hpp:149
double r
Fraction of rainfall volume.
Definition InflowData.hpp:146
int month
Month index (0-11, or -1 for ALL)
Definition InflowData.hpp:144
std::string gage_name
Associated rain gage name.
Definition InflowData.hpp:143
double dinit
Initial IA used.
Definition InflowData.hpp:151
double k
Recession-limb-to-peak-time ratio (tBase = t*(1+k); k >= 0)
Definition InflowData.hpp:148