OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
Inlet.hpp
Go to the documentation of this file.
1
19#ifndef OPENSWMM_INLET_HPP
20#define OPENSWMM_INLET_HPP
21
22#include <vector>
23
24namespace openswmm {
25
26struct SimulationContext;
27struct InletUsageStore;
28
29namespace inlet {
30
31enum class InletType : int {
32 GRATE = 0,
33 CURB = 1,
34 COMBO = 2,
35 SLOTTED = 3,
36 DROP_GRATE = 4,
37 DROP_CURB = 5,
38 CUSTOM = 6
39};
40
41enum class GrateType : int {
42 P_BAR_50 = 0,
43 P_BAR_50x100 = 1,
44 P_BAR_30 = 2,
45 CURVED_VANE = 3,
46 TILT_BAR_45 = 4,
47 TILT_BAR_30 = 5,
48 RETICULINE = 6,
49 GENERIC = 7
50};
51
52struct InletSoA {
53 int count = 0;
54 std::vector<int> link_idx;
55 std::vector<int> node_idx;
56 std::vector<int> bypass_node;
57 std::vector<int> inlet_type;
58 std::vector<int> grate_type;
59 std::vector<double> grate_length;
60 std::vector<double> grate_width;
61 std::vector<double> curb_length;
62 std::vector<double> curb_height;
63 std::vector<int> curb_throat;
64 std::vector<double> slotted_length;
65 std::vector<double> slotted_width;
66 std::vector<double> clog_factor;
67 std::vector<double> opening_ratio;
68 std::vector<int> num_inlets;
69 std::vector<double> flow_limit;
70 std::vector<double> local_depress;
71 std::vector<double> local_width;
72 std::vector<int> n_sides;
73
74 // Street geometry (resolved from StreetStore)
75 std::vector<double> sx;
76 std::vector<double> gutter_depression;
77 std::vector<double> gutter_width;
78 std::vector<double> road_roughness;
79 std::vector<double> t_crown;
80
81 // Working arrays (per-inlet results)
82 std::vector<double> flow_capture;
83
84 // Gap #56: backflow — fraction of capture node overflow that returns to bypass
85 std::vector<double> backflow_ratio;
86 std::vector<double> backflow;
87
88 // Gap #68: statistics (accumulated each timestep)
89 std::vector<double> stat_capture_vol;
90 std::vector<double> stat_bypass_vol;
91 std::vector<double> stat_backflow_vol;
92 std::vector<double> stat_peak_flow;
93
94 void resize(int n);
95};
96
98public:
99 void init(SimulationContext& ctx);
100
107 void computeAll(SimulationContext& ctx, double dt);
108
120 void adjustQualInflows(SimulationContext& ctx, double dt);
121
126 void gatherStats(InletUsageStore& usages) const;
127
128private:
129 InletSoA soa_;
130
132 static double grateCapture(double flow, double velocity, double length,
133 double sx, int grate_type, double open_ratio);
134
136 static double curbCapture(double flow, double curb_length,
137 double sx, double sl, double n,
138 double gutter_depress, double gutter_width,
139 double spread);
140
142 static double splashOverVelocity(double length, int grate_type);
143
145 static double computeFlowSpread(double flow, double qfactor,
146 double sx, double sw, double a_gutter,
147 double w_gutter, double t_crown);
148
150 static double computeEo(double sr, double ts, double w);
151
153 double computeOnGradeCapture(int idx, double flow, double depth) const;
154
156 double getInletArea(int ii) const noexcept;
157
159 void computeBackflowRatios();
160};
161
162} // namespace inlet
163} // namespace openswmm
164
165#endif // OPENSWMM_INLET_HPP
Definition Inlet.hpp:97
void adjustQualInflows(SimulationContext &ctx, double dt)
Adjust quality inflows at bypass and capture nodes for inlet transfers.
Definition Inlet.cpp:774
void gatherStats(InletUsageStore &usages) const
Gap #68: Copy accumulated stats from internal SoA into InletUsageStore. Called by SWMMEngine::report(...
Definition Inlet.cpp:829
void computeAll(SimulationContext &ctx, double dt)
Batch compute inlet capture for all inlets.
Definition Inlet.cpp:374
void init(SimulationContext &ctx)
Definition Inlet.cpp:263
GrateType
Definition Inlet.hpp:41
InletType
Definition Inlet.hpp:31
Definition NodeCoupling.cpp:15
Definition InfraData.hpp:90
Central, reentrant simulation context.
Definition SimulationContext.hpp:274
Definition Inlet.hpp:52
std::vector< double > flow_capture
Captured flow rate (cfs)
Definition Inlet.hpp:82
std::vector< int > grate_type
Definition Inlet.hpp:58
std::vector< double > slotted_width
Slotted drain width (ft)
Definition Inlet.hpp:65
std::vector< double > local_width
Local depression width (ft)
Definition Inlet.hpp:71
std::vector< double > local_depress
Local gutter depression (ft)
Definition Inlet.hpp:70
std::vector< int > inlet_type
Definition Inlet.hpp:57
std::vector< double > gutter_width
Street gutter width (ft)
Definition Inlet.hpp:77
std::vector< double > grate_length
Grate inlet length (ft)
Definition Inlet.hpp:59
std::vector< double > stat_peak_flow
Peak captured flow rate (cfs)
Definition Inlet.hpp:92
std::vector< double > opening_ratio
Grate opening ratio.
Definition Inlet.hpp:67
int count
Definition Inlet.hpp:53
std::vector< int > num_inlets
Number of inlets per side.
Definition Inlet.hpp:68
std::vector< double > t_crown
Distance curb to crown (ft)
Definition Inlet.hpp:79
std::vector< int > bypass_node
Bypass node (downstream of street conduit)
Definition Inlet.hpp:56
std::vector< double > curb_height
Curb opening height (ft)
Definition Inlet.hpp:62
std::vector< double > grate_width
Grate inlet width (ft)
Definition Inlet.hpp:60
std::vector< double > backflow_ratio
Pre-computed fraction of node overflow → backflow.
Definition Inlet.hpp:85
std::vector< double > sx
Street cross slope (fraction)
Definition Inlet.hpp:75
std::vector< int > link_idx
Street conduit link index.
Definition Inlet.hpp:54
std::vector< double > stat_capture_vol
Total captured volume (ft³)
Definition Inlet.hpp:89
std::vector< double > slotted_length
Slotted drain length (ft)
Definition Inlet.hpp:64
std::vector< int > n_sides
1 or 2 sided street
Definition Inlet.hpp:72
std::vector< double > curb_length
Curb opening length (ft)
Definition Inlet.hpp:61
std::vector< double > flow_limit
Max capture flow per inlet (cfs)
Definition Inlet.hpp:69
std::vector< double > stat_bypass_vol
Total bypassed volume (ft³)
Definition Inlet.hpp:90
std::vector< double > backflow
Current backflow rate (cfs), updated each step.
Definition Inlet.hpp:86
std::vector< int > node_idx
Receiving node index.
Definition Inlet.hpp:55
std::vector< double > stat_backflow_vol
Total backflow volume (ft³)
Definition Inlet.hpp:91
std::vector< double > road_roughness
Street Manning's n.
Definition Inlet.hpp:78
void resize(int n)
Definition Inlet.cpp:24
std::vector< double > gutter_depression
Street gutter depression (ft)
Definition Inlet.hpp:76
std::vector< double > clog_factor
Clogging reduction (0-1)
Definition Inlet.hpp:66
std::vector< int > curb_throat
Throat angle type (0=horiz, 1=inclined, 2=vert)
Definition Inlet.hpp:63