OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
LID.hpp
Go to the documentation of this file.
1
26#ifndef OPENSWMM_LID_HPP
27#define OPENSWMM_LID_HPP
28
29#include <vector>
30#include <cstddef>
31
32namespace openswmm {
33
34struct SimulationContext;
35
36namespace lid {
37
38// ============================================================================
39// LID type codes
40// ============================================================================
41
42enum class LIDType : int {
43 BIO_CELL = 0,
44 RAIN_GARDEN = 1,
45 GREEN_ROOF = 2,
46 INFIL_TRENCH = 3,
47 PERM_PAVEMENT = 4,
48 RAIN_BARREL = 5,
49 VEG_SWALE = 6,
50 ROOF_DISCON = 7
51};
52
53// ============================================================================
54// Layer state (per LID unit)
55// ============================================================================
56
57constexpr int SURF = 0;
58constexpr int SOIL = 1;
59constexpr int STOR = 2;
60constexpr int PAVE = 3;
61constexpr int N_LAYERS = 4;
62
63// ============================================================================
64// LID unit parameters (SoA for batch processing)
65// ============================================================================
66
69 int count = 0;
70
71 std::vector<int> subcatch_idx;
72 std::vector<double> area;
73
74 // Surface layer
75 std::vector<double> surf_store;
76 std::vector<double> surf_rough;
77 std::vector<double> surf_slope;
78
79 // Soil layer
80 std::vector<double> soil_thick;
81 std::vector<double> soil_poros;
82 std::vector<double> soil_fc;
83 std::vector<double> soil_wp;
84 std::vector<double> soil_ksat;
85 std::vector<double> soil_kslope;
86
87 // Storage layer
88 std::vector<double> stor_thick;
89 std::vector<double> stor_void;
90 std::vector<double> stor_ksat;
91
92 // Drain
93 std::vector<double> drain_coeff;
94 std::vector<double> drain_expon;
95 std::vector<double> drain_offset;
96
97 // Pavement layer (PERM_PAVEMENT)
98 std::vector<double> pave_thick;
99 std::vector<double> pave_void;
100 std::vector<double> pave_imperv_frac;
101 std::vector<double> pave_ksat;
102 std::vector<double> pave_clog_factor;
103
104 // Drainage mat layer (GREEN_ROOF)
105 std::vector<double> drainmat_thick;
106 std::vector<double> drainmat_void;
107 std::vector<double> drainmat_rough;
108
109 // Surface geometry (for Manning's outflow)
110 std::vector<double> surf_void_frac;
111 std::vector<double> surf_alpha;
112 std::vector<double> full_width;
113
114 // State variables (updated each step)
115 std::vector<double> surf_depth;
116 std::vector<double> soil_moist;
117 std::vector<double> stor_depth;
118 std::vector<double> pave_depth;
119
120 // Outputs (per unit)
121 std::vector<double> surface_runoff;
122 std::vector<double> drain_flow;
123 std::vector<double> evap_loss;
124 std::vector<double> infil_loss;
125
126 // Water balance tracking (cumulative per unit)
127 std::vector<double> wb_inflow;
128 std::vector<double> wb_evap;
129 std::vector<double> wb_infil;
130 std::vector<double> wb_surf_flow;
131 std::vector<double> wb_drain_flow;
132 std::vector<double> wb_init_vol;
133 std::vector<double> wb_final_vol;
134 std::vector<double> vol_treated;
135
136 void resize(int n);
137};
138
139// ============================================================================
140// LID solver
141// ============================================================================
142
144public:
145 void init(SimulationContext& ctx);
146
161 void execute(SimulationContext& ctx, double dt,
162 double rainfall, double evap_rate);
163
164private:
165 std::vector<LIDGroupSoA> groups_;
166
168 static void batchBioCellFlux(LIDGroupSoA& g, double rainfall,
169 double evap_rate, double dt);
170
172 static void batchBarrelFlux(LIDGroupSoA& g, double rainfall, double dt);
173
175 static void batchSwaleFlux(LIDGroupSoA& g, double rainfall,
176 double evap_rate, double dt);
177
180 static void batchGreenRoofFlux(LIDGroupSoA& g, double rainfall,
181 double evap_rate, double dt);
182
185 static void batchPavementFlux(LIDGroupSoA& g, double rainfall,
186 double evap_rate, double dt);
187
190 static void batchRoofDisconFlux(LIDGroupSoA& g, double rainfall,
191 double evap_rate, double dt);
192};
193
194} // namespace lid
195} // namespace openswmm
196
197#endif // OPENSWMM_LID_HPP
Definition LID.hpp:143
void execute(SimulationContext &ctx, double dt, double rainfall, double evap_rate)
Compute LID performance for all units (batch by type).
Definition LID.cpp:835
void init(SimulationContext &ctx)
Definition LID.cpp:83
constexpr int STOR
Definition LID.hpp:59
constexpr int SOIL
Definition LID.hpp:58
constexpr int N_LAYERS
Definition LID.hpp:61
LIDType
Definition LID.hpp:42
constexpr int PAVE
Definition LID.hpp:60
constexpr int SURF
Definition LID.hpp:57
Definition Controls.cpp:24
Central, reentrant simulation context.
Definition SimulationContext.hpp:141
Definition LID.hpp:67
std::vector< double > soil_wp
Soil wilting point.
Definition LID.hpp:83
std::vector< double > pave_void
Pavement void fraction.
Definition LID.hpp:99
std::vector< double > pave_imperv_frac
Impervious fraction of pavement.
Definition LID.hpp:100
std::vector< double > surface_runoff
Definition LID.hpp:121
std::vector< double > soil_thick
Soil thickness (ft)
Definition LID.hpp:80
std::vector< double > wb_evap
Total evaporation volume (ft)
Definition LID.hpp:128
std::vector< double > surf_alpha
Surface Manning alpha = sqrt(slope)/n.
Definition LID.hpp:111
std::vector< double > drain_coeff
Drain coefficient.
Definition LID.hpp:93
std::vector< double > drain_expon
Drain exponent.
Definition LID.hpp:94
std::vector< double > wb_surf_flow
Total surface outflow volume (ft)
Definition LID.hpp:130
std::vector< double > pave_thick
Pavement thickness (ft)
Definition LID.hpp:98
std::vector< double > surf_depth
Current surface ponded depth.
Definition LID.hpp:115
std::vector< double > pave_ksat
Pavement saturated K (ft/sec)
Definition LID.hpp:101
std::vector< double > stor_ksat
Storage exfiltration K (ft/sec)
Definition LID.hpp:90
std::vector< double > surf_slope
Surface slope.
Definition LID.hpp:77
std::vector< double > stor_void
Storage void fraction.
Definition LID.hpp:89
std::vector< double > wb_final_vol
Final stored volume (ft)
Definition LID.hpp:133
std::vector< double > soil_kslope
Conductivity slope.
Definition LID.hpp:85
std::vector< double > soil_poros
Soil porosity.
Definition LID.hpp:81
std::vector< double > stor_thick
Storage thickness (ft)
Definition LID.hpp:88
std::vector< double > surf_store
Surface storage depth (ft)
Definition LID.hpp:75
std::vector< double > drainmat_thick
Drainage mat thickness (ft)
Definition LID.hpp:105
std::vector< double > soil_ksat
Soil saturated K (ft/sec)
Definition LID.hpp:84
std::vector< double > drain_flow
Definition LID.hpp:122
void resize(int n)
Definition LID.cpp:23
std::vector< double > wb_infil
Total exfiltration volume (ft)
Definition LID.hpp:129
std::vector< double > wb_init_vol
Initial stored volume (ft)
Definition LID.hpp:132
std::vector< double > surf_rough
Surface Manning's n.
Definition LID.hpp:76
std::vector< double > full_width
Full width for Manning's flow (ft)
Definition LID.hpp:112
std::vector< double > wb_inflow
Total inflow volume (ft)
Definition LID.hpp:127
std::vector< double > pave_clog_factor
Pavement clog factor (ft of treated volume)
Definition LID.hpp:102
std::vector< double > wb_drain_flow
Total drain outflow volume (ft)
Definition LID.hpp:131
std::vector< double > drainmat_rough
Drainage mat Manning's roughness.
Definition LID.hpp:107
std::vector< int > subcatch_idx
Which subcatchment this unit belongs to.
Definition LID.hpp:71
std::vector< double > pave_depth
Current pavement depth.
Definition LID.hpp:118
std::vector< double > stor_depth
Current storage depth.
Definition LID.hpp:117
std::vector< double > infil_loss
Definition LID.hpp:124
std::vector< double > surf_void_frac
Surface void fraction (default 1.0)
Definition LID.hpp:110
LIDType type
Definition LID.hpp:68
std::vector< double > area
Unit area (ft2)
Definition LID.hpp:72
std::vector< double > evap_loss
Definition LID.hpp:123
int count
Definition LID.hpp:69
std::vector< double > soil_fc
Soil field capacity.
Definition LID.hpp:82
std::vector< double > vol_treated
Cumulative volume treated (ft, for clog model)
Definition LID.hpp:134
std::vector< double > drainmat_void
Drainage mat void fraction.
Definition LID.hpp:106
std::vector< double > drain_offset
Drain offset depth (ft)
Definition LID.hpp:95
std::vector< double > soil_moist
Current soil moisture (0-porosity)
Definition LID.hpp:116