![]() |
OpenSWMM Engine
6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
|
#include <SegmentStore.hpp>
Public Member Functions | |
| void | checkpoint (detail::CompletedSourceArchive &a) |
| Serialize or restore fixed-sized segment ring arrays and validate restored numerical state. | |
| void | resize (int n_links, int n_species, int cap=kMaxSegmentsPerLink) |
| Replace all segment storage with empty rings at new dimensions. | |
| int | count (int l) const |
| Read the number of live segments in one ring. | |
| int | species () const |
| Read initialized concentration row count. | |
| int | capacity () const |
| Read slots reserved per link ring. | |
| double | total_volume (int l) const |
| Sum live segment water volumes for one link. | |
| double | seg_volume (int l, int i) const |
| Read a live segment's stored water volume. | |
| double | seg_conc (int l, int i, int s) const |
| Read one species concentration in a live segment. | |
| void | set_seg_conc (int l, int i, int s, double c) |
| X3b: the RWPT exchange rewrites segment concentrations in place (mass-conserving by its own construction — every debit pairs with a credit; see RwptDispersion::exchange). | |
| void | mean_conc (int l, double *out) const |
Volume-weighted mean concentration over the link's segments. out has ns_ entries; an empty link reports 0. | |
| void | clear_link (int l) |
| Remove one whole link's contents (init/re-seed). | |
| double | drain_back (int l, double vol_target, double *mass_out) |
Drain up to vol_target from the BACK (downstream end). | |
| double | drain_front (int l, double vol_target, double *mass_out) |
| Same as drain_back but from the FRONT (upstream end) — the volume- reconciliation path for a link that shrank by more than its outflow. | |
| void | push_front (int l, double volume, const double *c) |
| Release a new segment at the FRONT (upstream end). | |
| void | reverse (int l) |
| §4.4 flow reversal: front becomes back, in place. | |
| void | add_species (int s, double delta) |
| Add a constant to one species on every LIVE segment. | |
| double | decay_species (int s, double factor) |
| Exact-exponential decay on one species over every LIVE segment. | |
|
inline |
Add a constant to one species on every LIVE segment.
X4: the water-age row ages by exactly +dt per routing step in every parcel (zero-order growth, water age plan §1). Only live segments are touched — stale slot contents never age.
Add a uniform concentration increment to one species in every live segment.
| [in] | s | Valid initialized species row, unchecked. |
| [in] | delta | Signed caller-unit concentration increment; no positivity/finite validation. |
|
inline |
Read slots reserved per link ring.
|
inline |
Serialize or restore fixed-sized segment ring arrays and validate restored numerical state.
| [in,out] | a | Archive already configured for read/write and this owner's dimensions; fixed() may mutate buffers on load. Dimensions nl/ns/cap are not serialized here and must match completed source. |
| std::runtime_error | Invalid head/count, negative/nonfinite volume or nonfinite concentration; archive failures also propagate. Negative finite concentration is accepted. Validation follows archive mutation with no rollback, and does not enforce unused-slot/active-volume consistency. |
|
inline |
Remove one whole link's contents (init/re-seed).
Mark one ring empty without clearing its inactive backing slots.
| [in] | l | Valid initialized link index. |
|
inline |
Read the number of live segments in one ring.
| [in] | l | Valid nonnegative link below initialized n_links, unchecked. |
|
inline |
Exact-exponential decay on one species over every LIVE segment.
| factor | exp(-k·dt), applied multiplicatively. |
Multiply one species in every live segment and return its signed inventory reduction.
| [in] | s | Valid initialized species row, unchecked.
|
|
inline |
Drain up to vol_target from the BACK (downstream end).
| mass_out | ns_ entries, ACCUMULATED into (not reset) — the mass carried by the drained water. |
Drain available water from the back (largest logical index) and accumulate its species inventories.
| [in] | l | Valid initialized link index. |
| [in] | vol_target | Finite desired withdrawal ft3; nonpositive/NaN drains nothing.
|
|
inline |
Same as drain_back but from the FRONT (upstream end) — the volume- reconciliation path for a link that shrank by more than its outflow.
Drain available water from the front (logical index0) and accumulate its species inventories.
| [in] | l | Valid initialized link index. |
| [in] | vol_target | Finite desired withdrawal ft3; nonpositive/NaN drains nothing. |
| [in,out] | mass_out | Writable species() tuple, adds concentration*ft3 without initial clearing; nonaliasing ring storage and stable throughout call. |
|
inline |
Volume-weighted mean concentration over the link's segments. out has ns_ entries; an empty link reports 0.
Compute all species' water-volume-weighted mean over a link's live segments.
| [in] | l | Valid initialized link index. |
| [out] | out | Writable species() tuple, nonaliasing ring concentrations/volumes; reset then filled. |
|
inline |
Release a new segment at the FRONT (upstream end).
Merges into the existing front segment when every species is within the §4.5 tolerance; on a full ring the two front segments merge first (D-L5) so the push never reallocates.
Insert incoming water at logical front, merging nearby tuples or freeing a full-ring slot.
| [in] | l | Valid initialized link index. |
| [in] | volume | Positive finite native water ft3; nonpositive returns (NaN is not rejected). |
| [in] | c | Stable readable species() caller-unit concentration tuple, nonaliasing mutable ring. |
|
inline |
Replace all segment storage with empty rings at new dimensions.
| [in] | n_links | Nonnegative link count, representable flattened products. |
| [in] | n_species | Nonnegative concentration row count; zero still allocates one dummy slab. |
| [in] | cap | Ring capacity, at least2 when pushes can fill a ring and require pair merging. |
|
inline |
§4.4 flow reversal: front becomes back, in place.
Reverse live segment water and species tuple order in place.
| [in] | l | Valid initialized link index. |
|
inline |
Read one species concentration in a live segment.
| [in] | l | Valid initialized link index. |
| [in] | i | Valid active logical segment index, front to back. |
| [in] | s | Valid species row in0..species()-1. |
|
inline |
Read a live segment's stored water volume.
| [in] | l | Valid initialized link index. |
| [in] | i | Valid logical active segment index in0..count(l)-1, ordered front to back. |
|
inline |
X3b: the RWPT exchange rewrites segment concentrations in place (mass-conserving by its own construction — every debit pairs with a credit; see RwptDispersion::exchange).
Replace one species concentration without volume or ledger changes.
| [in] | l | Valid initialized link index. |
| [in] | i | Valid active logical segment index. |
| [in] | s | Valid initialized species row. |
| [in] | c | New caller-unit concentration, copied without finite/sign validation. |
|
inline |
Read initialized concentration row count.
|
inline |
Sum live segment water volumes for one link.
| [in] | l | Valid initialized link index, unchecked. |