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
45
46#ifndef OPENSWMM_LANDUSE_HPP
47#define OPENSWMM_LANDUSE_HPP
48
49#include <vector>
50
51namespace openswmm {
52
54
55namespace landuse {
56
57// ============================================================================
58// Buildup/washoff function types
59// ============================================================================
60
61enum class BuildupType : int {
62 NONE = 0,
63 POWER = 1,
64 EXPON = 2,
65 SATUR = 3,
67};
68
69enum class WashoffType : int {
70 NONE = 0,
71 EXPON = 1,
72 RATING = 2,
73 EMC = 3
74};
75
76// ============================================================================
77// Per (landuse × pollutant) buildup/washoff parameters — SoA
78// ============================================================================
79
82 double coeff[3] = {};
83 double max_days = 0.0;
84 int normalizer = 0;
85};
86
89 double coeff = 0.0;
90 double expon = 0.0;
91 double sweep_effic = 0.0;
92 double bmp_effic = 0.0;
93};
94
95// ============================================================================
96// Surface quality SoA (per subcatchment × pollutant)
97// ============================================================================
98
100 int n_subcatch = 0;
101 int n_landuses = 0;
103
106 std::vector<double> buildup;
107
109 std::vector<double> washoff_conc;
110
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
139 const double* area, const double* curb_length,
140 double dt, int n_subcatch);
141
151 const double* runoff, const double* area,
152 int n_subcatch);
153
169 const double* runoff, const double* area,
170 const int* co_pollut, const double* co_frac,
171 int n_subcatch);
172
174 std::vector<BuildupParams> buildup_params;
175 std::vector<WashoffParams> washoff_params;
176 int n_landuses_ = 0;
178};
179
180} // namespace landuse
181} // namespace openswmm
182
183#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:92
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:166
void computeWashoff(SurfaceQualitySoA &sq, const double *runoff, const double *area, int n_subcatch)
Batch compute washoff for all subcatchments.
Definition Landuse.cpp:114
std::vector< BuildupParams > buildup_params
Per (landuse × pollutant) parameters. Index: [lu * n_pollutants + p].
Definition Landuse.hpp:174
int n_pollutants_
Definition Landuse.hpp:177
void init(int n_landuses, int n_pollutants)
Definition Landuse.cpp:43
int n_landuses_
Definition Landuse.hpp:176
std::vector< WashoffParams > washoff_params
Definition Landuse.hpp:175
Definition Landuse.cpp:33
WashoffType
Definition Landuse.hpp:69
@ EMC
Definition Landuse.hpp:73
@ NONE
Definition Landuse.hpp:70
@ RATING
Definition Landuse.hpp:72
BuildupType
Definition Landuse.hpp:61
@ EXTERNAL
Definition Landuse.hpp:66
@ EXPON
Definition Landuse.hpp:64
@ NONE
Definition Landuse.hpp:62
@ POWER
Definition Landuse.hpp:63
@ SATUR
Definition Landuse.hpp:65
Definition HotStartManager.hpp:90
Definition NodeCoupling.cpp:16
Central, reentrant simulation context.
Definition SimulationContext.hpp:353
Definition Landuse.hpp:80
double max_days
Time to reach max buildup.
Definition Landuse.hpp:83
BuildupType type
Definition Landuse.hpp:81
int normalizer
0=PER_AREA, 1=PER_CURB
Definition Landuse.hpp:84
double coeff[3]
c0 (max), c1 (rate), c2 (exponent)
Definition Landuse.hpp:82
Definition Landuse.hpp:99
std::vector< double > buildup
Definition Landuse.hpp:106
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:109
void resize(int n_sc, int n_lu, int n_poll)
Definition Landuse.cpp:35
int n_subcatch
Definition Landuse.hpp:100
int n_pollutants
Definition Landuse.hpp:102
int n_landuses
Definition Landuse.hpp:101
Definition Landuse.hpp:87
double expon
Washoff exponent.
Definition Landuse.hpp:90
double bmp_effic
BMP removal [0-1].
Definition Landuse.hpp:92
WashoffType type
Definition Landuse.hpp:88
double sweep_effic
Street sweep removal [0-1].
Definition Landuse.hpp:91
double coeff
Washoff coefficient.
Definition Landuse.hpp:89