24#ifndef OPENSWMM_ENGINE_LINK_DATA_HPP
25#define OPENSWMM_ENGINE_LINK_DATA_HPP
146 std::vector<double>
q0;
539 int count() const noexcept {
return static_cast<int>(
type.size()); }
542 const auto un =
static_cast<std::size_t
>(n);
545 node1.assign(un, -1);
546 node2.assign(un, -1);
576 dqdh.assign(un, 0.0);
579 flow.assign(un, 0.0);
580 depth.assign(un, 0.0);
590 tags.assign(un, std::string{});
621 if (n <=
count())
return;
622 const auto un =
static_cast<std::size_t
>(n);
623 auto g = [&](
auto& vec,
auto def) { vec.resize(un, def); };
642 tags.resize(un, std::string{});
671 const auto ui =
static_cast<std::size_t
>(idx);
672 auto e = [&](
auto& v) {
if (ui < v.size()) v.erase(v.begin() +
static_cast<std::ptrdiff_t
>(idx)); };
709 const auto base = ui * np;
710 auto erase2d = [&](
auto& v) {
711 if (base + np <= v.size())
712 v.erase(v.begin() +
static_cast<std::ptrdiff_t
>(base),
713 v.begin() +
static_cast<std::ptrdiff_t
>(base + np));
721 const auto base = ui * np;
734 if (n_pollutants > 0) {
735 auto total =
static_cast<std::size_t
>(
count()) *
736 static_cast<std::size_t
>(n_pollutants);
746 if (n_pollutants > 0) {
747 auto total =
static_cast<std::size_t
>(
count()) *
748 static_cast<std::size_t
>(n_pollutants);
749 conc.assign(total, 0.0);
758 type.shrink_to_fit();
759 node1.shrink_to_fit();
760 node2.shrink_to_fit();
785 dqdh.shrink_to_fit();
788 flow.shrink_to_fit();
789 depth.shrink_to_fit();
797 conc.shrink_to_fit();
801 tags.shrink_to_fit();
834 std::fill(
flow.begin(),
flow.end(), 0.0);
842 std::fill(
conc.begin(),
conc.end(), 0.0);
Definition NodeCoupling.cpp:15
LinkType
Link type codes.
Definition LinkData.hpp:42
@ CONDUIT
Definition LinkData.hpp:43
@ PUMP
Definition LinkData.hpp:44
@ WEIR
Definition LinkData.hpp:46
@ ORIFICE
Definition LinkData.hpp:45
@ OUTLET
Definition LinkData.hpp:47
FlowClass
Link flow state.
Definition LinkData.hpp:87
@ SUPERCRITICAL
Definition LinkData.hpp:92
@ DN_CRITICAL
Definition LinkData.hpp:94
@ SUBCRITICAL
Definition LinkData.hpp:91
@ UP_CRITICAL
Definition LinkData.hpp:93
@ DRY
Definition LinkData.hpp:88
@ UP_DRY
Definition LinkData.hpp:89
@ DN_DRY
Definition LinkData.hpp:90
XsectShape
Conduit cross-section shape code.
Definition LinkData.hpp:54
@ TRIANGULAR
Definition LinkData.hpp:60
@ RECT_CLOSED
Definition LinkData.hpp:57
@ ARCH
Arch pipe.
Definition LinkData.hpp:75
@ FORCE_MAIN
Circular force main (Hazen-Williams or D-W)
Definition LinkData.hpp:78
@ RECT_OPEN
Definition LinkData.hpp:58
@ BASKETHANDLE
Definition LinkData.hpp:69
@ STREET_XSECT
Street cross-section.
Definition LinkData.hpp:79
@ SEMICIRCULAR
Definition LinkData.hpp:70
@ IRREGULAR
User-supplied shape curve.
Definition LinkData.hpp:76
@ HORIZ_ELLIPSE
Horizontal elliptical pipe.
Definition LinkData.hpp:73
@ VERT_ELLIPSE
Vertical elliptical pipe.
Definition LinkData.hpp:74
@ CUSTOM
Shape from CURVE_SHAPE table.
Definition LinkData.hpp:77
@ RECT_ROUND
Rectangular-round bottom.
Definition LinkData.hpp:72
@ EGGSHAPED
Definition LinkData.hpp:64
@ SEMIELLIPTICAL
Definition LinkData.hpp:68
@ CATENARY
Definition LinkData.hpp:67
@ CIRCULAR
Definition LinkData.hpp:55
@ TRAPEZOIDAL
Definition LinkData.hpp:59
@ MODBASKETHANDLE
Definition LinkData.hpp:63
@ HORSESHOE
Definition LinkData.hpp:65
@ DUMMY
Dummy (no geometry)
Definition LinkData.hpp:80
@ PARABOLIC
Definition LinkData.hpp:61
@ POWER
Definition LinkData.hpp:62
@ RECT_TRIANG
Rectangular-triangular bottom.
Definition LinkData.hpp:71
@ FILLED_CIRCULAR
Definition LinkData.hpp:56
@ GOTHIC
Definition LinkData.hpp:66
Structure-of-Arrays storage for all links.
Definition LinkData.hpp:109
void resize(int n)
Definition LinkData.hpp:541
std::vector< double > stat_time_full_upstream
Definition LinkData.hpp:464
std::vector< long > stat_norm_ltd
Count of steps with normal flow limiting.
Definition LinkData.hpp:455
std::vector< double > stat_vol_flow
Total volume conveyed by this link (project volume units).
Definition LinkData.hpp:421
std::vector< int > stat_pump_cycles
Number of pump on→off + off→on transitions per pump.
Definition LinkData.hpp:492
int stat_n_pollutants
Definition LinkData.hpp:485
std::vector< double > dqdh
Derivative dQ/dH for inlet-controlled culvert flow.
Definition LinkData.hpp:311
std::vector< double > stat_total_load
Cumulative pollutant loads transported through each link.
Definition LinkData.hpp:484
std::vector< double > old_volume
Volume at the previous timestep.
Definition LinkData.hpp:367
std::vector< double > time_last_set
Absolute date (decimal days) when target_setting last crossed an open<->closed boundary....
Definition LinkData.hpp:276
std::vector< double > xsect_geom1
Raw [XSECTIONS] geometry parameters as supplied (display units), retained purely for lossless seriali...
Definition LinkData.hpp:185
std::vector< double > old_depth
Depth at the previous timestep.
Definition LinkData.hpp:364
std::vector< char > rpt_flag
Whether this link is included in report/output (0=no, 1=yes).
Definition LinkData.hpp:411
void reset_state() noexcept
Definition LinkData.hpp:833
std::vector< double > froude
Current froude number (absolute).
Definition LinkData.hpp:346
std::vector< double > flow
Current flow rate (project flow units, +ve = node1→node2).
Definition LinkData.hpp:328
std::vector< double > xsect_geom4
Definition LinkData.hpp:188
std::vector< double > xsect_s_full
Full-pipe section factor.
Definition LinkData.hpp:210
std::vector< double > xsect_r_bot
Multi-purpose shape param: wall length (RECT_TRIANG), wetted perimeter (FILLED_CIRCULAR).
Definition LinkData.hpp:241
std::vector< int > node1
Upstream node index.
Definition LinkData.hpp:122
std::vector< double > stat_time_surcharged
Total duration of surcharge (seconds).
Definition LinkData.hpp:445
std::vector< std::string > comments
Object comment from the INP file (';'-prefixed lines immediately above this link's data row),...
Definition LinkData.hpp:395
std::vector< XsectShape > xsect_shape
Cross-section shape.
Definition LinkData.hpp:159
int count() const noexcept
Definition LinkData.hpp:539
std::vector< long > stat_inlet_ctrl
Count of steps with inlet control.
Definition LinkData.hpp:456
std::vector< double > stat_max_filling
Maximum reported filling ratio (depth / full depth).
Definition LinkData.hpp:439
std::vector< double > stat_pump_on_time
Time pump was running (seconds).
Definition LinkData.hpp:495
std::vector< double > q_limit
Maximum allowable flow rate (project flow units, 0 = unlimited).
Definition LinkData.hpp:152
void grow_to(int n)
Grow all arrays to hold at least n links, preserving existing data.
Definition LinkData.hpp:620
std::vector< int > stat_flow_turn_sign
Sign of previous flow change for flow-turn detection.
Definition LinkData.hpp:525
std::vector< FlowClass > flow_class
Current flow class (DRY, SUBCRITICAL, etc.).
Definition LinkData.hpp:349
std::vector< long > stat_flow_class
Definition LinkData.hpp:454
std::vector< double > stat_max_flow
Maximum reported flow rate (project flow units).
Definition LinkData.hpp:427
void resize_quality(int n_pollutants)
Resize per-link quality arrays after pollutant count is known.
Definition LinkData.hpp:744
std::vector< double > q0
Initial flow rate (project flow units).
Definition LinkData.hpp:146
void save_state() noexcept
Definition LinkData.hpp:826
std::vector< double > stat_time_full_both
Definition LinkData.hpp:472
std::vector< double > xsect_w_max
Full hydraulic width of cross-section.
Definition LinkData.hpp:168
std::vector< double > stat_time_capacity_limited
Definition LinkData.hpp:476
std::vector< double > xsect_r_full
Full-pipe hydraulic radius.
Definition LinkData.hpp:204
std::vector< double > xsect_a_bot
Bottom area for FILLED_CIRCULAR, RECT_TRIANG shapes.
Definition LinkData.hpp:228
std::vector< int > xsect_curve
Shape curve index (for IRREGULAR / CUSTOM shapes).
Definition LinkData.hpp:194
std::vector< double > xsect_yw_max
Depth at maximum width.
Definition LinkData.hpp:247
std::vector< double > xsect_geom2
Definition LinkData.hpp:186
std::vector< double > stat_max_veloc
Maximum reported flow velocity (project length/time units).
Definition LinkData.hpp:433
std::vector< std::string > pump_curve_name
Pump curve name (for deferred resolution).
Definition LinkData.hpp:293
std::vector< double > stat_pump_volume
Total volume pumped (ft³).
Definition LinkData.hpp:498
std::vector< double > xsect_geom3
Definition LinkData.hpp:187
void resize_loads(int n_pollutants)
Resize pollutant load arrays after pollutant count is known.
Definition LinkData.hpp:732
std::vector< double > stat_pump_energy
Total pump energy consumed (kWh).
Definition LinkData.hpp:505
int conc_n_pollutants
Number of pollutants in the quality arrays.
Definition LinkData.hpp:384
std::vector< double > volume
Current full-flow volume (project volume units).
Definition LinkData.hpp:340
std::vector< LinkType > type
Link type.
Definition LinkData.hpp:116
std::vector< double > offset1
Link offset at upstream node (project length units above invert).
Definition LinkData.hpp:134
std::vector< double > offset2
Link offset at downstream node.
Definition LinkData.hpp:140
std::vector< double > conc
Current quality concentration in each link.
Definition LinkData.hpp:378
std::vector< long > stat_flow_turns
Count of flow direction reversals per link.
Definition LinkData.hpp:517
std::vector< double > stat_time_full_dnstream
Definition LinkData.hpp:468
std::vector< double > conc_old
Previous-step quality in each link.
Definition LinkData.hpp:381
std::vector< double > target_setting
Target setting from control rules.
Definition LinkData.hpp:266
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:235
std::vector< uint8_t > has_flap_gate
Flap gate on this conduit (uint8_t: 0=no, 1=yes).
Definition LinkData.hpp:305
std::vector< double > stat_max_flow_date
Definition LinkData.hpp:460
std::vector< double > xsect_s_max
Maximum section factor (at depth of max conveyance).
Definition LinkData.hpp:216
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:352
std::vector< int > node2
Downstream node index.
Definition LinkData.hpp:128
void shrink_to_fit()
Release excess vector capacity accumulated during parsing.
Definition LinkData.hpp:757
void erase_at(int idx)
Erase the link at index idx from every parallel array.
Definition LinkData.hpp:670
std::vector< double > xsect_a_full
Full-flow area of cross-section (sq project length units).
Definition LinkData.hpp:165
std::vector< int > direction
Flow direction: +1 = node1→node2, -1 = reversed.
Definition LinkData.hpp:282
std::vector< double > xsect_y_full
Full depth of cross-section (project length units).
Definition LinkData.hpp:162
std::vector< double > xsect_y_bot
Bottom depth for FILLED_CIRCULAR, RECT_TRIANG, RECT_ROUND shapes.
Definition LinkData.hpp:222
std::vector< std::string > tags
Per-object tag from the INP [TAGS] section.
Definition LinkData.hpp:403
static constexpr int N_FLOW_CLASSES
Per-link flow classification step counts.
Definition LinkData.hpp:453
std::vector< int > xsect_batch_shape
Cached batch (XSectBatch) shape code, translated from XsectShape at init.
Definition LinkData.hpp:254
std::vector< double > depth
Current water depth at midpoint (project length units).
Definition LinkData.hpp:334
std::vector< bool > stat_pump_was_on
Previous pump state for cycle detection (true = on).
Definition LinkData.hpp:508
std::vector< double > old_flow
Flow at the previous timestep.
Definition LinkData.hpp:361
std::vector< double > stat_time_courant_critical
CFL time-step critical count per link.
Definition LinkData.hpp:533
std::vector< double > setting
Current link setting (0-1 for pumps/orifices/weirs, 1.0 default for conduits).
Definition LinkData.hpp:260