55#ifndef OPENSWMM_ENGINE_LINK_SUBTYPES_HPP
56#define OPENSWMM_ENGINE_LINK_SUBTYPES_HPP
175 const auto un =
static_cast<std::size_t
>(n);
217 const auto p =
static_cast<std::ptrdiff_t
>(
245 return static_cast<int>(p);
259 const auto p =
static_cast<std::ptrdiff_t
>(r);
326 const auto un =
static_cast<std::size_t
>(n);
348 const auto p =
static_cast<std::ptrdiff_t
>(
356 return static_cast<int>(p);
369 const auto p =
static_cast<std::ptrdiff_t
>(r);
386 std::vector<double>
cd;
415 const auto un =
static_cast<std::size_t
>(n);
433 const auto p =
static_cast<std::ptrdiff_t
>(
437 cd.insert(
cd.begin() + p, 0.0);
439 return static_cast<int>(p);
451 const auto p =
static_cast<std::ptrdiff_t
>(r);
454 cd.erase(
cd.begin() + p);
467 std::vector<double>
cd;
513 const auto un =
static_cast<std::size_t
>(n);
538 const auto p =
static_cast<std::ptrdiff_t
>(
542 cd.insert(
cd.begin() + p, 0.0);
545 cd2.insert(
cd2.begin() + p, 0.0);
550 return static_cast<int>(p);
562 const auto p =
static_cast<std::ptrdiff_t
>(r);
565 cd.erase(
cd.begin() + p);
568 cd2.erase(
cd2.begin() + p);
620 const auto un =
static_cast<std::size_t
>(n);
641 const auto p =
static_cast<std::ptrdiff_t
>(
649 return static_cast<int>(p);
661 const auto p =
static_cast<std::ptrdiff_t
>(r);
702 const int n = L.
count();
703 for (
int i = 0; i < n; ++i) {
704 switch (L.
type[
static_cast<std::size_t
>(i)]) {
709 pumps.add_default(i);
715 weirs.add_default(i);
751 subtype_row.assign(
static_cast<std::size_t
>(n_links), -1);
752 auto idx = [&](
const std::vector<int>& keys) {
753 for (
int r = 0; r < static_cast<int>(keys.size()); ++r)
754 subtype_row[
static_cast<std::size_t
>(keys[
static_cast<std::size_t
>(r)])] = r;
779 const auto ui =
static_cast<std::size_t
>(i);
781 subtype_row.resize(
static_cast<std::size_t
>(i) + 1, -1);
785 if (old == t && existing >= 0)
788 bool shifted =
false;
795 pumps.erase_at(existing);
801 weirs.erase_at(existing);
820 row =
pumps.add_default(i);
821 if (row !=
pumps.count() - 1)
830 row =
weirs.add_default(i);
831 if (row !=
weirs.count() - 1)
836 if (row !=
outlets.count() - 1)
860 auto drop = [i](
auto& tbl) ->
bool {
861 for (
int r = 0; r < tbl.count(); ++r)
862 if (tbl.link_idx[
static_cast<std::size_t
>(r)] == i) {
870 auto shift = [i](std::vector<int>& keys) {
876 shift(
pumps.link_idx);
878 shift(
weirs.link_idx);
949 int row_in(
int i,
const std::vector<int>& keys)
const noexcept {
950 if (i >= 0 && i <
static_cast<int>(
subtype_row.size())) {
951 const int r =
subtype_row[
static_cast<std::size_t
>(i)];
952 if (r >= 0 && r <
static_cast<int>(keys.size()) &&
953 keys[
static_cast<std::size_t
>(r)] == i)
Structure-of-Arrays (SoA) storage for all link types.
Definition ExchangeLaw.hpp:60
LinkType
Link type codes.
Definition LinkData.hpp:58
@ CONDUIT
Definition LinkData.hpp:58
@ PUMP
Definition LinkData.hpp:58
@ WEIR
Definition LinkData.hpp:58
@ ORIFICE
Definition LinkData.hpp:58
@ OUTLET
Definition LinkData.hpp:58
Dense SoA for conduit-only properties (one row per CONDUIT link).
Definition LinkSubtypes.hpp:79
std::vector< int > link_idx
Base LinkData index (join key)
Definition LinkSubtypes.hpp:80
int add_default(int i)
Insert a default ConduitData row at the sorted base-object key position.
Definition LinkSubtypes.hpp:216
void erase_at(int r)
Erase dense ConduitData row data and shift later dense rows down.
Definition LinkSubtypes.hpp:258
void clear() noexcept
Erase all ConduitData rows while retaining vector capacities.
Definition LinkSubtypes.hpp:137
std::vector< double > gw_dc
bed thickness / characteristic path (project length); seeded from the full depth
Definition LinkSubtypes.hpp:121
std::vector< double > evap_loss_rate
per-step evaporation loss
Definition LinkSubtypes.hpp:104
std::vector< double > beta
Definition LinkSubtypes.hpp:93
std::vector< double > roughness
Definition LinkSubtypes.hpp:82
std::vector< int > culvert_code
Definition LinkSubtypes.hpp:101
std::vector< double > rough_factor
Definition LinkSubtypes.hpp:94
std::vector< double > q_full
Definition LinkSubtypes.hpp:95
std::vector< double > mod_length
Definition LinkSubtypes.hpp:91
std::vector< uint8_t > gw_coupled
1 = signed conductance law applies
Definition LinkSubtypes.hpp:116
int count() const noexcept
Count ConduitData rows from the base-object join-key column.
Definition LinkSubtypes.hpp:129
std::vector< int8_t > full_state
per-step up/down full bitmask
Definition LinkSubtypes.hpp:108
std::vector< double > loss_outlet
Definition LinkSubtypes.hpp:98
std::vector< double > true_length
Definition LinkSubtypes.hpp:89
std::vector< int > barrels
Definition LinkSubtypes.hpp:92
std::vector< double > loss_avg
Definition LinkSubtypes.hpp:99
std::vector< double > q_max
Definition LinkSubtypes.hpp:96
void reserve(int n)
Request capacity for each ConduitData column without changing row count.
Definition LinkSubtypes.hpp:174
std::vector< double > loss_inlet
Definition LinkSubtypes.hpp:97
std::vector< double > seep_loss_rate
per-step seepage loss
Definition LinkSubtypes.hpp:105
std::vector< uint8_t > normal_flow_limited
per-step flag (reset each step)
Definition LinkSubtypes.hpp:106
std::vector< double > slope
Definition LinkSubtypes.hpp:90
std::vector< double > length
Definition LinkSubtypes.hpp:83
std::vector< double > seep_rate
Definition LinkSubtypes.hpp:100
std::vector< double > gw_kc
bed conductivity (project rate units); seeded from seep_rate
Definition LinkSubtypes.hpp:119
std::vector< double > gw_head_rel
water-table elevation MINUS the conduit's mid invert (project length)
Definition LinkSubtypes.hpp:118
std::vector< double > gw_gain_max
cap on the gaining direction, ONE barrel (project flow units)
Definition LinkSubtypes.hpp:123
std::vector< uint8_t > inlet_control
per-step culvert inlet-control flag
Definition LinkSubtypes.hpp:107
Structure-of-Arrays storage for all links.
Definition LinkData.hpp:119
int count() const noexcept
Count link rows from the type column.
Definition LinkData.hpp:646
std::vector< LinkType > type
Link type.
Definition LinkData.hpp:126
Owns the five link subtype side-tables plus the reverse index map.
Definition LinkSubtypes.hpp:681
WeirData weirs
Definition LinkSubtypes.hpp:685
int set_link_type(LinkData &links, int i, LinkType t)
Change one base link type and maintain its dense side-table row.
Definition LinkSubtypes.hpp:778
OrificeData orifices
Definition LinkSubtypes.hpp:684
PumpData pumps
Definition LinkSubtypes.hpp:683
void clear() noexcept
Erase all owned link subtype tables and reverse-map entries.
Definition LinkSubtypes.hpp:731
int pump_row(int i) const noexcept
Resolve a base link key into the pump side table.
Definition LinkSubtypes.hpp:906
std::vector< int > subtype_row
base link index → row in its subtype table (-1 if unset).
Definition LinkSubtypes.hpp:689
void build_default_rows(const LinkData &L)
Replace all subtype rows with defaults derived from current base link types.
Definition LinkSubtypes.hpp:700
OutletData outlets
Definition LinkSubtypes.hpp:686
int outlet_row(int i) const noexcept
Resolve a base link key into the outlet side table.
Definition LinkSubtypes.hpp:939
ConduitData conduits
Definition LinkSubtypes.hpp:682
int conduit_row(int i) const noexcept
Resolve a base link key into the conduit side table.
Definition LinkSubtypes.hpp:895
int weir_row(int i) const noexcept
Resolve a base link key into the weir side table.
Definition LinkSubtypes.hpp:928
int orifice_row(int i) const noexcept
Resolve a base link key into the orifice side table.
Definition LinkSubtypes.hpp:917
void erase_link(int i, int n_after)
Drop a deleted base link's subtype row and renumber later join keys.
Definition LinkSubtypes.hpp:859
void rebuild_index(int n_links)
Rebuild base link indices to dense subtype-row lookup.
Definition LinkSubtypes.hpp:750
Definition LinkSubtypes.hpp:383
void reserve(int n)
Request capacity for each OrificeData column without changing row count.
Definition LinkSubtypes.hpp:414
std::vector< double > orate
Open/close time in HOURS, as parsed.
Definition LinkSubtypes.hpp:387
void erase_at(int r)
Erase dense OrificeData row data and shift later dense rows down.
Definition LinkSubtypes.hpp:450
int count() const noexcept
Count OrificeData rows from the base-object join-key column.
Definition LinkSubtypes.hpp:392
std::vector< int > link_idx
Definition LinkSubtypes.hpp:384
std::vector< double > orifice_type
0 = BOTTOM, 1 = SIDE (legacy param1)
Definition LinkSubtypes.hpp:385
void clear() noexcept
Erase all OrificeData rows while retaining vector capacities.
Definition LinkSubtypes.hpp:400
int add_default(int i)
Insert a default OrificeData row at the sorted base-object key position.
Definition LinkSubtypes.hpp:432
std::vector< double > cd
Discharge coefficient.
Definition LinkSubtypes.hpp:386
Definition LinkSubtypes.hpp:582
std::vector< double > crest_height
Offset/crest.
Definition LinkSubtypes.hpp:585
int count() const noexcept
Count OutletData rows from the base-object join-key column.
Definition LinkSubtypes.hpp:595
std::vector< int > link_idx
Definition LinkSubtypes.hpp:583
void erase_at(int r)
Erase dense OutletData row data and shift later dense rows down.
Definition LinkSubtypes.hpp:660
void reserve(int n)
Request capacity for each OutletData column without changing row count.
Definition LinkSubtypes.hpp:619
std::vector< double > expon
Functional C2 exponent (legacy param2)
Definition LinkSubtypes.hpp:587
std::vector< double > outlet_type
Rating type (legacy param1)
Definition LinkSubtypes.hpp:584
std::vector< double > coeff
Functional C1 (legacy cd)
Definition LinkSubtypes.hpp:586
void clear() noexcept
Erase all OutletData rows while retaining vector capacities.
Definition LinkSubtypes.hpp:603
int add_default(int i)
Insert a default OutletData row at the sorted base-object key position.
Definition LinkSubtypes.hpp:640
std::vector< int > curve
TABULAR rating-curve index (legacy pump_curve reuse; -1 = functional)
Definition LinkSubtypes.hpp:589
Definition LinkSubtypes.hpp:288
void reserve(int n)
Request capacity for each PumpData column without changing row count.
Definition LinkSubtypes.hpp:325
std::vector< int > curve_type
Pump curve type (1-5, 6=ideal; -1 unset)
Definition LinkSubtypes.hpp:294
std::vector< uint8_t > init_state
Initial on/off (was vector<bool>)
Definition LinkSubtypes.hpp:291
void erase_at(int r)
Erase dense PumpData row data and shift later dense rows down.
Definition LinkSubtypes.hpp:368
std::vector< double > shutoff
Shutoff depth.
Definition LinkSubtypes.hpp:293
std::vector< double > startup
Startup depth.
Definition LinkSubtypes.hpp:292
std::vector< int > link_idx
Definition LinkSubtypes.hpp:289
int add_default(int i)
Insert a default PumpData row at the sorted base-object key position.
Definition LinkSubtypes.hpp:347
int count() const noexcept
Count PumpData rows from the base-object join-key column.
Definition LinkSubtypes.hpp:300
void clear() noexcept
Erase all PumpData rows while retaining vector capacities.
Definition LinkSubtypes.hpp:308
std::vector< int > curve
Pump curve table index (-1 = ideal)
Definition LinkSubtypes.hpp:290
Definition LinkSubtypes.hpp:463
void reserve(int n)
Request capacity for each WeirData column without changing row count.
Definition LinkSubtypes.hpp:512
void clear() noexcept
Erase all WeirData rows while retaining vector capacities.
Definition LinkSubtypes.hpp:492
std::vector< double > crest_height
Definition LinkSubtypes.hpp:469
std::vector< double > road_width
ROADWAY weir: road width across the flow (legacy Weir.roadWidth; authored length units until the reso...
Definition LinkSubtypes.hpp:474
std::vector< int > cd_curve
Discharge-coefficient curve index in ctx.tables, -1 none (legacy Weir.cdCurve)
Definition LinkSubtypes.hpp:478
void erase_at(int r)
Erase dense WeirData row data and shift later dense rows down.
Definition LinkSubtypes.hpp:561
std::vector< double > cd2
End-section discharge coeff (legacy cDisch2)
Definition LinkSubtypes.hpp:470
std::vector< uint8_t > can_surcharge
Surcharge YES/NO (legacy Weir.canSurcharge, default YES)
Definition LinkSubtypes.hpp:472
std::vector< double > weir_type
TRANSVERSE/SIDEFLOW/V-NOTCH/TRAPEZOIDAL/ROADWAY = 0..4 (legacy param1)
Definition LinkSubtypes.hpp:466
std::vector< double > cd
Discharge coefficient.
Definition LinkSubtypes.hpp:467
int add_default(int i)
Insert a default WeirData row at the sorted base-object key position.
Definition LinkSubtypes.hpp:537
std::vector< int > link_idx
Definition LinkSubtypes.hpp:464
std::vector< double > end_contractions
End contractions (legacy param2)
Definition LinkSubtypes.hpp:468
std::vector< int8_t > road_surface
ROADWAY weir: 0 none, 1 PAVED, 2 GRAVEL (legacy Weir.roadSurface)
Definition LinkSubtypes.hpp:476
int count() const noexcept
Count WeirData rows from the base-object join-key column.
Definition LinkSubtypes.hpp:484