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

#include <ArdEngine.hpp>

Collaboration diagram for openswmm::transport::ArdEngine:

Public Member Functions

bool init (SimulationContext &ctx)
 Build the transport mesh and size all state; call once after the model is fully resolved (Router::init done, pollutants known).
 
void step (SimulationContext &ctx, double dt)
 One transport step over the routing step dt.
 
bool initialized () const noexcept
 Read successful mesh/state initialization flag.
 
std::string checkpointState () const
 Export completed ARD numerical state without serializing live diagnostic writer.
 
void restoreCheckpointState (const std::string &, SimulationContext &)
 Decode completed ARD state into a fresh staging owner against compatible context.
 
const std::vector< std::string > & warnings () const noexcept
 Borrow initialization diagnostics retained by this transport owner.
 
void absorbTreatedNodeConc (SimulationContext &ctx)
 E5b treatment interop: absorb treated node concentrations back into the node stores.
 
std::vector< double > totalMass (const SimulationContext &ctx) const
 Sum represented inventory over cells and physical node stores for every carried row.
 
std::vector< ChannelThermalRegion > thermalRegions () const
 Export wet transport-cell thermal regions and their SI geometry.
 
std::string applyThermalIncrements (SimulationContext &, const std::vector< ChannelThermalIncrement > &)
 Add validated per-cell signed temperature increments then publish all families.
 
std::vector< ChannelSpeciesRegion > speciesRegions (const SimulationContext &) const
 Export carried row concentrations over available wet thermal transport-cell regions.
 
std::string applySpeciesIncrements (SimulationContext &, const std::vector< ChannelSpeciesIncrement > &)
 Validate unique cell species deltas then apply nonthermal rows and republish.
 

Member Function Documentation

◆ absorbTreatedNodeConc()

void openswmm::transport::ArdEngine::absorbTreatedNodeConc ( SimulationContext & ctx)

E5b treatment interop: absorb treated node concentrations back into the node stores.

Replace represented pollutant mass only at wet nodes marked for treatment.

Called by SWMMEngine AFTER QualitySolver::applyTreatment ran on the PUBLISHED nodes.conc. Only nodes with treatment defined are touched — untreated nodes keep their store mass bit-identical (a conc→mass→conc round trip is NOT exact in floating point, so a blanket absorb would break the no-treatment parity).

Parameters
[in]ctxPublic post-treatment node concentrations and prepared treatment mask matching owner.
Note
Uninitialized/no pollutants/no treatment returns; wet node>1e-9ft3 receives c*represented water, untreated/tiny nodes remain bit-identical. Does not alter native/age/heat rows, publish or book removal again; caller treatment already owns ledger. Allocation-free, unchecked parallel extents, exclusive post-treatment phase.
Here is the call graph for this function:

◆ applySpeciesIncrements()

std::string openswmm::transport::ArdEngine::applySpeciesIncrements ( SimulationContext & ctx,
const std::vector< ChannelSpeciesIncrement > & updates )

Validate unique cell species deltas then apply nonthermal rows and republish.

Parameters
[in,out]ctxMatching initialized public family stores and canonical row layout.
[in]updatesStable native-link/global-cell records, concentration_delta total-row tuples; thermal delta exactly0, finite/nonnegative candidate for every other carried row.
Returns
Empty success or descriptive validation error before writes. Duplicate cell region refused. No external mass ledger, hydraulic water or clock booking. Allocations/publish can throw after accepted updates; exclusive completed coupling owner and matching row units required.

◆ applyThermalIncrements()

std::string openswmm::transport::ArdEngine::applyThermalIncrements ( SimulationContext & ctx,
const std::vector< ChannelThermalIncrement > & updates )

Add validated per-cell signed temperature increments then publish all families.

Parameters
[in,out]ctxMatching initialized public quality/scalar arrays; publish updates reported means.
[in]updatesStable native-link/global-cell identities and signed celsius increments degC.
Returns
Empty success, descriptive message before writes for unavailable state/identity/nonfinite candidate. Repeated cell IDs allowed and prevalidated independently, so aggregate overflow is caller responsibility. Publish/allocation may throw after writes; no ledger/water/clock advance. Exclusive coupling phase.

◆ checkpointState()

std::string openswmm::transport::ArdEngine::checkpointState ( ) const

Export completed ARD numerical state without serializing live diagnostic writer.

Returns
Owning bytes with ready flag, fixed state arrays, node mass/volume, face flux and warnings/latch.
Exceptions
std::runtime_errorActive detailed output cannot continue from checkpoint; archive/allocation failures propagate. Does not validate finite values on save or serialize mesh/options/source row mappings, context inventory, engine clock or scratch; retain matching completed source separately. Stable owner required.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init()

bool openswmm::transport::ArdEngine::init ( SimulationContext & ctx)

Build the transport mesh and size all state; call once after the model is fully resolved (Router::init done, pollutants known).

Build a transport mesh and seed finite-volume carried species/node stores.

