OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm::lard::SegmentStore Class Reference

#include <SegmentStore.hpp>

Collaboration diagram for openswmm::lard::SegmentStore:

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.
 

Member Function Documentation

◆ add_species()

void openswmm::lard::SegmentStore::add_species ( int s,
double delta )
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.

Parameters
[in]sValid initialized species row, unchecked.
[in]deltaSigned caller-unit concentration increment; no positivity/finite validation.
Note
Adds concentration, not total mass. Does not book mass ledgers or advance time itself; caller supplies aging/source ownership and duration. Allocation-free, exclusive store access.
Here is the call graph for this function:

◆ capacity()

int openswmm::lard::SegmentStore::capacity ( ) const
inline

Read slots reserved per link ring.

Returns
Configured capacity (default100 before resize); no mutation or allocation.

◆ checkpoint()

void openswmm::lard::SegmentStore::checkpoint ( detail::CompletedSourceArchive & a)
inline

Serialize or restore fixed-sized segment ring arrays and validate restored numerical state.

Parameters
[in,out]aArchive 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.
Exceptions
std::runtime_errorInvalid 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.
Note
Exclusive checkpoint barrier; no hydraulic/clock advance or inventory ledger booking.

◆ clear_link()

void openswmm::lard::SegmentStore::clear_link ( int l)
inline

Remove one whole link's contents (init/re-seed).

Mark one ring empty without clearing its inactive backing slots.

Parameters
[in]lValid initialized link index.
Note
Resets head/count0; retained mass/volume is discarded logically without ledger booking. Exclusive lifecycle access; no allocation, numeric repair or clock advance.

◆ count()

int openswmm::lard::SegmentStore::count ( int l) const
inline

Read the number of live segments in one ring.

Parameters
[in]lValid nonnegative link below initialized n_links, unchecked.
Returns
Live count in0..capacity for a valid store; no allocation/state change.
Here is the caller graph for this function:

◆ decay_species()

double openswmm::lard::SegmentStore::decay_species ( int s,
double factor )
inline

Exact-exponential decay on one species over every LIVE segment.

Parameters
factorexp(-k·dt), applied multiplicatively.
Returns
the total mass removed (for the reacted ledger row).

Multiply one species in every live segment and return its signed inventory reduction.

Parameters
[in]sValid initialized species row, unchecked.
  • Additional argument factor: Finite concentration multiplier; caller qualifies range, routine does not clamp.
Returns
Sum volume*old_concentration*(1-factor), concentration*ft3; factor>1 produces negative removal.
Note
No ledger/clock booking; caller routes returned inventory to its family ledger. Allocation-free, exclusive mutation; no numerical/domain validation.
Here is the call graph for this function:

◆ drain_back()

double openswmm::lard::SegmentStore::drain_back ( int l,
double vol_target,
double * mass_out )
inline

Drain up to vol_target from the BACK (downstream end).

Parameters
mass_outns_ entries, ACCUMULATED into (not reset) — the mass carried by the drained water.
Returns
the volume actually drained (< target iff the link emptied).

Drain available water from the back (largest logical index) and accumulate its species inventories.

Parameters
[in]lValid initialized link index.
[in]vol_targetFinite desired withdrawal ft3; nonpositive/NaN drains nothing.
  • Additional argument mass_out: Writable species() tuple, adds concentration*ft3 without initial clearing; nonaliasing ring storage and stable throughout call.
Returns
Actual drained ft3 up to available ring volume; empties exhausted segments and updates ring.
Note
Requires finite nonnegative stored water/concentrations and positive ring capacity. No allocation, ledger or clock update; caller owns removed inventory booking and exclusive ring access.
Here is the call graph for this function:

◆ drain_front()

double openswmm::lard::SegmentStore::drain_front ( int l,
double vol_target,
double * mass_out )
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.

Parameters
[in]lValid initialized link index.
[in]vol_targetFinite desired withdrawal ft3; nonpositive/NaN drains nothing.
[in,out]mass_outWritable species() tuple, adds concentration*ft3 without initial clearing; nonaliasing ring storage and stable throughout call.
Returns
Actual drained ft3 up to available ring volume; empties exhausted segments and updates ring.
Note
Requires finite nonnegative stored water/concentrations and positive ring capacity. No allocation, ledger or clock update; caller owns removed inventory booking and exclusive ring access.
Here is the call graph for this function:

