54#ifndef OPENSWMM_ENGINE_NODE_SUBTYPES_HPP
55#define OPENSWMM_ENGINE_NODE_SUBTYPES_HPP
84 std::vector<StorageShape>
shape;
87 std::vector<double>
a;
90 std::vector<double>
b;
92 std::vector<double>
c;
96 std::vector<double>
p1;
98 std::vector<double>
p2;
100 std::vector<double>
p3;
123 a.clear();
b.clear();
c.clear();
124 p1.clear();
p2.clear();
p3.clear();
131 const auto un =
static_cast<std::size_t
>(n);
134 a.reserve(un);
b.reserve(un);
c.reserve(un);
135 p1.reserve(un);
p2.reserve(un);
p3.reserve(un);
145 const auto p =
static_cast<std::ptrdiff_t
>(
153 a.insert(
a.begin() + p, 0.0);
154 b.insert(
b.begin() + p, 0.0);
155 c.insert(
c.begin() + p, 0.0);
156 p1.insert(
p1.begin() + p, 0.0);
157 p2.insert(
p2.begin() + p, 0.0);
158 p3.insert(
p3.begin() + p, 0.0);
166 return static_cast<int>(p);
171 const auto p =
static_cast<std::ptrdiff_t
>(r);
176 a.erase(
a.begin() + p);
177 b.erase(
b.begin() + p);
178 c.erase(
c.begin() + p);
179 p1.erase(
p1.begin() + p);
180 p2.erase(
p2.begin() + p);
181 p3.erase(
p3.begin() + p);
240 const auto un =
static_cast<std::size_t
>(n);
251 const auto p =
static_cast<std::ptrdiff_t
>(
263 return static_cast<int>(p);
268 const auto p =
static_cast<std::ptrdiff_t
>(r);
299 std::vector<double>
cd;
323 const auto un =
static_cast<std::size_t
>(n);
332 const auto p =
static_cast<std::ptrdiff_t
>(
337 cd.insert(
cd.begin() + p, 0.0);
343 return static_cast<int>(p);
348 const auto p =
static_cast<std::ptrdiff_t
>(r);
352 cd.erase(
cd.begin() + p);
400 subtype_row.assign(
static_cast<std::size_t
>(n_nodes), -1);
401 for (
int r = 0; r <
storages.count(); ++r)
403 for (
int r = 0; r <
outfalls.count(); ++r)
405 for (
int r = 0; r <
dividers.count(); ++r)
423 const auto ui =
static_cast<std::size_t
>(i);
425 subtype_row.resize(
static_cast<std::size_t
>(i) + 1, -1);
429 if (old == t && existing >= 0)
432 bool shifted =
false;
448 if (row !=
storages.count() - 1) shifted =
true;
break;
450 if (row !=
outfalls.count() - 1) shifted =
true;
break;
452 if (row !=
dividers.count() - 1) shifted =
true;
break;
472 auto drop = [i](
auto& tbl) ->
bool {
473 for (
int r = 0; r < tbl.count(); ++r)
474 if (tbl.node_idx[
static_cast<std::size_t
>(r)] == i) { tbl.erase_at(r);
return true; }
479 auto shift = [i](std::vector<int>& keys) {
480 for (
auto& k : keys)
if (k > i) --k;
492 if (i >= 0 && i <
static_cast<int>(
subtype_row.size())) {
493 const int r =
subtype_row[
static_cast<std::size_t
>(i)];
494 if (r >= 0 && r <
storages.count() &&
495 storages.node_idx[
static_cast<std::size_t
>(r)] == i)
504 if (i >= 0 && i <
static_cast<int>(
subtype_row.size())) {
505 const int r =
subtype_row[
static_cast<std::size_t
>(i)];
506 if (r >= 0 && r <
outfalls.count() &&
507 outfalls.node_idx[
static_cast<std::size_t
>(r)] == i)
516 if (i >= 0 && i <
static_cast<int>(
subtype_row.size())) {
517 const int r =
subtype_row[
static_cast<std::size_t
>(i)];
518 if (r >= 0 && r <
dividers.count() &&
519 dividers.node_idx[
static_cast<std::size_t
>(r)] == i)
Structure-of-Arrays (SoA) storage for all node types.
Definition NodeCoupling.cpp:16
@ FUNCTIONAL
Area = c + a*d^b.
Definition NodeData.hpp:106
@ FREE
Definition NodeData.hpp:71
NodeType
Node type codes.
Definition NodeData.hpp:59
@ JUNCTION
Definition NodeData.hpp:60
@ DIVIDER
Definition NodeData.hpp:62
@ STORAGE
Definition NodeData.hpp:63
@ OUTFALL
Definition NodeData.hpp:61
@ CUTOFF
Definition NodeData.hpp:83
Dense SoA for flow-divider properties (one row per DIVIDER node).
Definition NodeSubtypes.hpp:290
std::vector< double > cd
Weir discharge coefficient for WEIR dividers.
Definition NodeSubtypes.hpp:299
std::vector< std::string > link_name
Diversion link name (deferred resolution).
Definition NodeSubtypes.hpp:307
std::vector< int > curve
Diversion curve index for TABULAR dividers (-1 = none).
Definition NodeSubtypes.hpp:303
std::vector< double > cutoff
Cutoff flow for CUTOFF dividers.
Definition NodeSubtypes.hpp:297
void clear() noexcept
Drop all rows (capacity retained).
Definition NodeSubtypes.hpp:315
std::vector< DividerType > method
Diversion method (CUTOFF/OVERFLOW/TABULAR/WEIR).
Definition NodeSubtypes.hpp:295
int count() const noexcept
Number of divider rows.
Definition NodeSubtypes.hpp:312
int add_default(int i)
Insert a default divider row for base node i, keeping node_idx ascending; returns the inserted row in...
Definition NodeSubtypes.hpp:331
std::vector< double > max_depth
Weir max depth for WEIR dividers.
Definition NodeSubtypes.hpp:301
void reserve(int n)
Reserve capacity for n rows.
Definition NodeSubtypes.hpp:322
std::vector< int > link
Diversion link index (-1 = not set).
Definition NodeSubtypes.hpp:305
std::vector< std::string > curve_name
Diversion curve name (deferred resolution, TABULAR only).
Definition NodeSubtypes.hpp:309
void erase_at(int r)
Erase divider row r from every column.
Definition NodeSubtypes.hpp:347
std::vector< int > node_idx
Base NodeData index this row belongs to (the join key).
Definition NodeSubtypes.hpp:292
Structure-of-Arrays storage for all nodes.
Definition NodeData.hpp:130
int count() const noexcept
Number of nodes.
Definition NodeData.hpp:721
std::vector< NodeType > type
Node type for each node.
Definition NodeData.hpp:137
Owns the three node subtype side-tables plus the reverse index map.
Definition NodeSubtypes.hpp:373
int divider_row(int i) const noexcept
Divider side-table row for base node i, or -1 if not a divider (or the side-table is unbuilt)....
Definition NodeSubtypes.hpp:515
DividerData dividers
Definition NodeSubtypes.hpp:376
int storage_row(int i) const noexcept
Storage side-table row for base node i, or -1 if i is not a storage node (or the side-table is unbuil...
Definition NodeSubtypes.hpp:491
int set_node_type(NodeData &nodes, int i, NodeType t)
Set node i to t, creating/removing/moving its subtype row so the side-table stays the single source o...
Definition NodeSubtypes.hpp:422
void erase_node(int i, int n_after)
Drop node i's subtype row and renumber the join keys after a base node erase. Call after NodeData::er...
Definition NodeSubtypes.hpp:470
void rebuild_index(int n_nodes)
Recompute the reverse map (subtype_row) from the side-table rows.
Definition NodeSubtypes.hpp:399
void clear() noexcept
Drop all rows and the reverse map.
Definition NodeSubtypes.hpp:382
OutfallData outfalls
Definition NodeSubtypes.hpp:375
std::vector< int > subtype_row
base node index → row in its subtype table (-1 for junctions).
Definition NodeSubtypes.hpp:379
int outfall_row(int i) const noexcept
Outfall side-table row for base node i, or -1 if not an outfall (or the side-table is unbuilt)....
Definition NodeSubtypes.hpp:503
StorageData storages
Definition NodeSubtypes.hpp:374
Dense SoA for outfall boundary-condition properties (one row per OUTFALL).
Definition NodeSubtypes.hpp:200
std::vector< OutfallType > bc_type
Boundary condition type (FREE/NORMAL/FIXED/TIDAL/TIMESERIES).
Definition NodeSubtypes.hpp:205
void erase_at(int r)
Erase outfall row r from every column.
Definition NodeSubtypes.hpp:267
std::vector< int > link_idx
Cached connected-conduit index (-1 = none).
Definition NodeSubtypes.hpp:218
std::vector< uint8_t > has_flap_gate
Flap gate present (0/1).
Definition NodeSubtypes.hpp:214
void reserve(int n)
Reserve capacity for n rows.
Definition NodeSubtypes.hpp:239
std::vector< int > route_to
Subcatchment index to route discharge to (-1 = none).
Definition NodeSubtypes.hpp:216
int count() const noexcept
Number of outfall rows.
Definition NodeSubtypes.hpp:228
void clear() noexcept
Drop all rows (capacity retained).
Definition NodeSubtypes.hpp:231
std::vector< std::string > param_name
Stage-data table name for TIDAL/TIMESERIES, held for deferred name→index resolution in PostParseResol...
Definition NodeSubtypes.hpp:212
std::vector< double > ramp_2d
Cached wet/dry ramp factor [0,1] for the 2D tailwater override (0 = dry → free discharge,...
Definition NodeSubtypes.hpp:225
int add_default(int i)
Insert a default outfall row for base node i, keeping node_idx ascending; returns the inserted row in...
Definition NodeSubtypes.hpp:250
std::vector< double > param
Fixed stage, or tidal/timeseries table index (per bc_type). For TIDAL/TIMESERIES an unresolved refere...
Definition NodeSubtypes.hpp:209
std::vector< double > head_2d
Cached 2D surface head at the coupling point (sentinel -1e30).
Definition NodeSubtypes.hpp:222
std::vector< double > link_offset
Conduit offset at the outfall end.
Definition NodeSubtypes.hpp:220
std::vector< int > node_idx
Base NodeData index this row belongs to (the join key).
Definition NodeSubtypes.hpp:202
Dense SoA for storage-unit properties (one row per STORAGE node).
Definition NodeSubtypes.hpp:75
void clear() noexcept
Drop all rows (capacity retained).
Definition NodeSubtypes.hpp:120
int add_default(int i)
Insert a default storage row for base node i, keeping node_idx ascending; returns the inserted row in...
Definition NodeSubtypes.hpp:144
int count() const noexcept
Number of storage rows.
Definition NodeSubtypes.hpp:117
void reserve(int n)
Reserve capacity for n rows.
Definition NodeSubtypes.hpp:130
std::vector< double > exfil_imd
Green-Ampt initial moisture deficit for exfiltration (0-1).
Definition NodeSubtypes.hpp:114
std::vector< double > evap_frac
Fraction of potential evaporation realized (0-1).
Definition NodeSubtypes.hpp:104
std::vector< double > exfil_suction
Green-Ampt suction head for exfiltration.
Definition NodeSubtypes.hpp:110
std::vector< double > a
Area coefficient A (legacy a1). FUNCTIONAL: A·d^B; geometric shapes: the linear term of C + A·d + B·d...
Definition NodeSubtypes.hpp:87
std::vector< double > p3
Raw shape parameter 3 — side slope Z (run/rise), or height for PARABOLOID.
Definition NodeSubtypes.hpp:100
std::vector< double > b
Area coefficient B (legacy a2). FUNCTIONAL: the exponent; geometric shapes: the quadratic term.
Definition NodeSubtypes.hpp:90
std::vector< double > seep_rate
Seepage rate (project units/day).
Definition NodeSubtypes.hpp:102
std::vector< int > node_idx
Base NodeData index this row belongs to (the join key).
Definition NodeSubtypes.hpp:77
std::vector< int > curve
Storage curve index into TableData (-1 = not tabulated).
Definition NodeSubtypes.hpp:80
std::vector< double > p2
Raw shape parameter 2 — minor axis / base width W.
Definition NodeSubtypes.hpp:98
std::vector< double > exfil_ksat
Green-Ampt saturated conductivity for exfiltration.
Definition NodeSubtypes.hpp:112
std::vector< double > c
Area coefficient C (legacy a0). Baseline area at zero depth.
Definition NodeSubtypes.hpp:92
std::vector< std::string > curve_name
Curve name for deferred resolution.
Definition NodeSubtypes.hpp:82
std::vector< double > evap_loss
Evaporation loss this timestep (ft3).
Definition NodeSubtypes.hpp:106
std::vector< double > p1
Raw shape parameter 1 — major axis / base length L (geometric shapes only). Kept alongside the derive...
Definition NodeSubtypes.hpp:96
std::vector< double > exfil_loss
Exfiltration loss this timestep (ft3).
Definition NodeSubtypes.hpp:108
std::vector< StorageShape > shape
Surface-area relation. Selects how a/b/c below are interpreted.
Definition NodeSubtypes.hpp:84
void erase_at(int r)
Erase storage row r from every column.
Definition NodeSubtypes.hpp:170