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

Own topology, SI hydraulic averages and steady-flow trace preparation state. The C API validates topology/options and supplies aligned arrays. Direct C++ callers must preserve those invariants: valid endpoint indices, finite lengths, na.size()==nodes.size(), la.size()==links.size(), and valid positive solver tolerances/iteration limits. Serialize all access to one tracer; methods can mutate error/state and invoke synchronous callbacks. No internal transaction or C++ exception boundary is supplied; C wrappers catch most analysis exceptions. More...

#include <FlowTracer.hpp>

Collaboration diagram for openswmm::trace::FlowTracer:

Public Member Functions

int derive ()
 Derive directions, residence/travel times and flags from installed SI averages.
 
int prepare (const char *path, const char *cache, const char *digest, SWMM_TraceProgress cb, void *user, bool live=false)
 
int estimate (int direction, int seed, SWMM_TraceValue *nv, SWMM_TraceValue *lv, SWMM_TraceSummary &summary, SWMM_TraceProgress cb, void *user)
 Solve steady upstream/downstream fractions and conditional travel-time moments.
 
std::string cacheKey (const char *digest) const
 Build a versioned identity string for cached hydraulic averages.
 
bool readCache (const char *path, const std::string &key)
 Load exact-key HDF5 report metadata and seven-column node/link averages.
 
bool writeCache (const char *path, const std::string &key)
 Write owned SI averages through an HDF5 staging sidecar and replace the target.
 

Public Attributes

std::vector< Node > nodes
 
std::vector< Link > links
 
std::vector< SWMM_TraceNodeAverage > na
 
std::vector< SWMM_TraceLinkAverage > la
 
SWMM_TraceOptions options {}
 
SWMM_TraceInfo info {}
 
std::string error
 
bool prepared = false
 

Detailed Description

Own topology, SI hydraulic averages and steady-flow trace preparation state. The C API validates topology/options and supplies aligned arrays. Direct C++ callers must preserve those invariants: valid endpoint indices, finite lengths, na.size()==nodes.size(), la.size()==links.size(), and valid positive solver tolerances/iteration limits. Serialize all access to one tracer; methods can mutate error/state and invoke synchronous callbacks. No internal transaction or C++ exception boundary is supplied; C wrappers catch most analysis exceptions.

Member Function Documentation

◆ cacheKey()

std::string openswmm::trace::FlowTracer::cacheKey ( const char * digest) const

Build a versioned identity string for cached hydraulic averages.

Parameters
digestOptional NUL-terminated fingerprint; null contributes an empty string.
Returns
Independent key including trace versions, flow/velocity/reversal thresholds and length-prefixed topology IDs/types/flags/endpoints/lengths. Solver tolerance/ iteration count are deliberately absent; no hash/content read is performed here.
Here is the caller graph for this function:

◆ derive()

int openswmm::trace::FlowTracer::derive ( )

Derive directions, residence/travel times and flags from installed SI averages.

Returns
OK after setting prepared=true, INVALID after recording invalid averages. Resets derived flags/outgoing fields while walking; failure can leave partial derived state and does not itself reset an already true prepared flag. Conduits use length/absolute velocity for travel seconds, other link types zero. Storage residence uses volume/outgoing-withdrawal-loss; flagged exchange/ponding forces approximate/unknown residence as applicable. Unknown times are NaN.
Here is the caller graph for this function:

◆ estimate()

int openswmm::trace::FlowTracer::estimate ( int direction,
int seed,
SWMM_TraceValue * nv,
SWMM_TraceValue * lv,
SWMM_TraceSummary & summary,
SWMM_TraceProgress cb,
void * user )

Solve steady upstream/downstream fractions and conditional travel-time moments.

Parameters
directionValid SWMM_TRACE_UPSTREAM or SWMM_TRACE_DOWNSTREAM; direct callers must validate it because any other integer follows the downstream branches.
seedValid zero-based node index; no bounds check occurs in this method.
[out]nvRequired writable array of at least nodes.size() trace values.
[out]lvWritable array of at least links.size(); null only for zero links.
[out]summaryReset initially, then filled with reachability, terminal fractions, solver residual and partial SI-volume balance diagnostics.
cbOptional synchronous cancellation/progress callback; must not reenter or mutate this tracer.
userBorrowed callback context, passed through unchanged.
Returns
OK, CANCELLED or SOLVER after SCC-local sparse solves. Requires prepared coherent averages/topology/options; the C wrapper enforces readiness and capacities. Closed reachable circulation has NaN traversal ratios/unknown times and explicit trapped terminal fractions. Unknown-time edges contribute fraction but not known time moments. Solver failure can leave summary or output arrays partially updated; there is no rollback. Final completion callback return is ignored. Ratios are expected traversal amounts and can exceed one in circulating open networks; time fields use seconds and partial balance fields cubic metres.

◆ prepare()

int openswmm::trace::FlowTracer::prepare ( const char * path,
const char * cache,
const char * digest,
SWMM_TraceProgress cb,
void * user,
bool live = false )

live: scan the whole periods already written to an output that may still be growing (no footer needed, no cache; appends are fine, truncation fails).

Parameters
pathRequired nonempty NUL-terminated output filename. Completed mode requires successful finalized output; live mode accepts complete periods already written and ignores later appended periods during this scan. IDs are matched to topology by exact names; counts and reporting data must agree.
cacheOptional nonempty HDF5 sidecar destination/source. Completed mode can reuse an exact cache key; a requested new cache requires a nonempty digest.
digestOptional caller-supplied content fingerprint, incorporated with topology and selected thresholds. This method does not calculate/verify the digest.
cbOptional synchronous progress callback; nonzero requests cancellation at polling points. Must not mutate/reenter this tracer or throw across a C boundary.
userBorrowed opaque callback context, never owned or retained afterward.
liveDisable cache/digest and accept a growing file; final size may grow but shrink rejects the scan. Completed mode rejects size/write-time changes.
Returns
Trace status for preparation, IO, mismatch, invalid data or cancellation. Starts unprepared and clears error; computes time-averaged SI data by piecewise linear positive integrals, with a synthetic one-second averaging weight for one report and reported duration zero. Earlier failures can leave partial averages. After derive succeeds, a missing cache digest/write failure can return an error while prepared remains true; cancellation at the pre-cache poll clears it. Final 100% callback cancellation is ignored. Filesystem/allocation exceptions propagate.
Here is the call graph for this function:

◆ readCache()

bool openswmm::trace::FlowTracer::readCache ( const char * path,
const std::string & key )

Load exact-key HDF5 report metadata and seven-column node/link averages.

Parameters
pathRequired NUL-terminated sidecar filename when HDF5 is enabled.
keyExact expected cache identity; no digest verification occurs here.
Returns
False without HDF5 or on normal IO/key/dimension/average validation failure. HDF5 reads are serialized by a process-local cache mutex and error printing is suppressed. Successful load fills info/averages and derive() sets prepared. Normal failure clears prepared/error but may retain partially replaced metadata/ averages; allocation exceptions propagate without that cleanup guarantee.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeCache()

bool openswmm::trace::FlowTracer::writeCache ( const char * path,
const std::string & key )

Write owned SI averages through an HDF5 staging sidecar and replace the target.

Parameters
pathRequired NUL-terminated destination filename when HDF5 is enabled.
keyExact identity bytes written with six metadata values and flattened seven-column node/link averages. Caller supplies coherent prepared state.
Returns
False without HDF5 or for a normal create/write/flush/rename failure. A unique sibling .part timestamp/serial file is closed then renamed/replaced; normal failure attempts staging removal. Cache mutex serializes this implementation. Exceptions can leave staging files and propagate; no filesystem durability guarantee beyond the platform rename/flush calls is supplied. Tracer state is not modified.
Here is the caller graph for this function:

Member Data Documentation

◆ error

std::string openswmm::trace::FlowTracer::error

◆ info

SWMM_TraceInfo openswmm::trace::FlowTracer::info {}

◆ la

std::vector<SWMM_TraceLinkAverage> openswmm::trace::FlowTracer::la

◆ links

std::vector<Link> openswmm::trace::FlowTracer::links

◆ na

std::vector<SWMM_TraceNodeAverage> openswmm::trace::FlowTracer::na

◆ nodes

std::vector<Node> openswmm::trace::FlowTracer::nodes

◆ options

SWMM_TraceOptions openswmm::trace::FlowTracer::options {}

◆ prepared

bool openswmm::trace::FlowTracer::prepared = false

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