OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
Landuse.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
46
47#ifndef OPENSWMM_LANDUSE_HPP
48#define OPENSWMM_LANDUSE_HPP
49
50#include <vector>
51
52namespace openswmm {
53
55
56namespace landuse {
57
58// ============================================================================
59// Buildup/washoff function types
60// ============================================================================
61
62enum class BuildupType : int { NONE = 0, POWER = 1, EXPON = 2, SATUR = 3, EXTERNAL = 4 };
63
64enum class WashoffType : int { NONE = 0, EXPON = 1, RATING = 2, EMC = 3 };
65
66// ============================================================================
67// Per (landuse × pollutant) buildup/washoff parameters — SoA
68// ============================================================================
69
72 double coeff[3] = {};
73 double max_days = 0.0;
74 int normalizer = 0;
75};
76
79 double coeff = 0.0;
80 double expon = 0.0;
81 double sweep_effic = 0.0;
82 double bmp_effic = 0.0;
83};
84
85// ============================================================================
86// Surface quality SoA (per subcatchment × pollutant)
87// ============================================================================
88
90 int n_subcatch = 0;
91 int n_landuses = 0;
92 int n_pollutants = 0;
93
96 std::vector<double> buildup;
97
99 std::vector<double> washoff_conc;
100
112 std::size_t bu_idx(int sc, int lu, int p) const {
113 return static_cast<std::size_t>(sc) * static_cast<std::size_t>(n_landuses * n_pollutants) +
114 static_cast<std::size_t>(lu) * static_cast<std::size_t>(n_pollutants) +
115 static_cast<std::size_t>(p);
116 }
117
118 void resize(int n_sc, int n_lu, int n_poll);
119};
120
121// ============================================================================
122// Landuse quality solver
123// ============================================================================
124
126public:
127 void init(int n_landuses, int n_pollutants);
128
146 void computeBuildup(SurfaceQualitySoA& sq, const double* area, const double* curb_length,
147 double dt, int n_subcatch);
148
156 void computeWashoff(SurfaceQualitySoA& sq, const double* runoff, const double* area,
157 int n_subcatch);
158
172 void applyCoPollutant(SurfaceQualitySoA& sq, const double* runoff, const double* area,
173 const int* co_pollut, const double* co_frac, int n_subcatch);
174
176 std::vector<BuildupParams> buildup_params;
177 std::vector<WashoffParams> washoff_params;
178 int n_landuses_ = 0;
180};
181
182} // namespace landuse
183} // namespace openswmm
184
185#endif // OPENSWMM_LANDUSE_HPP
Definition Landuse.hpp:125
void computeBuildup(SurfaceQualitySoA &sq, const double *area, const double *curb_length, double dt, int n_subcatch)
Batch compute buildup for all subcatchments.
Definition Landuse.cpp:149
void applyCoPollutant(SurfaceQualitySoA &sq, const double *runoff, const double *area, const int *co_pollut, const double *co_frac, int n_subcatch)
Apply co-pollutant washoff fractions.
Definition Landuse.cpp:248
void computeWashoff(SurfaceQualitySoA &sq, const double *runoff, const double *area, int n_subcatch)
Batch compute washoff for all subcatchments.
Definition Landuse.cpp:187
std::vector< BuildupParams > buildup_params
Per (landuse × pollutant) parameters. Index: [lu * n_pollutants + p].
Definition Landuse.hpp:176
int n_pollutants_
Definition Landuse.hpp:179
void init(int n_landuses, int n_pollutants)
Set solver counts and resize landuse/pollutant parameter tables.
Definition Landuse.cpp:62
int n_landuses_
Definition Landuse.hpp:178
std::vector< WashoffParams > washoff_params
Definition Landuse.hpp:177
Definition Landuse.cpp:33
WashoffType
Definition Landuse.hpp:64
@ EMC
Definition Landuse.hpp:64
@ NONE
Definition Landuse.hpp:64
@ RATING
Definition Landuse.hpp:64
BuildupType
Definition Landuse.hpp:62
@ EXTERNAL
Definition Landuse.hpp:62
@ EXPON
Definition Landuse.hpp:62
@ NONE
Definition Landuse.hpp:62
@ POWER
Definition Landuse.hpp:62
@ SATUR
Definition Landuse.hpp:62
Definition ExplicitInertialSolver.hpp:68
Definition ExchangeLaw.hpp:60
Central, reentrant simulation context.
Definition SimulationContext.hpp:390
Definition Landuse.hpp:70
double max_days
Time to reach max buildup.
Definition Landuse.hpp:73
BuildupType type
Definition Landuse.hpp:71
int normalizer
0=PER_AREA, 1=PER_CURB
Definition Landuse.hpp:74
double coeff[3]
c0 (max), c1 (rate), c2 (exponent)
Definition Landuse.hpp:72
Definition Landuse.hpp:89
std::vector< double > buildup
Definition Landuse.hpp:96
std::size_t bu_idx(int sc, int lu, int p) const
Index into buildup array for (subcatch, landuse, pollutant)
Definition Landuse.hpp:112
std::vector< double > washoff_conc
Washoff concentration [subcatch * n_pollutants + pollutant] (mass/vol)
Definition Landuse.hpp:99
void resize(int n_sc, int n_lu, int n_poll)
Reset surface quality storage to requested subcatchment/landuse/pollutant dimensions.
Definition Landuse.cpp:46
int n_subcatch
Definition Landuse.hpp:90
int n_pollutants
Definition Landuse.hpp:92
int n_landuses
Definition Landuse.hpp:91
Definition Landuse.hpp:77
double expon
Washoff exponent.
Definition Landuse.hpp:80
double bmp_effic
BMP removal [0-1].
Definition Landuse.hpp:82
WashoffType type
Definition Landuse.hpp:78
double sweep_effic
Street sweep removal [0-1].
Definition Landuse.hpp:81
double coeff
Washoff coefficient.
Definition Landuse.hpp:79