OpenSWMM Engine  6.0.0-alpha.3
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.3)
Loading...
Searching...
No Matches
HydStructures.hpp
Go to the documentation of this file.
1
31
32#ifndef OPENSWMM_HYD_STRUCTURES_HPP
33#define OPENSWMM_HYD_STRUCTURES_HPP
34
35#include "../data/LinkData.hpp"
36#include "../data/NodeData.hpp"
37#include "../data/TableData.hpp"
38#include <vector>
39
40namespace openswmm {
41
43
44namespace hydstruct {
45
46// ============================================================================
47// Constants
48// ============================================================================
49
50constexpr double GRAVITY = 32.2;
51constexpr double FUDGE = 0.0001;
52
53// ============================================================================
54// Per-type SoA groups (like XSectGroups but for structure types)
55// ============================================================================
56
57struct PumpGroup {
58 int count = 0;
59 std::vector<int> link_idx;
60 std::vector<int> curve_idx;
61 std::vector<int> curve_type;
62 std::vector<double> speed;
63 std::vector<double> y_on;
64 std::vector<double> y_off;
65 void resize(int n);
66};
67
69 int count = 0;
70 std::vector<int> link_idx;
71 std::vector<int> shape;
72 std::vector<double> c_orifice;
73 std::vector<double> c_weir;
74 std::vector<double> h_crit;
75 std::vector<uint8_t> has_flap;
81 std::vector<double> surf_area;
85 std::vector<double> length_eff;
86 void resize(int n);
87};
88
89struct WeirGroup {
90 int count = 0;
91 std::vector<int> link_idx;
92 std::vector<int> weir_type;
93 std::vector<double> c_disch1;
94 std::vector<double> c_disch2;
95 std::vector<double> end_con;
96 std::vector<double> slope;
97 std::vector<int> cd_curve;
98 std::vector<uint8_t> has_flap;
102 std::vector<double> surf_area;
106 std::vector<double> length_eff;
110 std::vector<uint8_t> can_surcharge;
111 void resize(int n);
112};
113
115 int count = 0;
116 std::vector<int> link_idx;
117 std::vector<int> curve_idx;
118 std::vector<double> q_coeff;
119 std::vector<double> q_expon;
120 void resize(int n);
121};
122
123// ============================================================================
124// Structure flow solver
125// ============================================================================
126
128public:
129 void init(SimulationContext& ctx);
130
149 void computeAllFlows(SimulationContext& ctx, double dt,
150 double* node_new_surf_area = nullptr);
151
156
158 const std::vector<int>& nonConduitIndices() const noexcept { return nc_indices_; }
159
168 void computeNonConduitFlowOne(SimulationContext& ctx, double dt,
169 double* node_new_surf_area, int link_idx);
170
176 double* node_new_surf_area, int link_idx);
177
178private:
179 PumpGroup pumps_;
180 OrificeGroup orifices_;
181 WeirGroup weirs_;
182 OutletGroup outlets_;
183 std::vector<int> nc_indices_;
184 std::vector<int> nc_group_k_;
185
188 void computePumpFlows(SimulationContext& ctx, double dt,
189 const double* node_new_surf_area);
190
191 // Per-element bodies of the batch loops (k = row in the type group).
192 void computePumpFlowK(SimulationContext& ctx, double dt,
193 const double* node_new_surf_area, int k);
194 void computeOrificeFlowK(SimulationContext& ctx,
195 double* node_new_surf_area, int k);
196 void computeWeirFlowK(SimulationContext& ctx,
197 double* node_new_surf_area, int k);
198 void computeOutletFlowK(SimulationContext& ctx, int k);
199 void scatterOrificeSurfArea(SimulationContext& ctx,
200 double* node_new_surf_area,
201 std::size_t uk, std::size_t uj,
202 std::size_t un1, std::size_t un2);
203
209 void computeOrificeFlows(SimulationContext& ctx,
210 double* node_new_surf_area = nullptr);
211
216 void computeWeirFlows(SimulationContext& ctx,
217 double* node_new_surf_area = nullptr);
218
220 void computeOutletFlows(SimulationContext& ctx);
221};
222
223} // namespace hydstruct
224} // namespace openswmm
225
226#endif // OPENSWMM_HYD_STRUCTURES_HPP
Structure-of-Arrays (SoA) storage for all node types.
Time series and rating curve data with bidirectional cursor.
Definition HydStructures.hpp:127
void computeNonConduitFlowOne(SimulationContext &ctx, double dt, double *node_new_surf_area, int link_idx)
Compute flow for ONE non-conduit link (per-link sequential path). PARITY: legacy findLinkFlows (dynwa...
Definition HydStructures.cpp:1095
void computeAllFlows(SimulationContext &ctx, double dt, double *node_new_surf_area=nullptr)
Compute flow for all non-conduit links (batch by type).
Definition HydStructures.cpp:1079
const std::vector< int > & nonConduitIndices() const noexcept
Get pre-built list of all non-conduit link indices.
Definition HydStructures.hpp:158
void scatterHeldSurfArea(SimulationContext &ctx, double *node_new_surf_area, int link_idx)
Scatter the HELD surface area of a bypassed non-conduit link (legacy updateNodeFlows runs for bypasse...
Definition HydStructures.cpp:1124
void updatePumpTargetSettings(SimulationContext &ctx)
Evaluate pump startup/shutoff depth hysteresis. Must be called ONCE per timestep BEFORE the DW iterat...
Definition HydStructures.cpp:200
void init(SimulationContext &ctx)
Definition HydStructures.cpp:30
Definition HydStructures.cpp:23
constexpr double FUDGE
Definition HydStructures.hpp:51
constexpr double GRAVITY
Definition HydStructures.hpp:50
Definition NodeCoupling.cpp:15
Central, reentrant simulation context.
Definition SimulationContext.hpp:292
Definition HydStructures.hpp:68
std::vector< double > surf_area
Definition HydStructures.hpp:81
std::vector< double > c_orifice
Cd * sqrt(2g) * Area.
Definition HydStructures.hpp:72
std::vector< int > shape
BOTTOM or SIDE.
Definition HydStructures.hpp:71
std::vector< double > length_eff
Definition HydStructures.hpp:85
int count
Definition HydStructures.hpp:69
std::vector< double > h_crit
Transition depth.
Definition HydStructures.hpp:74
void resize(int n)
Definition HydStructures.cpp:26
std::vector< uint8_t > has_flap
Definition HydStructures.hpp:75
std::vector< int > link_idx
Definition HydStructures.hpp:70
std::vector< double > c_weir
Cd * L * sqrt(2g) for partial fill.
Definition HydStructures.hpp:73
Definition HydStructures.hpp:114
void resize(int n)
Definition HydStructures.cpp:28
std::vector< int > link_idx
Definition HydStructures.hpp:116
int count
Definition HydStructures.hpp:115
std::vector< int > curve_idx
Rating curve (-1 = power law)
Definition HydStructures.hpp:117
std::vector< double > q_expon
Power law exponent.
Definition HydStructures.hpp:119
std::vector< double > q_coeff
Power law coefficient.
Definition HydStructures.hpp:118
Definition HydStructures.hpp:57
int count
Definition HydStructures.hpp:58
std::vector< int > curve_type
Pump type (1-5, 6=ideal)
Definition HydStructures.hpp:61
std::vector< int > curve_idx
Pump curve table index.
Definition HydStructures.hpp:60
std::vector< int > link_idx
Global link index.
Definition HydStructures.hpp:59
std::vector< double > speed
Current speed setting [0-1].
Definition HydStructures.hpp:62
std::vector< double > y_on
Startup depth.
Definition HydStructures.hpp:63
void resize(int n)
Definition HydStructures.cpp:25
std::vector< double > y_off
Shutoff depth.
Definition HydStructures.hpp:64
Definition HydStructures.hpp:89
std::vector< uint8_t > has_flap
Definition HydStructures.hpp:98
std::vector< int > cd_curve
Optional Cd(head) curve index.
Definition HydStructures.hpp:97
std::vector< double > slope
V-notch slope or trap slope.
Definition HydStructures.hpp:96
std::vector< double > end_con
End contraction factor.
Definition HydStructures.hpp:95
std::vector< double > length_eff
Definition HydStructures.hpp:106
std::vector< uint8_t > can_surcharge
Definition HydStructures.hpp:110
std::vector< double > surf_area
Definition HydStructures.hpp:102
void resize(int n)
Definition HydStructures.cpp:27
std::vector< double > c_disch2
End section coefficient (trapezoidal)
Definition HydStructures.hpp:94
std::vector< int > link_idx
Definition HydStructures.hpp:91
std::vector< int > weir_type
TRANSVERSE/SIDE/VNOTCH/TRAPEZOIDAL.
Definition HydStructures.hpp:92
std::vector< double > c_disch1
Main discharge coefficient.
Definition HydStructures.hpp:93
int count
Definition HydStructures.hpp:90