◆ mean_conc()

void openswmm::lard::SegmentStore::mean_conc ( int l,
double * out ) const
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.

Parameters
[in]lValid initialized link index.
[out]outWritable species() tuple, nonaliasing ring concentrations/volumes; reset then filled.
Note
Leaves zeros for empty/zero total volume. No bounds/finite repair, allocation or owner mutation; borrowed output stays caller-owned, no ledger or clock effect.
Here is the call graph for this function:

◆ push_front()

void openswmm::lard::SegmentStore::push_front ( int l,
double volume,
const double * c )
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.

Parameters
[in]lValid initialized link index.
[in]volumePositive finite native water ft3; nonpositive returns (NaN is not rejected).
[in]cStable readable species() caller-unit concentration tuple, nonaliasing mutable ring.
Note
Merges with front when all tuple differences meet tolerance; at capacity merges front pair then inserts. Capacity>=2 required for full-ring operation. Preserves represented finite volume/mass with weighted merges but loses parcel resolution; no ledger/clock effect. No allocation or shape/finite validation; caller enforces finite nonnegative water and exclusive store mutation.
Here is the call graph for this function:

◆ resize()

void openswmm::lard::SegmentStore::resize ( int n_links,
int n_species,
int cap = kMaxSegmentsPerLink )
inline

Replace all segment storage with empty rings at new dimensions.

Parameters
[in]n_linksNonnegative link count, representable flattened products.
[in]n_speciesNonnegative concentration row count; zero still allocates one dummy slab.
[in]capRing capacity, at least2 when pushes can fill a ring and require pair merging.
Note
Resets all heads/counts/volumes/concentrations, discarding inventories without ledger booking. No dimension/overflow validation. Allocation can throw after dimensions/earlier vectors change; exclusive initialization/reset, not an evolved-state-preserving resize.

◆ reverse()

void openswmm::lard::SegmentStore::reverse ( int l)
inline

§4.4 flow reversal: front becomes back, in place.

Reverse live segment water and species tuple order in place.

Parameters
[in]lValid initialized link index.
Note
Reverses logical entries without changing head/count or total inventory; used when hydraulic orientation flips. No allocation or finite validation; caller owns exclusive ring mutation.
Here is the call graph for this function:

◆ seg_conc()

double openswmm::lard::SegmentStore::seg_conc ( int l,
int i,
int s ) const
inline

Read one species concentration in a live segment.

Parameters
[in]lValid initialized link index.
[in]iValid active logical segment index, front to back.
[in]sValid species row in0..species()-1.
Returns
Stored family concentration in caller's row units; no mutation/allocation or bounds validation.
Here is the caller graph for this function:

◆ seg_volume()

double openswmm::lard::SegmentStore::seg_volume ( int l,
int i ) const
inline

Read a live segment's stored water volume.

Parameters
[in]lValid initialized link index.
[in]iValid logical active segment index in0..count(l)-1, ordered front to back.
Returns
Native ft3; no bounds/finite check, mutation or allocation.
Here is the caller graph for this function:

◆ set_seg_conc()

void openswmm::lard::SegmentStore::set_seg_conc ( int l,
int i,
int s,
double c )
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.

Parameters
[in]lValid initialized link index.
[in]iValid active logical segment index.
[in]sValid initialized species row.
[in]cNew caller-unit concentration, copied without finite/sign validation.
Note
Exclusive ring mutation; no allocation, positivity repair or removed-mass bookkeeping.

◆ species()

int openswmm::lard::SegmentStore::species ( ) const
inline

Read initialized concentration row count.

Returns
Number of species, possibly0 before configuration; no mutation or allocation.
Here is the caller graph for this function:

◆ total_volume()

double openswmm::lard::SegmentStore::total_volume ( int l) const
inline

Sum live segment water volumes for one link.

Parameters
[in]lValid initialized link index, unchecked.
Returns
Native water ft3 summed over active ring entries; empty yields0. No repair, allocation or state change.
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: