![]() |
OpenSWMM Engine
6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
|
Owned completed-source water/snow and conservative-pollutant trial driver. Context and kernel histories are copied; callbacks are borrowed synchronously. One owner serializes initialization, crediting, trials, reads and checkpoints. Stage advances private runoff/LID/snow state; commit adopts it with its group clock. Spatial receivers/hydraulic routing must settle separately. Liquid source and solid/liquid snow balances are distinct and paired, not double-counted rain. Qualified pollutants are conservative source-pool mixtures with drain removal; no land-use buildup/washoff, lumped groundwater, age/heat/reactions or production hot-start initialization is supplied. Private accepted-boundary restart requires a matching model and publication with paired source/surface/engine owners. More...
#include <SourceWaterDriver.hpp>
Classes | |
| struct | State |
Public Types | |
| using | BottomCeiling = std::function<double(int type, int unit, double start, double end)> |
| Synchronous LID bottom-capacity callback; caller-owned, never retained. Receives LID type/group and unit indices plus start/end elapsed seconds; returns a finite nonnegative accepted infiltration ceiling ft/s. It can be called for each weather subdivision. External side effects are not rolled back with private source trials. | |
| using | ForcingTransform = std::function<void(SourceForcingInterval&)> |
| Synchronous transform of a private resolved forcing-segment copy. Caller supplies completed-interval rates, preserves positive ordered start/ end/cohort indices and finite nonnegative rain/PET/factors. References must not escape the callback. Does not change immutable native clock records; caller-owned side effects are outside source rollback. | |
Public Member Functions | |
| SourceWaterDriver () | |
| Construct an uninitialized driver without source state or IO. Most data accessors require successful initialize(); clocks() alone can be read. | |
| ~SourceWaterDriver () | |
| Release private accepted/trial histories without committing a pending trial. Borrowed state/kernel/ledger references become invalid. Caller ends concurrent access and owns any external callback/receiver rollback or persistence. | |
| SourceWaterDriver (SourceWaterDriver &&) noexcept | |
| Move owned accepted/trial histories and source clocks without copying water. Transfers pending-group bookkeeping; caller releases prior borrows and does not use moved-from data accessors until assigning a valid driver. No synchronization or external receiver settlement is performed. | |
| SourceWaterDriver & | operator= (SourceWaterDriver &&) noexcept |
| Replace this driver's histories by move, discarding any prior private trial. | |
| SourceWaterDriver | waterTrial () const |
| Copy committed water, kernels, ledgers and clocks for an independent trial. | |
| void | checkpoint (detail::CompletedSourceArchive &archive, bool model) |
| Stream private native model or accepted runtime source histories. | |
| std::string | initialize (const SimulationContext &context, const std::vector< int > &seeds, const std::vector< std::pair< int, double > > &non_lid_areas={}, const lid::LIDSolver *initial_lids=nullptr, bool hydraulic_returns=false) |
| Build private source kernels/ledgers from a simulation-start model snapshot. | |
| std::string | configureSpatialCoverage (const std::vector< double > &inside_fractions) |
| Bind uniform inside fractions once before any source advancement. | |
| const std::vector< double > & | spatialFractions () const |
| Borrow accepted per-source inside physical-area fractions. | |
| std::string | creditSurfaceReturns (double start, const std::vector< SourceSurfaceReturn > &returns) |
| Validate and queue paired aquifer-return water/mass before source trials. | |
| std::string | creditOutfallReturns (double start, double end, const std::vector< double > &volumes) |
| Queue one explicitly accepted hydraulic-return interval exactly once. | |
| bool | acceptsOutfallReturns () const |
| Read whether explicit water-only hydraulic receipts were enabled. | |
| double | outfallReturnEnd () const |
| Read the last credited accepted hydraulic-return endpoint. | |
| const std::vector< SourceOutfallReturn > & | pendingOutfallReturns () const |
| Borrow accepted hydraulic receipts waiting for their source clock. | |
| std::string | stage (int group, double end, double completed_through, const RunoffSolver::InfiltrationBoundary *boundary=nullptr, const BottomCeiling *bottom_ceiling=nullptr, const ForcingTransform *forcing=nullptr) |
| Advance one source group into a private completed-interval trial. | |
| std::string | commit () |
| Adopt staged private water and its source-group endpoint together. | |
| void | cancel () |
| Drop an active water trial and its tracked pending group forcing. Retains accepted water/histories and does not undo caller callback/receiver effects. Safe without a tracked trial; cannot repair an untracked clock left by a copy exception before pending_group_ assignment in stage(). Invalidates trial borrows. | |
| const SourceClockGroups & | clocks () const |
| Borrow source membership, accepted endpoints and staged forcing clocks. | |
| const surface::SourceSnow & | snow (bool trial=false) const |
| Borrow trial or accepted snow state without copying it. | |
| const SimulationContext & | context (bool trial=false) const |
| Borrow trial or accepted context state without copying it. | |
| const RunoffSolver & | runoff (bool trial=false) const |
| Borrow trial or accepted runoff state without copying it. | |
| const lid::LIDSolver & | lids (bool trial=false) const |
| Borrow trial or accepted lids state without copying it. | |
| const std::vector< SourceWaterLedger > & | ledgers (bool trial=false) const |
| Borrow trial or accepted ledgers state without copying it. | |
| const std::vector< SourceWaterDelivery > & | deliveries (bool trial=false) const |
| Borrow trial or accepted deliveries state without copying it. | |
| const std::vector< SourceAtmosphericLedger > & | atmosphere (bool trial=false) const |
| Borrow trial or accepted atmosphere state without copying it. | |
| const std::vector< std::string > & | pollutantNames () const |
| Borrow ordered active source-pollutant identifiers from accepted state. | |
| const std::vector< SourcePollutantLedger > & | pollutants (bool trial=false) const |
| Borrow trial or accepted pollutants state without copying it. | |
| double | pollutantBalanceResidual (int group, int pollutant, bool trial=false) const |
| Read pollutantBalanceResidual for one selected source-clock group. | |
| double | pendingPollutantMass (int group, int pollutant, bool trial=false) const |
| Read pendingPollutantMass for one selected source-clock group. | |
| double | pendingVolume (int group, bool trial=false) const |
| Read pendingVolume for one selected source-clock group. | |
| double | storedVolume (int source) const |
| Sum accepted physical runoff/LID stored water for one source. | |
| double | balanceResidual (int group, bool trial=false) const |
| Read balanceResidual for one selected source-clock group. | |
Owned completed-source water/snow and conservative-pollutant trial driver. Context and kernel histories are copied; callbacks are borrowed synchronously. One owner serializes initialization, crediting, trials, reads and checkpoints. Stage advances private runoff/LID/snow state; commit adopts it with its group clock. Spatial receivers/hydraulic routing must settle separately. Liquid source and solid/liquid snow balances are distinct and paired, not double-counted rain. Qualified pollutants are conservative source-pool mixtures with drain removal; no land-use buildup/washoff, lumped groundwater, age/heat/reactions or production hot-start initialization is supplied. Private accepted-boundary restart requires a matching model and publication with paired source/surface/engine owners.
| using openswmm::runoff::SourceWaterDriver::BottomCeiling = std::function<double(int type, int unit, double start, double end)> |
Synchronous LID bottom-capacity callback; caller-owned, never retained. Receives LID type/group and unit indices plus start/end elapsed seconds; returns a finite nonnegative accepted infiltration ceiling ft/s. It can be called for each weather subdivision. External side effects are not rolled back with private source trials.
| using openswmm::runoff::SourceWaterDriver::ForcingTransform = std::function<void(SourceForcingInterval&)> |
Synchronous transform of a private resolved forcing-segment copy. Caller supplies completed-interval rates, preserves positive ordered start/ end/cohort indices and finite nonnegative rain/PET/factors. References must not escape the callback. Does not change immutable native clock records; caller-owned side effects are outside source rollback.
|
default |
Construct an uninitialized driver without source state or IO. Most data accessors require successful initialize(); clocks() alone can be read.
|
default |
Release private accepted/trial histories without committing a pending trial. Borrowed state/kernel/ledger references become invalid. Caller ends concurrent access and owns any external callback/receiver rollback or persistence.
|
defaultnoexcept |
Move owned accepted/trial histories and source clocks without copying water. Transfers pending-group bookkeeping; caller releases prior borrows and does not use moved-from data accessors until assigning a valid driver. No synchronization or external receiver settlement is performed.
| bool openswmm::runoff::SourceWaterDriver::acceptsOutfallReturns | ( | ) | const |
Read whether explicit water-only hydraulic receipts were enabled.
| const std::vector< SourceAtmosphericLedger > & openswmm::runoff::SourceWaterDriver::atmosphere | ( | bool | trial = false | ) | const |
Borrow trial or accepted atmosphere state without copying it.
| trial | True selects only an active water trial; false accepted state. |
| std::logic_error | Requested state absent. No fallback from trial to accepted. Reference/elements are owned by the selected state and can be invalidated by commit/cancel/checkpoint/move/destruction. Serialize reads with mutation and copy snapshots needed across state publication; never modify through a cast. |
| double openswmm::runoff::SourceWaterDriver::balanceResidual | ( | int | group, |
| bool | trial = false ) const |
Read balanceResidual for one selected source-clock group.
| group | Zero-based group index, bounds checked through groups().at(). |
| trial | True selects active private trial, false accepted state. |
| std::logic_error | Requested state absent; std::out_of_range invalid group index. No normalization, tolerance test, finite-value repair or state mutation occurs. Callers decide whether the residual is acceptable; trial reads do not commit it. |
| void openswmm::runoff::SourceWaterDriver::cancel | ( | ) |
Drop an active water trial and its tracked pending group forcing. Retains accepted water/histories and does not undo caller callback/receiver effects. Safe without a tracked trial; cannot repair an untracked clock left by a copy exception before pending_group_ assignment in stage(). Invalidates trial borrows.
| void openswmm::runoff::SourceWaterDriver::checkpoint | ( | detail::CompletedSourceArchive & | archive, |
| bool | model ) |
Stream private native model or accepted runtime source histories.
| [in,out] | archive | Matching CompletedSourceArchive reader/writer at the paired schema position; same-platform bytes, no standalone portable file format here. |
| model | True streams model/forcing/membership/footprint/configuration identity; false streams accepted water/snow/kernel/transfer/ledger/delivery state and optional hydraulic-return profile. Requires initialized state and no active water trial. |
| std::runtime_error | Pending clocks, kernel/shape/profile, snow-clock, finite water/mass tuple, atmospheric or conservation mismatch; archive errors also propagate. Read mutates this object progressively and may fail after a prefix; restore an isolated waterTrial/fresh matching model, finish containing archive validation, then publish all paired owners together. A write may emit a prefix before a later validation failure. Does not activate production restart or settle external receivers. |
|
inline |
Borrow source membership, accepted endpoints and staged forcing clocks.
| std::string openswmm::runoff::SourceWaterDriver::commit | ( | ) |
Adopt staged private water and its source-group endpoint together.
| std::string openswmm::runoff::SourceWaterDriver::configureSpatialCoverage | ( | const std::vector< double > & | inside_fractions | ) |
Bind uniform inside fractions once before any source advancement.
| inside_fractions | One finite [0,1] value per original subcatchment, including unowned rows. Represents reviewed physical footprint shares, not a water debit. |
| const SimulationContext & openswmm::runoff::SourceWaterDriver::context | ( | bool | trial = false | ) | const |
Borrow trial or accepted context state without copying it.
| trial | True selects only an active water trial; false accepted state. |
| std::logic_error | Requested state absent. No fallback from trial to accepted. Reference/elements are owned by the selected state and can be invalidated by commit/cancel/checkpoint/move/destruction. Serialize reads with mutation and copy snapshots needed across state publication; never modify through a cast. |
| std::string openswmm::runoff::SourceWaterDriver::creditOutfallReturns | ( | double | start, |
| double | end, | ||
| const std::vector< double > & | volumes ) |
Queue one explicitly accepted hydraulic-return interval exactly once.
| start | Finite elapsed seconds exactly equal outfallReturnEnd(). |
| end | Finite later accepted seconds within total simulation duration tolerance; no source group may be pending or physically ahead of this endpoint. |
| volumes | One finite nonnegative ft3 per original source; nonzero values require an owned source with positive full non-LID+LID footprint. Unowned entries are zero. |
| std::string openswmm::runoff::SourceWaterDriver::creditSurfaceReturns | ( | double | start, |
| const std::vector< SourceSurfaceReturn > & | returns ) |
Validate and queue paired aquifer-return water/mass before source trials.
| start | Finite exact completed clock for each referenced source group. |
| returns | Borrowed batch with owned source, originating non-LID pool (type=unit=-1, pool in [0,2]) or exact LID type/unit and positive physical footprint. volume is finite nonnegative ft3; mass has one finite nonnegative concentration*m3 value per source pollutant, all zero for zero water. Entries are not deduplicated: caller credits accepted receipts exactly once. |
| const std::vector< SourceWaterDelivery > & openswmm::runoff::SourceWaterDriver::deliveries | ( | bool | trial = false | ) | const |
Borrow trial or accepted deliveries state without copying it.
| trial | True selects only an active water trial; false accepted state. |
| std::logic_error | Requested state absent. No fallback from trial to accepted. Reference/elements are owned by the selected state and can be invalidated by commit/cancel/checkpoint/move/destruction. Serialize reads with mutation and copy snapshots needed across state publication; never modify through a cast. |
| std::string openswmm::runoff::SourceWaterDriver::initialize | ( | const SimulationContext & | context, |
| const std::vector< int > & | seeds, | ||
| const std::vector< std::pair< int, double > > & | non_lid_areas = {}, | ||
| const lid::LIDSolver * | initial_lids = nullptr, | ||
| bool | hydraulic_returns = false ) |
Build private source kernels/ledgers from a simulation-start model snapshot.
| context | Compatible fully initialized model at current_time==elapsed_ms==0, with aligned geometry/forcing/quality/name arrays and resolved runoff/LID outlets. Selected sources cannot use lumped groundwater or preexisting runon/pervious-return histories. Nonempty selection rejects water age, heat and reactions species; snow-enabled nonempty groups require water-only even without assigned packs. Conservative pollutants otherwise require finite nonnegative rain concentration, no decay/ co-pollutants/snow-only species or land uses. Snow delegates its own qualification. |
| seeds | Valid subcatchment indices selecting entire weakly connected source graphs through SourceClockGroups. Empty selection is allowed. |
| non_lid_areas | Optional reviewed (source index,m2) overrides forwarded to RunoffSolver::init instead of rounded project-area conversion. |
| initial_lids | Optional borrowed matching initialized LID water snapshot; group/usage order and area/source/control mappings must match. Copies water-only history without retaining the pointer/report writers. Null builds fresh LID state. |
| hydraulic_returns | Explicit accepted water-only outfall-return profile; rejects active source pollutants and requires compatible positive receiving footprints. |
| const std::vector< SourceWaterLedger > & openswmm::runoff::SourceWaterDriver::ledgers | ( | bool | trial = false | ) | const |
Borrow trial or accepted ledgers state without copying it.
| trial | True selects only an active water trial; false accepted state. |
| std::logic_error | Requested state absent. No fallback from trial to accepted. Reference/elements are owned by the selected state and can be invalidated by commit/cancel/checkpoint/move/destruction. Serialize reads with mutation and copy snapshots needed across state publication; never modify through a cast. |
| const lid::LIDSolver & openswmm::runoff::SourceWaterDriver::lids | ( | bool | trial = false | ) | const |
Borrow trial or accepted lids state without copying it.
| trial | True selects only an active water trial; false accepted state. |
| std::logic_error | Requested state absent. No fallback from trial to accepted. Reference/elements are owned by the selected state and can be invalidated by commit/cancel/checkpoint/move/destruction. Serialize reads with mutation and copy snapshots needed across state publication; never modify through a cast. |
|
defaultnoexcept |
Replace this driver's histories by move, discarding any prior private trial.
| double openswmm::runoff::SourceWaterDriver::outfallReturnEnd | ( | ) | const |
Read the last credited accepted hydraulic-return endpoint.
| const std::vector< SourceOutfallReturn > & openswmm::runoff::SourceWaterDriver::pendingOutfallReturns | ( | ) | const |
Borrow accepted hydraulic receipts waiting for their source clock.
| double openswmm::runoff::SourceWaterDriver::pendingPollutantMass | ( | int | group, |
| int | pollutant, | ||
| bool | trial = false ) const |
Read pendingPollutantMass for one selected source-clock group.
| group | Zero-based group index, bounds checked through groups().at(). |
| pollutant | Zero-based source mass-vector index, checked with names.at(). |
| trial | True selects active private trial, false accepted state. |
| std::logic_error | Requested state absent; std::out_of_range invalid group or pollutant index. No normalization, tolerance test, finite-value repair or state mutation occurs. Callers decide whether the residual is acceptable; trial reads do not commit it. |
| double openswmm::runoff::SourceWaterDriver::pendingVolume | ( | int | group, |
| bool | trial = false ) const |
Read pendingVolume for one selected source-clock group.
| group | Zero-based group index, bounds checked through groups().at(). |
| trial | True selects active private trial, false accepted state. |
| std::logic_error | Requested state absent; std::out_of_range invalid group index. No normalization, tolerance test, finite-value repair or state mutation occurs. Callers decide whether the residual is acceptable; trial reads do not commit it. |
| double openswmm::runoff::SourceWaterDriver::pollutantBalanceResidual | ( | int | group, |
| int | pollutant, | ||
| bool | trial = false ) const |
Read pollutantBalanceResidual for one selected source-clock group.
| group | Zero-based group index, bounds checked through groups().at(). |
| pollutant | Zero-based source mass-vector index, checked with names.at(). |
| trial | True selects active private trial, false accepted state. |
| std::logic_error | Requested state absent; std::out_of_range invalid group or pollutant index. No normalization, tolerance test, finite-value repair or state mutation occurs. Callers decide whether the residual is acceptable; trial reads do not commit it. |
| const std::vector< std::string > & openswmm::runoff::SourceWaterDriver::pollutantNames | ( | ) | const |
Borrow ordered active source-pollutant identifiers from accepted state.
| const std::vector< SourcePollutantLedger > & openswmm::runoff::SourceWaterDriver::pollutants | ( | bool | trial = false | ) | const |
Borrow trial or accepted pollutants state without copying it.
| trial | True selects only an active water trial; false accepted state. |
| std::logic_error | Requested state absent. No fallback from trial to accepted. Reference/elements are owned by the selected state and can be invalidated by commit/cancel/checkpoint/move/destruction. Serialize reads with mutation and copy snapshots needed across state publication; never modify through a cast. |
| const RunoffSolver & openswmm::runoff::SourceWaterDriver::runoff | ( | bool | trial = false | ) | const |
Borrow trial or accepted runoff state without copying it.
| trial | True selects only an active water trial; false accepted state. |
| std::logic_error | Requested state absent. No fallback from trial to accepted. Reference/elements are owned by the selected state and can be invalidated by commit/cancel/checkpoint/move/destruction. Serialize reads with mutation and copy snapshots needed across state publication; never modify through a cast. |
| const surface::SourceSnow & openswmm::runoff::SourceWaterDriver::snow | ( | bool | trial = false | ) | const |
Borrow trial or accepted snow state without copying it.
| trial | True selects only an active water trial; false accepted state. |
| std::logic_error | Requested state absent. No fallback from trial to accepted. Reference/elements are owned by the selected state and can be invalidated by commit/cancel/checkpoint/move/destruction. Serialize reads with mutation and copy snapshots needed across state publication; never modify through a cast. |
| const std::vector< double > & openswmm::runoff::SourceWaterDriver::spatialFractions | ( | ) | const |
Borrow accepted per-source inside physical-area fractions.
| std::string openswmm::runoff::SourceWaterDriver::stage | ( | int | group, |
| double | end, | ||
| double | completed_through, | ||
| const RunoffSolver::InfiltrationBoundary * | boundary = nullptr, | ||
| const BottomCeiling * | bottom_ceiling = nullptr, | ||
| const ForcingTransform * | forcing = nullptr ) |
Advance one source group into a private completed-interval trial.
| group | Valid initialized source-group index, no active water/pending clock trial. |
| end | Finite requested elapsed-second endpoint after that group's completed_end. |
| completed_through | Finite completed-forcing frontier at least end; bounded by simulation interval through SourceClockGroups::stage(). Not a prediction horizon. |
| boundary | Optional borrowed synchronous non-LID infiltration callback per RunoffSolver::InfiltrationBoundary: source, ponded feet, seconds and output ft/s; return true to use its reviewed capacity. Must not publish trial water externally. |
| bottom_ceiling | Optional borrowed LID callback returning capacity ft/s for type/unit/start/end. Required for selected inside native-bottom LIDs when partitioned. |
| forcing | Optional borrowed transform on each private weather subdivision; preserve interval/cohort/index validity and meaningful finite rates. Callback references cannot escape; external effects are not part of source rollback. |
| double openswmm::runoff::SourceWaterDriver::storedVolume | ( | int | source | ) | const |
Sum accepted physical runoff/LID stored water for one source.
| source | Original subcatchment index; bounds checked against accepted ledger. |
| SourceWaterDriver openswmm::runoff::SourceWaterDriver::waterTrial | ( | ) | const |
Copy committed water, kernels, ledgers and clocks for an independent trial.
| std::logic_error | Missing accepted state or an active water trial. Caller must also ensure source clocks are fully committed, including after an exception. Context value copies can retain external handle/callback references; do not use those to publish through a trial. Copy/allocation failures propagate; original accepted water is retained. Use the copy for multi-group/receiver coordination. |