OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
NodeCoupling2DData.hpp
Go to the documentation of this file.
1
23
24#ifndef OPENSWMM_ENGINE_NODE_COUPLING_2D_DATA_HPP
25#define OPENSWMM_ENGINE_NODE_COUPLING_2D_DATA_HPP
26
27#include <array>
28#include <cstddef>
29#include <cstdint>
30#include <limits>
31#include <vector>
32
33namespace openswmm {
34
36enum class NodeCoupling2DType : int8_t {
37 NONE = 0,
39 GRATE = 2,
40 CURB = 3,
41 OPEN = 4,
43};
44
63
64constexpr int kNodeCoupling2DKeys = static_cast<int>(NodeCoupling2DKey::COUNT);
65
67enum class NodeCoupling2DCrest : int { NODE_RIM = 0, MESH_BED = 1, MAX = 2, MIN = 3 };
75
76enum class NodeCoupling2DLaw : int { ORIFICE = 0, WEIR_ORIFICE = 1 };
77
78using NodeCoupling2DParams = std::array<double, kNodeCoupling2DKeys>;
79
86 p.fill(std::numeric_limits<double>::quiet_NaN());
87 return p;
88}
89
92 std::vector<int> node;
93 std::vector<NodeCoupling2DType> type;
94 std::vector<NodeCoupling2DParams> params;
95
100 int count() const noexcept { return static_cast<int>(node.size()); }
101
108 int row_of(int node_idx) const noexcept {
109 for (std::size_t r = 0; r < node.size(); ++r)
110 if (node[r] == node_idx)
111 return static_cast<int>(r);
112 return -1;
113 }
114
125 int ensure_row(int node_idx, NodeCoupling2DType t) {
126 const int r = row_of(node_idx);
127 if (r >= 0)
128 return r;
129 node.push_back(node_idx);
130 type.push_back(t);
132 return count() - 1;
133 }
134
142 void erase_row(int r) {
143 const auto d = static_cast<std::ptrdiff_t>(r);
144 node.erase(node.begin() + d);
145 type.erase(type.begin() + d);
146 params.erase(params.begin() + d);
147 }
148
157 void erase_node(int idx) {
158 const int r = row_of(idx);
159 if (r >= 0)
160 erase_row(r);
161 for (auto& n : node)
162 if (n > idx)
163 --n;
164 }
165
172 void clear() {
173 node.clear();
174 type.clear();
175 params.clear();
176 }
177};
178
179} // namespace openswmm
180
181#endif // OPENSWMM_ENGINE_NODE_COUPLING_2D_DATA_HPP
@ NONE
Definition SimulationContext.hpp:183
Definition ExchangeLaw.hpp:60
@ ORIFICE
Definition LinkData.hpp:58
@ DEFAULT
Definition HeatData.hpp:107
NodeCoupling2DLaw
LAW values (stored in the LAW parameter slot).
Definition NodeCoupling2DData.hpp:76
@ WEIR_ORIFICE
Definition NodeCoupling2DData.hpp:76
NodeCoupling2DCrest
CREST policy values (stored in the CREST parameter slot).
Definition NodeCoupling2DData.hpp:67
@ MAX
Definition NodeCoupling2DData.hpp:67
@ NODE_RIM
Definition NodeCoupling2DData.hpp:67
@ MESH_BED
Definition NodeCoupling2DData.hpp:67
@ MIN
Definition NodeCoupling2DData.hpp:67
constexpr int kNodeCoupling2DKeys
Definition NodeCoupling2DData.hpp:64
NodeCoupling2DCoeffs
COEFFS preset values (stored in the COEFFS parameter slot).
Definition NodeCoupling2DData.hpp:69
@ RUBINATO2017_LOWER
Definition NodeCoupling2DData.hpp:72
@ RUBINATO2017_UPPER
Definition NodeCoupling2DData.hpp:73
@ RUBINATO2017
Definition NodeCoupling2DData.hpp:71
std::array< double, kNodeCoupling2DKeys > NodeCoupling2DParams
Definition NodeCoupling2DData.hpp:78
NodeCoupling2DParams unsetNodeCoupling2DParams() noexcept
Create a parameter array with every slot marked unauthored.
Definition NodeCoupling2DData.hpp:84
NodeCoupling2DType
Coupling structure type of a node. NONE = not coupleable.
Definition NodeCoupling2DData.hpp:36
@ GRATE
Definition NodeCoupling2DData.hpp:39
@ OPEN
open-top storage / pond under the mesh
Definition NodeCoupling2DData.hpp:41
@ MANHOLE
Definition NodeCoupling2DData.hpp:38
@ CURB
Definition NodeCoupling2DData.hpp:40
@ OUTFALL
tailwater + discharge mechanism, not an exchange law
Definition NodeCoupling2DData.hpp:42
NodeCoupling2DKey
Optional KEY=VALUE parameters of a [2D_NODE_COUPLING] row, in write order.
Definition NodeCoupling2DData.hpp:46
@ SPREAD
outfall discharge spread radius (length)
Definition NodeCoupling2DData.hpp:59
@ CREST
crest policy (NodeCoupling2DCrest)
Definition NodeCoupling2DData.hpp:52
@ COEFFS
coefficient preset (NodeCoupling2DCoeffs)
Definition NodeCoupling2DData.hpp:53
@ COUNT
Definition NodeCoupling2DData.hpp:61
@ COI
orifice coefficient, surface → sewer
Definition NodeCoupling2DData.hpp:56
@ LAW
per-node exchange law (NodeCoupling2DLaw)
Definition NodeCoupling2DData.hpp:58
@ AREA
orifice / open area (length²)
Definition NodeCoupling2DData.hpp:49
@ PERIMETER
weir crest length (length)
Definition NodeCoupling2DData.hpp:48
@ CW
free-weir coefficient
Definition NodeCoupling2DData.hpp:54
@ COO
orifice coefficient, sewer → surface
Definition NodeCoupling2DData.hpp:57
@ CSW
submerged-weir coefficient
Definition NodeCoupling2DData.hpp:55
@ LID_OPEN_FRACTION
open share of a covered lid, (0, 1]
Definition NodeCoupling2DData.hpp:51
@ D
manhole diameter (length)
Definition NodeCoupling2DData.hpp:47
@ TAILWATER_RELAX
outfall tailwater relaxation time (s)
Definition NodeCoupling2DData.hpp:60
@ CHAMBER_AREA
1D chamber plan area above the rim (length²)
Definition NodeCoupling2DData.hpp:50
Sparse [2D_NODE_COUPLING] rows (one per authored node).
Definition NodeCoupling2DData.hpp:91
void clear()
Erase all owned sparse node-coupling rows.
Definition NodeCoupling2DData.hpp:172
std::vector< NodeCoupling2DParams > params
NaN = not authored.
Definition NodeCoupling2DData.hpp:94
int row_of(int node_idx) const noexcept
Find the first sparse row for a stored node index.
Definition NodeCoupling2DData.hpp:108
int ensure_row(int node_idx, NodeCoupling2DType t)
Reuse a sparse node row or append an unauthored one.
Definition NodeCoupling2DData.hpp:125
void erase_row(int r)
Erase a sparse row from all three columns.
Definition NodeCoupling2DData.hpp:142
std::vector< int > node
node index
Definition NodeCoupling2DData.hpp:92
void erase_node(int idx)
Remove a deleted node's first sparse row and shift higher stored node keys.
Definition NodeCoupling2DData.hpp:157
std::vector< NodeCoupling2DType > type
Definition NodeCoupling2DData.hpp:93
int count() const noexcept
Count sparse coupling rows from the node-key column.
Definition NodeCoupling2DData.hpp:100