Returns
false if the mesh could not be built — the caller must fall back to the legacy quality path and surface the warnings.
Parameters
[in,out]ctxFully resolved hydraulic geometry, pollutant/native species, scalar seeds/options, ARD config and output path. May ensure MSX state, resize/reseed public age/heat arrays and open detail file.
Returns
True when mesh/state setup completes; false with warnings for active WALL profile, no rows, mesh errors or no cells. Caller decides legacy fallback and exposes warnings; earlier setup may remain.
Note
Replaces owned mesh/inventories/scratch; rows pollutants, MSX, optional age, final temperature. Mesh lengths/dispersion converted display->native ft; TARGET_DX ignored under hydraulic FV with warning. Resolves boundary/source mesh mapping, preserves age hotstart seeds but initializes thermal overrides. DETAILED_OUTPUT opens/truncates configured CSV and writes header; open failure only warns/disables writer. Allocation/IO/dependency exceptions can leave partial state; initialized=true only at final success. No hydraulic water or engine clock advance, exclusive initial lifecycle with stable dimensions.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialized()

bool openswmm::transport::ArdEngine::initialized ( ) const
inlinenoexcept

Read successful mesh/state initialization flag.

Returns
True only after final init success; does not validate current context/layout compatibility. No allocation/mutation.

◆ restoreCheckpointState()

void openswmm::transport::ArdEngine::restoreCheckpointState ( const std::string & bytes,
SimulationContext & ctx )

Decode completed ARD state into a fresh staging owner against compatible context.

Parameters
[in]bytesArchive from checkpointState with matching source/configuration/dimensions.
[in,out]ctxMatching completed native geometry/quality/options; ready snapshot calls init, which may reseed public scalar/native stores before fixed numerical state replacement.
Exceptions
std::runtime_errorDetail path configured, init failure, archive/trailing extent error, nonfinite stored numerical values or negative node volume. Other allocations/dependencies propagate.
Note
Decode mutates staging owner/context before validation, no rollback. Does not reject all negative cell area/concentration values. False-ready snapshot leaves existing owner untouched, so caller must use fresh staging owner and install only after broader physical/output validation. No engine clock advance.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ speciesRegions()

std::vector< ChannelSpeciesRegion > openswmm::transport::ArdEngine::speciesRegions ( const SimulationContext & ctx) const

Export carried row concentrations over available wet thermal transport-cell regions.

Parameters
[in]ctxStable canonical network row policy/names matching initialized owner.
Returns
Owning link/global-cell/normalized-interval snapshots with volume m3, canonical row names and pollutant/native declared concentrations, age s and thermal degC. Requires thermal row even when other species carried; absent heat yields empty. No mutation/clock change; allocation can throw.
Here is the call graph for this function:

◆ step()

void openswmm::transport::ArdEngine::step ( SimulationContext & ctx,
double dt )

One transport step over the routing step dt.

Advance one accepted projected-hydraulic ARD routing interval and publish family means.

Pre-condition: the external quality loads for this step have been assembled into nodes.qual_mass_in / qual_vol_in (the QualitySolver loader stage). Post-condition: links.conc, nodes.conc updated; pollutant old arrays capture entry values.

Parameters
[in,out]ctxCompleted hydraulics and freshly assembled pollutant/native/age/thermal sources; updates public current quality, entry old histories, HRT, heat/bed, reaction/clamp/forcing diagnostics.
[in]dtPositive finite accepted routing seconds; uninitialized/nonpositive returns.
Note
Captures pollutant old histories at entry, projects hydraulics and refreshes rows. Resynchronizes node volume to hydraulic store, scales mass for shrinking/tiny relative-growth corrections only. CFL=.9 chooses up to512 advection/dispersion substeps; cap warns once and may exceed stability target. After transport increments age by whole dt, applies atmospheric/bed heat, HRT/kinetics and bed solute, then publishes. Detail writer advances private time and appends CSV when active. Caller applies node treatment separately then absorbs it. No hydraulic/engine clock advance. Allocation/IO/solver errors can leave partial accepted state, histories/ledgers/output without rollback; exclusive phase.
Here is the call graph for this function:

◆ thermalRegions()

std::vector< ChannelThermalRegion > openswmm::transport::ArdEngine::thermalRegions ( ) const

Export wet transport-cell thermal regions and their SI geometry.

Returns
Owning channel region snapshots with native parent link, global cell region index, normalized along-link interval, volume m3, degC, length/depth m and free/wetted contact area m2. Empty when uninitialized/thermal row absent; closed geometry has free area0. No context mutation; allocation or geometry dependency may throw. Caller keeps initialized owner stable during read, snapshots later stale.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ totalMass()

std::vector< double > openswmm::transport::ArdEngine::totalMass ( const SimulationContext & ctx) const

Sum represented inventory over cells and physical node stores for every carried row.

Total species mass currently held (cells + node stores), one entry per species — the conservation ledger the unit gates check.

Parameters
[in]ctxUnused context retained for diagnostics interface.
Returns
Owning total-row vector of concentration*ft3 inventories, age s*ft3, temperature degC*ft3; no litre/user-mass or heat-capacity conversion. No physical/clock mutation, array validation or implicit initialization. Allocation can throw; stable matching owned state required.

◆ warnings()

const std::vector< std::string > & openswmm::transport::ArdEngine::warnings ( ) const
inlinenoexcept

Borrow initialization diagnostics retained by this transport owner.

Returns
Const reference to owner vector, nonowned, valid until owner destruction or next init/restore. Caller copies if retaining across lifecycle mutations; no allocation or context/clock change.
Here is the caller graph for this function:

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