OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
PollutantData.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
34
35#ifndef OPENSWMM_ENGINE_POLLUTANT_DATA_HPP
36#define OPENSWMM_ENGINE_POLLUTANT_DATA_HPP
37
38#include <vector>
39#include <string>
40#include <cstdint>
41
42namespace openswmm {
43
44// ============================================================================
45// Concentration units
46// ============================================================================
47
52enum class MassUnits : int8_t {
56};
57
58// ============================================================================
59// PollutantData — pollutant definitions
60// ============================================================================
61
72
73 // -----------------------------------------------------------------------
74 // Pollutant definition arrays (indexed by pollutant index)
75 // -----------------------------------------------------------------------
76
81 std::vector<MassUnits> units;
82
87 std::vector<double> mwt;
88
96 std::vector<double> k_decay;
97
102 std::vector<double> c_rain;
103
108 std::vector<double> c_gw;
109
114 std::vector<double> c_rdii;
115
120 std::vector<double> c_dwf;
121
126 std::vector<double> init_conc;
127
133 std::vector<int> co_pollut;
134
139 std::vector<double> co_frac;
140
145 std::vector<bool> snow_only;
146
152 std::vector<std::string> comments;
153
154 // -----------------------------------------------------------------------
155 // Capacity management
156 // -----------------------------------------------------------------------
157
158 int n_pollutants() const noexcept { return static_cast<int>(units.size()); }
159
161 void resize_pollutants(int n) {
162 const auto un = static_cast<std::size_t>(n);
163 units.assign(un, MassUnits::MG_PER_L);
164 mwt.assign(un, 1.0);
165 k_decay.assign(un, 0.0);
166 c_rain.assign(un, 0.0);
167 c_gw.assign(un, 0.0);
168 c_rdii.assign(un, 0.0);
169 c_dwf.assign(un, 0.0);
170 init_conc.assign(un, 0.0);
171 co_pollut.assign(un, -1);
172 co_frac.assign(un, 0.0);
173 snow_only.assign(un, false);
174 comments.assign(un, std::string{});
175 }
176
179 units.shrink_to_fit();
180 mwt.shrink_to_fit();
181 k_decay.shrink_to_fit();
182 c_rain.shrink_to_fit();
183 c_gw.shrink_to_fit();
184 c_rdii.shrink_to_fit();
185 c_dwf.shrink_to_fit();
186 init_conc.shrink_to_fit();
187 co_pollut.shrink_to_fit();
188 co_frac.shrink_to_fit();
189 snow_only.shrink_to_fit();
190 comments.shrink_to_fit();
191 }
192};
193
194} /* namespace openswmm */
195
196#endif /* OPENSWMM_ENGINE_POLLUTANT_DATA_HPP */
Definition NodeCoupling.cpp:16
MassUnits
Pollutant concentration units.
Definition PollutantData.hpp:52
@ MG_PER_L
Milligrams per liter.
Definition PollutantData.hpp:53
@ UG_PER_L
Micrograms per liter.
Definition PollutantData.hpp:54
@ COUNTS_PER_L
Counts per liter (bacteria)
Definition PollutantData.hpp:55
Static properties for each pollutant species.
Definition PollutantData.hpp:71
std::vector< double > init_conc
Initial concentration everywhere in the network.
Definition PollutantData.hpp:126
std::vector< double > c_dwf
Dry weather sanitary flow concentration.
Definition PollutantData.hpp:120
int n_pollutants() const noexcept
Definition PollutantData.hpp:158
void shrink_to_fit()
Release excess vector capacity.
Definition PollutantData.hpp:178
void resize_pollutants(int n)
Resize pollutant definition arrays to hold n pollutants.
Definition PollutantData.hpp:161
std::vector< double > c_gw
Groundwater concentration.
Definition PollutantData.hpp:108
std::vector< int > co_pollut
Co-pollutant index (-1 if none).
Definition PollutantData.hpp:133
std::vector< double > c_rain
Rain concentration (project mass/volume units).
Definition PollutantData.hpp:102
std::vector< std::string > comments
Object comment from the INP file (';'-prefixed lines immediately above this pollutant's data row),...
Definition PollutantData.hpp:152
std::vector< double > mwt
Molecular weight (g/mol). Used for unit conversions.
Definition PollutantData.hpp:87
std::vector< double > k_decay
First-order decay coefficient (1/sec). The [POLLUTANTS] Kdecay column is 1/day: the parser divides by...
Definition PollutantData.hpp:96
std::vector< bool > snow_only
True if the pollutant should be printed in output.
Definition PollutantData.hpp:145
std::vector< double > c_rdii
RDII concentration.
Definition PollutantData.hpp:114
std::vector< MassUnits > units
Concentration units for each pollutant.
Definition PollutantData.hpp:81
std::vector< double > co_frac
Co-fraction (fraction of co-pollutant concentration).
Definition PollutantData.hpp:139