OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
HydStructures.hpp
Go to the documentation of this file.
1
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
42struct SimulationContext;
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<bool> has_flap;
76 void resize(int n);
77};
78
79struct WeirGroup {
80 int count = 0;
81 std::vector<int> link_idx;
82 std::vector<int> weir_type;
83 std::vector<double> c_disch1;
84 std::vector<double> c_disch2;
85 std::vector<double> end_con;
86 std::vector<double> slope;
87 std::vector<int> cd_curve;
88 std::vector<bool> has_flap;
89 void resize(int n);
90};
91
93 int count = 0;
94 std::vector<int> link_idx;
95 std::vector<int> curve_idx;
96 std::vector<double> q_coeff;
97 std::vector<double> q_expon;
98 void resize(int n);
99};
100
101// ============================================================================
102// Structure flow solver
103// ============================================================================
104
106public:
107 void init(SimulationContext& ctx);
108
120 void computeAllFlows(SimulationContext& ctx, double dt);
121
122private:
123 PumpGroup pumps_;
124 OrificeGroup orifices_;
125 WeirGroup weirs_;
126 OutletGroup outlets_;
127
129 void computePumpFlows(SimulationContext& ctx);
130
132 void computeOrificeFlows(SimulationContext& ctx);
133
135 void computeWeirFlows(SimulationContext& ctx);
136
138 void computeOutletFlows(SimulationContext& ctx);
139};
140
141} // namespace hydstruct
142} // namespace openswmm
143
144#endif // OPENSWMM_HYD_STRUCTURES_HPP
Definition HydStructures.hpp:105
void computeAllFlows(SimulationContext &ctx, double dt)
Compute flow for all non-conduit links (batch by type).
Definition HydStructures.cpp:321
void init(SimulationContext &ctx)
Definition HydStructures.cpp:24
constexpr double FUDGE
Definition HydStructures.hpp:51
constexpr double GRAVITY
Definition HydStructures.hpp:50
Definition Controls.cpp:24
Central, reentrant simulation context.
Definition SimulationContext.hpp:141
Definition HydStructures.hpp:68
std::vector< double > c_orifice
Cd * sqrt(2g) * Area.
Definition HydStructures.hpp:72
std::vector< int > shape
BOTTOM or SIDE.
Definition HydStructures.hpp:71
int count
Definition HydStructures.hpp:69
std::vector< double > h_crit
Transition depth.
Definition HydStructures.hpp:74
void resize(int n)
Definition HydStructures.cpp:20
std::vector< bool > has_flap
Flap gate.
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:92
void resize(int n)
Definition HydStructures.cpp:22
std::vector< int > link_idx
Definition HydStructures.hpp:94
int count
Definition HydStructures.hpp:93
std::vector< int > curve_idx
Rating curve (-1 = power law)
Definition HydStructures.hpp:95
std::vector< double > q_expon
Power law exponent.
Definition HydStructures.hpp:97
std::vector< double > q_coeff
Power law coefficient.
Definition HydStructures.hpp:96
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:19
std::vector< double > y_off
Shutoff depth.
Definition HydStructures.hpp:64
Definition HydStructures.hpp:79
std::vector< int > cd_curve
Optional Cd(head) curve index.
Definition HydStructures.hpp:87
std::vector< bool > has_flap
Definition HydStructures.hpp:88
std::vector< double > slope
V-notch slope or trap slope.
Definition HydStructures.hpp:86
std::vector< double > end_con
End contraction factor.
Definition HydStructures.hpp:85
void resize(int n)
Definition HydStructures.cpp:21
std::vector< double > c_disch2
End section coefficient (trapezoidal)
Definition HydStructures.hpp:84
std::vector< int > link_idx
Definition HydStructures.hpp:81
std::vector< int > weir_type
TRANSVERSE/SIDE/VNOTCH/TRAPEZOIDAL.
Definition HydStructures.hpp:82
std::vector< double > c_disch1
Main discharge coefficient.
Definition HydStructures.hpp:83
int count
Definition HydStructures.hpp:80