OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
QualityData.hpp
Go to the documentation of this file.
1
16#ifndef OPENSWMM_ENGINE_QUALITY_DATA_HPP
17#define OPENSWMM_ENGINE_QUALITY_DATA_HPP
18
19#include <vector>
20#include <string>
21#include "../quality/Treatment.hpp"
22
23namespace openswmm {
24
25// ============================================================================
26// Land use definitions
27// ============================================================================
28
30 int count() const { return static_cast<int>(sweep_interval.size()); }
31
32 std::vector<double> sweep_interval;
33 std::vector<double> sweep_removal;
34 std::vector<double> last_swept;
35
41 std::vector<std::string> comments;
42
43 void resize(int n) {
44 auto un = static_cast<std::size_t>(n);
45 sweep_interval.assign(un, 0.0);
46 sweep_removal.assign(un, 0.0);
47 last_swept.assign(un, 0.0);
48 comments.assign(un, std::string{});
49 }
50
52 sweep_interval.shrink_to_fit();
53 sweep_removal.shrink_to_fit();
54 last_swept.shrink_to_fit();
55 comments.shrink_to_fit();
56 }
57};
58
59// ============================================================================
60// Buildup function per (landuse x pollutant)
61// ============================================================================
62
65 std::vector<int> func_type;
66 std::vector<double> coeff1;
67 std::vector<double> coeff2;
68 std::vector<double> coeff3;
69 std::vector<int> normalizer;
70
71 int n_landuses = 0;
72 int n_pollutants = 0;
73
74 void resize(int nlu, int npoll) {
75 n_landuses = nlu; n_pollutants = npoll;
76 auto total = static_cast<std::size_t>(nlu) *
77 static_cast<std::size_t>(npoll);
78 func_type.assign(total, 0);
79 coeff1.assign(total, 0.0);
80 coeff2.assign(total, 0.0);
81 coeff3.assign(total, 0.0);
82 normalizer.assign(total, 0);
83 }
84
86 func_type.shrink_to_fit();
87 coeff1.shrink_to_fit();
88 coeff2.shrink_to_fit();
89 coeff3.shrink_to_fit();
90 normalizer.shrink_to_fit();
91 }
92};
93
94// ============================================================================
95// Washoff function per (landuse x pollutant)
96// ============================================================================
97
100 std::vector<int> func_type;
101 std::vector<double> coeff;
102 std::vector<double> expon;
103 std::vector<double> sweep_effic;
104 std::vector<double> bmp_effic;
105
106 int n_landuses = 0;
108
109 void resize(int nlu, int npoll) {
110 n_landuses = nlu; n_pollutants = npoll;
111 auto total = static_cast<std::size_t>(nlu) *
112 static_cast<std::size_t>(npoll);
113 func_type.assign(total, 0);
114 coeff.assign(total, 0.0);
115 expon.assign(total, 0.0);
116 sweep_effic.assign(total, 0.0);
117 bmp_effic.assign(total, 0.0);
118 }
119
121 func_type.shrink_to_fit();
122 coeff.shrink_to_fit();
123 expon.shrink_to_fit();
124 sweep_effic.shrink_to_fit();
125 bmp_effic.shrink_to_fit();
126 }
127};
128
129// ============================================================================
130// Treatment expression per (node x pollutant)
131// ============================================================================
132
135 std::vector<std::string> expressions;
136
137 int n_nodes = 0;
139
141 std::vector<openswmm::treatment::TreatExpr> compiled;
142
144 std::vector<bool> has_treatment;
145
147 std::vector<double> cin;
148
151 std::vector<double> removal;
152
153 void resize(int nn, int npoll) {
154 n_nodes = nn; n_pollutants = npoll;
155 auto total = static_cast<std::size_t>(nn * npoll);
156 expressions.assign(total, "");
157 compiled.resize(total);
158 has_treatment.assign(static_cast<std::size_t>(nn), false);
159 cin.assign(static_cast<std::size_t>(npoll), 0.0);
160 removal.assign(static_cast<std::size_t>(npoll), -1.0);
161 }
162
164 expressions.shrink_to_fit();
165 compiled.shrink_to_fit();
166 }
167
168 bool hasAny() const {
169 for (const auto& e : expressions) if (!e.empty()) return true;
170 return false;
171 }
172};
173
174} // namespace openswmm
175
176#endif // OPENSWMM_ENGINE_QUALITY_DATA_HPP
Definition NodeCoupling.cpp:15
Definition QualityData.hpp:63
int n_pollutants
Definition QualityData.hpp:72
std::vector< int > func_type
Index: [landuse * n_pollutants + pollutant].
Definition QualityData.hpp:65
void shrink_to_fit()
Definition QualityData.hpp:85
int n_landuses
Definition QualityData.hpp:71
std::vector< double > coeff2
Definition QualityData.hpp:67
void resize(int nlu, int npoll)
Definition QualityData.hpp:74
std::vector< double > coeff1
Definition QualityData.hpp:66
std::vector< double > coeff3
Definition QualityData.hpp:68
std::vector< int > normalizer
0=PER_AREA, 1=PER_CURB
Definition QualityData.hpp:69
Definition QualityData.hpp:29
std::vector< std::string > comments
Object comment from the INP file (';'-prefixed lines immediately above this landuse's data row),...
Definition QualityData.hpp:41
int count() const
Definition QualityData.hpp:30
void resize(int n)
Definition QualityData.hpp:43
std::vector< double > sweep_interval
Days between sweeps.
Definition QualityData.hpp:32
std::vector< double > last_swept
Days since last swept.
Definition QualityData.hpp:34
void shrink_to_fit()
Definition QualityData.hpp:51
std::vector< double > sweep_removal
Max removal fraction (0-100)
Definition QualityData.hpp:33
Definition QualityData.hpp:133
std::vector< std::string > expressions
Index: [node * n_pollutants + pollutant].
Definition QualityData.hpp:135
int n_nodes
Definition QualityData.hpp:137
std::vector< double > removal
Definition QualityData.hpp:151
void resize(int nn, int npoll)
Definition QualityData.hpp:153
std::vector< openswmm::treatment::TreatExpr > compiled
Compiled treatment expressions (same indexing as expressions[])
Definition QualityData.hpp:141
void shrink_to_fit()
Definition QualityData.hpp:163
std::vector< bool > has_treatment
Per-node flag: true if any pollutant has a treatment expression.
Definition QualityData.hpp:144
std::vector< double > cin
Per-node inflow concentrations (size = n_pollutants, reused each timestep)
Definition QualityData.hpp:147
bool hasAny() const
Definition QualityData.hpp:168
int n_pollutants
Definition QualityData.hpp:138
Definition QualityData.hpp:98
std::vector< double > sweep_effic
0-100
Definition QualityData.hpp:103
int n_pollutants
Definition QualityData.hpp:107
std::vector< double > expon
Definition QualityData.hpp:102
std::vector< int > func_type
Index: [landuse * n_pollutants + pollutant].
Definition QualityData.hpp:100
std::vector< double > bmp_effic
0-100
Definition QualityData.hpp:104
std::vector< double > coeff
Definition QualityData.hpp:101
void resize(int nlu, int npoll)
Definition QualityData.hpp:109
int n_landuses
Definition QualityData.hpp:106
void shrink_to_fit()
Definition QualityData.hpp:120