24#ifndef OPENSWMM_ENGINE_LINK_DATA_HPP
25#define OPENSWMM_ENGINE_LINK_DATA_HPP
146 std::vector<double>
q0;
387 std::vector<double>
cd;
627 int count() const noexcept {
return static_cast<int>(
type.size()); }
630 const auto un =
static_cast<std::size_t
>(n);
633 node1.assign(un, -1);
634 node2.assign(un, -1);
647 slope.assign(un, 0.0);
650 beta.assign(un, 0.0);
656 q_max.assign(un, 0.0);
677 dqdh.assign(un, 0.0);
690 orate.assign(un, 0.0);
692 flow.assign(un, 0.0);
693 depth.assign(un, 0.0);
704 tags.assign(un, std::string{});
736 if (n <=
count())
return;
737 const auto un =
static_cast<std::size_t
>(n);
738 auto g = [&](
auto& vec,
auto def) { vec.resize(un, def); };
767 tags.resize(un, std::string{});
796 const auto ui =
static_cast<std::size_t
>(idx);
797 auto e = [&](
auto& v) {
if (ui < v.size()) v.erase(v.begin() +
static_cast<std::ptrdiff_t
>(idx)); };
841 const auto base = ui * np;
842 auto erase2d = [&](
auto& v) {
843 if (base + np <= v.size())
844 v.erase(v.begin() +
static_cast<std::ptrdiff_t
>(base),
845 v.begin() +
static_cast<std::ptrdiff_t
>(base + np));
853 const auto base = ui * np;
866 if (n_pollutants > 0) {
867 auto total =
static_cast<std::size_t
>(
count()) *
868 static_cast<std::size_t
>(n_pollutants);
878 if (n_pollutants > 0) {
879 auto total =
static_cast<std::size_t
>(
count()) *
880 static_cast<std::size_t
>(n_pollutants);
881 conc.assign(total, 0.0);
890 type.shrink_to_fit();
891 node1.shrink_to_fit();
892 node2.shrink_to_fit();
905 slope.shrink_to_fit();
908 beta.shrink_to_fit();
914 q_max.shrink_to_fit();
934 dqdh.shrink_to_fit();
948 orate.shrink_to_fit();
950 flow.shrink_to_fit();
951 depth.shrink_to_fit();
959 conc.shrink_to_fit();
963 tags.shrink_to_fit();
996 std::fill(
flow.begin(),
flow.end(), 0.0);
1004 std::fill(
conc.begin(),
conc.end(), 0.0);
Definition NodeCoupling.cpp:15
LinkType
Link type codes.
Definition LinkData.hpp:42
FlowClass
Link flow state.
Definition LinkData.hpp:87
XsectShape
Conduit cross-section shape code.
Definition LinkData.hpp:54
@ FORCE_MAIN
Circular force main (Hazen-Williams or D-W)
@ STREET_XSECT
Street cross-section.
@ IRREGULAR
User-supplied shape curve.
@ HORIZ_ELLIPSE
Horizontal elliptical pipe.
@ VERT_ELLIPSE
Vertical elliptical pipe.
@ CUSTOM
Shape from CURVE_SHAPE table.
@ RECT_ROUND
Rectangular-round bottom.
@ DUMMY
Dummy (no geometry)
@ RECT_TRIANG
Rectangular-triangular bottom.
Structure-of-Arrays storage for all links.
Definition LinkData.hpp:109
void resize(int n)
Definition LinkData.hpp:629
std::vector< double > stat_time_full_upstream
Definition LinkData.hpp:552
std::vector< double > orate
Orifice open/close rate (fraction per second).
Definition LinkData.hpp:400
std::vector< long > stat_norm_ltd
Count of steps with normal flow limiting.
Definition LinkData.hpp:543
std::vector< double > stat_vol_flow
Total volume conveyed by this link (project volume units).
Definition LinkData.hpp:509
std::vector< int > stat_pump_cycles
Number of pump on→off + off→on transitions per pump.
Definition LinkData.hpp:580
int stat_n_pollutants
Definition LinkData.hpp:573
std::vector< uint8_t > normal_flow_limited
Definition LinkData.hpp:365
std::vector< double > dqdh
Derivative dQ/dH for inlet-controlled culvert flow.
Definition LinkData.hpp:377
std::vector< double > stat_total_load
Cumulative pollutant loads transported through each link.
Definition LinkData.hpp:572
std::vector< double > old_volume
Volume at the previous timestep.
Definition LinkData.hpp:455
std::vector< double > time_last_set
Absolute date (decimal days) when target_setting last crossed an open<->closed boundary....
Definition LinkData.hpp:298
std::vector< double > old_depth
Depth at the previous timestep.
Definition LinkData.hpp:452
std::vector< char > rpt_flag
Whether this link is included in report/output (0=no, 1=yes).
Definition LinkData.hpp:499
std::vector< double > pump_shutoff
Pump shutoff depth (ft).
Definition LinkData.hpp:323
void reset_state() noexcept
Definition LinkData.hpp:995
std::vector< bool > pump_init_state
Initial pump on/off state.
Definition LinkData.hpp:317
std::vector< double > froude
Current froude number (absolute).
Definition LinkData.hpp:428
std::vector< int > culvert_code
Culvert type code (1-57, 0 = not a culvert).
Definition LinkData.hpp:361
std::vector< double > flow
Current flow rate (project flow units, +ve = node1→node2).
Definition LinkData.hpp:410
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:263
std::vector< int > pump_curve
Pump curve index into TableData.
Definition LinkData.hpp:314
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:533
std::vector< std::string > comments
Object comment from the INP file (';'-prefixed lines immediately above this link's data row),...
Definition LinkData.hpp:483
std::vector< XsectShape > xsect_shape
Cross-section shape.
Definition LinkData.hpp:159
int count() const noexcept
Definition LinkData.hpp:627
std::vector< long > stat_inlet_ctrl
Count of steps with inlet control.
Definition LinkData.hpp:544
std::vector< double > stat_max_filling
Maximum reported filling ratio (depth / full depth).
Definition LinkData.hpp:527
std::vector< double > stat_pump_on_time
Time pump was running (seconds).
Definition LinkData.hpp:583
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:735
std::vector< int > stat_flow_turn_sign
Sign of previous flow change for flow-turn detection.
Definition LinkData.hpp:613
std::vector< double > loss_outlet
Outlet loss coefficient.
Definition LinkData.hpp:343
std::vector< double > length
Conduit length (project length units).
Definition LinkData.hpp:180
std::vector< double > q_full
Full-pipe flow rate: q_full = xsect_s_full * beta.
Definition LinkData.hpp:214
std::vector< double > rough_factor
Roughness factor for head loss: GRAVITY * (n/PHI)^2.
Definition LinkData.hpp:208
std::vector< FlowClass > flow_class
Current flow class (DRY, SUBCRITICAL, etc.).
Definition LinkData.hpp:431
std::vector< double > param2
Rated capacity or parameter 2 (weir side slopes, orifice area, etc.).
Definition LinkData.hpp:393
std::vector< long > stat_flow_class
Definition LinkData.hpp:542
std::vector< double > stat_max_flow
Maximum reported flow rate (project flow units).
Definition LinkData.hpp:515
void resize_quality(int n_pollutants)
Resize per-link quality arrays after pollutant count is known.
Definition LinkData.hpp:876
std::vector< double > q0
Initial flow rate (project flow units).
Definition LinkData.hpp:146
void save_state() noexcept
Definition LinkData.hpp:988
std::vector< double > stat_time_full_both
Definition LinkData.hpp:560
std::vector< double > evap_loss_rate
Computed conduit evaporation loss rate (cfs per barrel).
Definition LinkData.hpp:352
std::vector< double > xsect_w_max
Full hydraulic width of cross-section.
Definition LinkData.hpp:168
std::vector< double > param1
Parameter 1 (orifice type: 0=BOTTOM, 1=SIDE; weir type encoding).
Definition LinkData.hpp:390
std::vector< double > stat_time_capacity_limited
Definition LinkData.hpp:564
std::vector< double > xsect_r_full
Full-pipe hydraulic radius.
Definition LinkData.hpp:220
std::vector< int > pump_curve_type
Pump curve type: 1=TYPE1..5=TYPE5, 6=Ideal, -1=not a pump.
Definition LinkData.hpp:331
std::vector< double > xsect_a_bot
Bottom area for FILLED_CIRCULAR, RECT_TRIANG shapes.
Definition LinkData.hpp:250
std::vector< double > seep_loss_rate
Computed conduit seepage loss rate (cfs per barrel).
Definition LinkData.hpp:355
std::vector< int > xsect_curve
Shape curve index (for IRREGULAR / CUSTOM shapes).
Definition LinkData.hpp:174
std::vector< double > xsect_yw_max
Depth at maximum width.
Definition LinkData.hpp:269
std::vector< double > stat_max_veloc
Maximum reported flow velocity (project length/time units).
Definition LinkData.hpp:521
std::vector< std::string > pump_curve_name
Pump curve name (for deferred resolution).
Definition LinkData.hpp:334
std::vector< double > q_max
Maximum flow rate at sMax: q_max = xsect_s_max * beta.
Definition LinkData.hpp:238
std::vector< double > roughness
Manning's roughness coefficient.
Definition LinkData.hpp:177
std::vector< double > stat_pump_volume
Total volume pumped (ft³).
Definition LinkData.hpp:586
void resize_loads(int n_pollutants)
Resize pollutant load arrays after pollutant count is known.
Definition LinkData.hpp:864
std::vector< double > stat_pump_energy
Total pump energy consumed (kWh).
Definition LinkData.hpp:593
int conc_n_pollutants
Number of pollutants in the quality arrays.
Definition LinkData.hpp:472
std::vector< double > volume
Current full-flow volume (project volume units).
Definition LinkData.hpp:422
std::vector< double > mod_length
Modified conduit length for CFL stability (project length units).
Definition LinkData.hpp:192
std::vector< LinkType > type
Link type.
Definition LinkData.hpp:116
std::vector< double > loss_avg
Average loss coefficient.
Definition LinkData.hpp:345
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 > loss_inlet
Inlet loss coefficient.
Definition LinkData.hpp:341
std::vector< double > conc
Current quality concentration in each link.
Definition LinkData.hpp:466
std::vector< double > cd
Discharge coefficient (dimensionless).
Definition LinkData.hpp:387
std::vector< long > stat_flow_turns
Count of flow direction reversals per link.
Definition LinkData.hpp:605
std::vector< double > stat_time_full_dnstream
Definition LinkData.hpp:556
std::vector< double > conc_old
Previous-step quality in each link.
Definition LinkData.hpp:469
std::vector< double > target_setting
Target setting from control rules.
Definition LinkData.hpp:288
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:257
std::vector< uint8_t > has_flap_gate
Flap gate on this conduit (uint8_t: 0=no, 1=yes).
Definition LinkData.hpp:347
std::vector< double > stat_max_flow_date
Definition LinkData.hpp:548
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:434
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:889
void erase_at(int idx)
Erase the link at index idx from every parallel array.
Definition LinkData.hpp:795
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:304
std::vector< double > xsect_y_full
Full depth of cross-section (project length units).
Definition LinkData.hpp:162
std::vector< double > crest_height
Crest height above upstream node invert (project length units).
Definition LinkData.hpp:384
std::vector< double > xsect_y_bot
Bottom depth for FILLED_CIRCULAR, RECT_TRIANG, RECT_ROUND shapes.
Definition LinkData.hpp:244
std::vector< std::string > tags
Per-object tag from the INP [TAGS] section.
Definition LinkData.hpp:491
static constexpr int N_FLOW_CLASSES
Per-link flow classification step counts.
Definition LinkData.hpp:541
std::vector< int > xsect_batch_shape
Cached batch (XSectBatch) shape code, translated from XsectShape at init.
Definition LinkData.hpp:276
std::vector< double > beta
Manning conveyance factor: beta = PHI * sqrt(|slope|) / n.
Definition LinkData.hpp:202
std::vector< double > depth
Current water depth at midpoint (project length units).
Definition LinkData.hpp:416
std::vector< bool > stat_pump_was_on
Previous pump state for cycle detection (true = on).
Definition LinkData.hpp:596
std::vector< double > pump_startup
Pump startup depth (ft).
Definition LinkData.hpp:320
std::vector< double > seep_rate
User-specified seepage rate (project units).
Definition LinkData.hpp:349
std::vector< int8_t > full_state
End-of-step full-pipe classification: 0=neither, 1=UP_FULL, 2=DN_FULL, 3=ALL_FULL.
Definition LinkData.hpp:442
std::vector< int > barrels
Number of identical barrels (conduits only, default 1).
Definition LinkData.hpp:195
std::vector< double > old_flow
Flow at the previous timestep.
Definition LinkData.hpp:449
std::vector< double > slope
Conduit slope (rise/run, dimensionless).
Definition LinkData.hpp:183
std::vector< double > stat_time_courant_critical
CFL time-step critical count per link.
Definition LinkData.hpp:621
std::vector< uint8_t > inlet_control
True if inlet control governs for this culvert link (uint8_t: 0=no, 1=yes).
Definition LinkData.hpp:371
std::vector< double > setting
Current link setting (0-1 for pumps/orifices/weirs, 1.0 default for conduits).
Definition LinkData.hpp:282