40#ifndef OPENSWMM_ENGINE_LINK_DATA_HPP
41#define OPENSWMM_ENGINE_LINK_DATA_HPP
162 std::vector<double>
q0;
578 int count() const noexcept {
return static_cast<int>(
type.size()); }
581 const auto un =
static_cast<std::size_t
>(n);
584 node1.assign(un, -1);
585 node2.assign(un, -1);
615 dqdh.assign(un, 0.0);
618 flow.assign(un, 0.0);
619 depth.assign(un, 0.0);
634 tags.assign(un, std::string{});
665 if (n <=
count())
return;
666 const auto un =
static_cast<std::size_t
>(n);
667 auto g = [&](
auto& vec,
auto def) { vec.resize(un, def); };
688 tags.resize(un, std::string{});
728 const auto un =
static_cast<std::size_t
>(n);
729 if (
type.capacity() >= un)
return;
730 auto r = [&](
auto& vec) { vec.reserve(un); };
759 const auto ui =
static_cast<std::size_t
>(idx);
760 auto e = [&](
auto& v) {
if (ui < v.size()) v.erase(v.begin() +
static_cast<std::ptrdiff_t
>(idx)); };
797 const auto base = ui * np;
798 auto erase2d = [&](
auto& v) {
799 if (base + np <= v.size())
800 v.erase(v.begin() +
static_cast<std::ptrdiff_t
>(base),
801 v.begin() +
static_cast<std::ptrdiff_t
>(base + np));
809 const auto base = ui * np;
822 if (n_pollutants > 0) {
823 auto total =
static_cast<std::size_t
>(
count()) *
824 static_cast<std::size_t
>(n_pollutants);
834 if (n_pollutants > 0) {
835 auto total =
static_cast<std::size_t
>(
count()) *
836 static_cast<std::size_t
>(n_pollutants);
837 conc.assign(total, 0.0);
846 type.shrink_to_fit();
847 node1.shrink_to_fit();
848 node2.shrink_to_fit();
873 dqdh.shrink_to_fit();
876 flow.shrink_to_fit();
877 depth.shrink_to_fit();
885 conc.shrink_to_fit();
889 tags.shrink_to_fit();
922 std::fill(
flow.begin(),
flow.end(), 0.0);
930 std::fill(
conc.begin(),
conc.end(), 0.0);
Definition NodeCoupling.cpp:16
LinkType
Link type codes.
Definition LinkData.hpp:58
@ CONDUIT
Definition LinkData.hpp:59
@ PUMP
Definition LinkData.hpp:60
@ WEIR
Definition LinkData.hpp:62
@ ORIFICE
Definition LinkData.hpp:61
@ OUTLET
Definition LinkData.hpp:63
FlowClass
Link flow state.
Definition LinkData.hpp:103
@ SUPERCRITICAL
Definition LinkData.hpp:108
@ DN_CRITICAL
Definition LinkData.hpp:110
@ SUBCRITICAL
Definition LinkData.hpp:107
@ UP_CRITICAL
Definition LinkData.hpp:109
@ DRY
Definition LinkData.hpp:104
@ UP_DRY
Definition LinkData.hpp:105
@ DN_DRY
Definition LinkData.hpp:106
XsectShape
Conduit cross-section shape code.
Definition LinkData.hpp:70
@ TRIANGULAR
Definition LinkData.hpp:76
@ RECT_CLOSED
Definition LinkData.hpp:73
@ ARCH
Arch pipe.
Definition LinkData.hpp:91
@ FORCE_MAIN
Circular force main (Hazen-Williams or D-W)
Definition LinkData.hpp:94
@ RECT_OPEN
Definition LinkData.hpp:74
@ BASKETHANDLE
Definition LinkData.hpp:85
@ STREET_XSECT
Street cross-section.
Definition LinkData.hpp:95
@ SEMICIRCULAR
Definition LinkData.hpp:86
@ IRREGULAR
User-supplied shape curve.
Definition LinkData.hpp:92
@ HORIZ_ELLIPSE
Horizontal elliptical pipe.
Definition LinkData.hpp:89
@ VERT_ELLIPSE
Vertical elliptical pipe.
Definition LinkData.hpp:90
@ CUSTOM
Shape from CURVE_SHAPE table.
Definition LinkData.hpp:93
@ RECT_ROUND
Rectangular-round bottom.
Definition LinkData.hpp:88
@ EGGSHAPED
Definition LinkData.hpp:80
@ SEMIELLIPTICAL
Definition LinkData.hpp:84
@ CATENARY
Definition LinkData.hpp:83
@ CIRCULAR
Definition LinkData.hpp:71
@ TRAPEZOIDAL
Definition LinkData.hpp:75
@ MODBASKETHANDLE
Definition LinkData.hpp:79
@ HORSESHOE
Definition LinkData.hpp:81
@ DUMMY
Dummy (no geometry)
Definition LinkData.hpp:96
@ PARABOLIC
Definition LinkData.hpp:77
@ POWER
Definition LinkData.hpp:78
@ RECT_TRIANG
Rectangular-triangular bottom.
Definition LinkData.hpp:87
@ FILLED_CIRCULAR
Definition LinkData.hpp:72
@ GOTHIC
Definition LinkData.hpp:82
Structure-of-Arrays storage for all links.
Definition LinkData.hpp:125
void resize(int n)
Definition LinkData.hpp:580
std::vector< double > stat_time_full_upstream
Definition LinkData.hpp:503
std::vector< long > stat_norm_ltd
Count of steps with normal flow limiting.
Definition LinkData.hpp:494
std::vector< double > stat_vol_flow
Total volume conveyed by this link (project volume units).
Definition LinkData.hpp:460
std::vector< int > stat_pump_cycles
Number of pump on→off + off→on transitions per pump.
Definition LinkData.hpp:531
int stat_n_pollutants
Definition LinkData.hpp:524
std::vector< double > dqdh
Derivative dQ/dH for inlet-controlled culvert flow.
Definition LinkData.hpp:327
std::vector< double > stat_total_load
Cumulative pollutant loads transported through each link.
Definition LinkData.hpp:523
std::vector< double > old_volume
Volume at the previous timestep.
Definition LinkData.hpp:406
std::vector< double > time_last_set
Absolute date (decimal days) when target_setting last crossed an open<->closed boundary....
Definition LinkData.hpp:292
std::vector< double > xsect_geom1
Raw [XSECTIONS] geometry parameters as supplied (display units), retained purely for lossless seriali...
Definition LinkData.hpp:201
std::vector< double > stat_time_slot_above
Time (s) the instantaneous slot share exceeded 1 %.
Definition LinkData.hpp:379
std::vector< double > old_depth
Depth at the previous timestep.
Definition LinkData.hpp:403
std::vector< char > rpt_flag
Whether this link is included in report/output (0=no, 1=yes).
Definition LinkData.hpp:450
std::vector< double > stat_vol_dt
∫ volume dt over the run (ft³·s) — the share denominator.
Definition LinkData.hpp:375
void reset_state() noexcept
Definition LinkData.hpp:921
std::vector< double > froude
Current froude number (absolute).
Definition LinkData.hpp:385
std::vector< double > flow
Current flow rate (project flow units, +ve = node1→node2).
Definition LinkData.hpp:344
std::vector< double > xsect_geom4
Definition LinkData.hpp:204
std::vector< double > xsect_s_full
Full-pipe section factor.
Definition LinkData.hpp:226
std::vector< double > xsect_r_bot
Multi-purpose shape param: wall length (RECT_TRIANG), wetted perimeter (FILLED_CIRCULAR).
Definition LinkData.hpp:257
std::vector< int > node1
Upstream node index.
Definition LinkData.hpp:138
std::vector< double > stat_time_surcharged
Total duration of surcharge (seconds).
Definition LinkData.hpp:484
std::vector< std::string > comments
Object comment from the INP file (';'-prefixed lines immediately above this link's data row),...
Definition LinkData.hpp:434
std::vector< XsectShape > xsect_shape
Cross-section shape.
Definition LinkData.hpp:175
int count() const noexcept
Definition LinkData.hpp:578
std::vector< long > stat_inlet_ctrl
Count of steps with inlet control.
Definition LinkData.hpp:495
std::vector< double > stat_max_filling
Maximum reported filling ratio (depth / full depth).
Definition LinkData.hpp:478
std::vector< double > stat_pump_on_time
Time pump was running (seconds).
Definition LinkData.hpp:534
std::vector< double > q_limit
Maximum allowable flow rate (project flow units, 0 = unlimited).
Definition LinkData.hpp:168
void grow_to(int n)
Grow all arrays to hold at least n links, preserving existing data.
Definition LinkData.hpp:664
std::vector< int > stat_flow_turn_sign
Sign of previous flow change for flow-turn detection.
Definition LinkData.hpp:564
std::vector< FlowClass > flow_class
Current flow class (DRY, SUBCRITICAL, etc.).
Definition LinkData.hpp:388
std::vector< long > stat_flow_class
Definition LinkData.hpp:493
std::vector< double > stat_max_flow
Maximum reported flow rate (project flow units).
Definition LinkData.hpp:466
void resize_quality(int n_pollutants)
Resize per-link quality arrays after pollutant count is known.
Definition LinkData.hpp:832
std::vector< double > q0
Initial flow rate (project flow units).
Definition LinkData.hpp:162
void save_state() noexcept
Definition LinkData.hpp:914
std::vector< double > stat_time_full_both
Definition LinkData.hpp:511
std::vector< double > xsect_w_max
Full hydraulic width of cross-section.
Definition LinkData.hpp:184
std::vector< double > stat_time_capacity_limited
Definition LinkData.hpp:515
std::vector< double > xsect_r_full
Full-pipe hydraulic radius.
Definition LinkData.hpp:220
std::vector< double > xsect_a_bot
Bottom area for FILLED_CIRCULAR, RECT_TRIANG shapes.
Definition LinkData.hpp:244
std::vector< int > xsect_curve
Shape curve index (for IRREGULAR / CUSTOM shapes).
Definition LinkData.hpp:210
std::vector< double > xsect_yw_max
Depth at maximum width.
Definition LinkData.hpp:263
std::vector< double > xsect_geom2
Definition LinkData.hpp:202
std::vector< double > stat_max_veloc
Maximum reported flow velocity (project length/time units).
Definition LinkData.hpp:472
std::vector< std::string > pump_curve_name
Pump curve name (for deferred resolution).
Definition LinkData.hpp:309
std::vector< double > stat_pump_volume
Total volume pumped (ft³).
Definition LinkData.hpp:537
std::vector< double > xsect_geom3
Definition LinkData.hpp:203
void resize_loads(int n_pollutants)
Resize pollutant load arrays after pollutant count is known.
Definition LinkData.hpp:820
std::vector< double > stat_pump_energy
Total pump energy consumed (kWh).
Definition LinkData.hpp:544
int conc_n_pollutants
Number of pollutants in the quality arrays.
Definition LinkData.hpp:423
std::vector< double > volume
Current full-flow volume (project volume units).
Definition LinkData.hpp:356
std::vector< LinkType > type
Link type.
Definition LinkData.hpp:132
std::vector< double > offset1
Link offset at upstream node (project length units above invert).
Definition LinkData.hpp:150
std::vector< double > offset2
Link offset at downstream node.
Definition LinkData.hpp:156
std::vector< double > conc
Current quality concentration in each link.
Definition LinkData.hpp:417
void reserve_to(int n)
Reserve capacity for n links without changing count().
Definition LinkData.hpp:726
std::vector< long > stat_flow_turns
Count of flow direction reversals per link.
Definition LinkData.hpp:556
std::vector< double > stat_time_full_dnstream
Definition LinkData.hpp:507
std::vector< double > conc_old
Previous-step quality in each link.
Definition LinkData.hpp:420
std::vector< double > target_setting
Target setting from control rules.
Definition LinkData.hpp:282
std::vector< double > xsect_s_bot
Multi-purpose shape param: side slope (RECT_TRIANG), C-factor (FORCE_MAIN), number of open sides (REC...
Definition LinkData.hpp:251
std::vector< uint8_t > has_flap_gate
Flap gate on this conduit (uint8_t: 0=no, 1=yes).
Definition LinkData.hpp:321
std::vector< double > stat_max_flow_date
Definition LinkData.hpp:499
std::vector< double > stat_peak_slot_share
Peak instantaneous slot share (slot_volume/volume, 0..1).
Definition LinkData.hpp:377
std::vector< double > slot_volume
Portion of volume held in the Preissmann slot (ft³).
Definition LinkData.hpp:365
std::vector< double > xsect_s_max
Maximum section factor (at depth of max conveyance).
Definition LinkData.hpp:232
std::vector< uint8_t > is_closed
True if the link is closed by a control rule (uint8_t: 0=no, 1=yes).
Definition LinkData.hpp:391
std::vector< int > node2
Downstream node index.
Definition LinkData.hpp:144
void shrink_to_fit()
Release excess vector capacity accumulated during parsing.
Definition LinkData.hpp:845
void erase_at(int idx)
Erase the link at index idx from every parallel array.
Definition LinkData.hpp:758
std::vector< double > xsect_a_full
Full-flow area of cross-section (sq project length units).
Definition LinkData.hpp:181
std::vector< int > direction
Flow direction: +1 = node1→node2, -1 = reversed.
Definition LinkData.hpp:298
std::vector< double > xsect_y_full
Full depth of cross-section (project length units).
Definition LinkData.hpp:178
std::vector< double > xsect_y_bot
Bottom depth for FILLED_CIRCULAR, RECT_TRIANG, RECT_ROUND shapes.
Definition LinkData.hpp:238
std::vector< std::string > tags
Per-object tag from the INP [TAGS] section.
Definition LinkData.hpp:442
static constexpr int N_FLOW_CLASSES
Per-link flow classification step counts.
Definition LinkData.hpp:492
std::vector< int > xsect_batch_shape
Cached batch (XSectBatch) shape code, translated from XsectShape at init.
Definition LinkData.hpp:270
std::vector< double > depth
Current water depth at midpoint (project length units).
Definition LinkData.hpp:350
std::vector< bool > stat_pump_was_on
Previous pump state for cycle detection (true = on).
Definition LinkData.hpp:547
std::vector< double > stat_slot_vol_dt
∫ slot_volume dt over the run (ft³·s).
Definition LinkData.hpp:373
std::vector< double > old_flow
Flow at the previous timestep.
Definition LinkData.hpp:400
std::vector< double > stat_time_courant_critical
CFL time-step critical count per link.
Definition LinkData.hpp:572
std::vector< double > setting
Current link setting (0-1 for pumps/orifices/weirs, 1.0 default for conduits).
Definition LinkData.hpp:276