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