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

#include <InterfaceFile.hpp>

Collaboration diagram for openswmm::iface::InterfaceManager:

Public Member Functions

void init (SimulationContext &ctx)
 Close prior files and reset per-run interpolation/mapping metadata.
 
int openFiles (const std::string &infile_path, const std::string &outfile_path)
 Open optional text routing interface streams.
 
int readFileHeader (SimulationContext &ctx)
 Read interface units, constituent mapping, nodes and the first data period.
 
void writeFileHeader (const SimulationContext &ctx)
 Write the routing interface header for current outlet nodes.
 
void readInflows (SimulationContext &ctx, double current_time)
 Advance file periods and add interpolated flow/quality into model source arrays.
 
void writeOutfallResults (const SimulationContext &ctx, double current_time)
 Append one period of selected outlet flow and pollutant results.
 
void closeFiles ()
 Close both owned interface streams if open.
 
double getFlow (int node_idx, double frac) const
 Interpolate flow for an interface-entry index.
 
double getQuality (int node_idx, int pollut_idx, double frac) const
 Interpolate a mapped pollutant concentration for an interface entry.
 
int getNumIfaceNodes () const
 Get number of interface nodes currently active.
 
int getIfaceNode (int index) const
 Translate an interface file entry into a project node index.
 
double getFrac () const
 Get the interpolation fraction (set during readInflows)
 

Member Function Documentation

◆ closeFiles()

void openswmm::iface::InterfaceManager::closeFiles ( )

Close both owned interface streams if open.

Sets handles NULL and ignores fclose results. Preserves mappings, interpolation values and times; call init for a per-run metadata reset.

Here is the caller graph for this function:

◆ getFlow()

double openswmm::iface::InterfaceManager::getFlow ( int node_idx,
double frac ) const

Interpolate flow for an interface-entry index.

Requires old/new arrays sized to parsed stride. Does not read more data or verify temporal bracketing.

Parameters
[in]node_idxInterface file entry index, not the project node index; outside [0,getNumIfaceNodes()) returns zero.
[in]fracInterpolation fraction; normally getFrac() in [0,1], but this method does not clamp.
Returns
(1-frac)*old+frac*new in internal cfs; out-of-range entry returns zero.
Here is the caller graph for this function:

◆ getFrac()

double openswmm::iface::InterfaceManager::getFrac ( ) const
inline

Get the interpolation fraction (set during readInflows)

◆ getIfaceNode()

int openswmm::iface::InterfaceManager::getIfaceNode ( int index) const

Translate an interface file entry into a project node index.

Parameters
[in]indexZero-based interface entry index.
Returns
Mapped project node index, or -1 for out-of-range entry or unresolved node name.

◆ getNumIfaceNodes()

int openswmm::iface::InterfaceManager::getNumIfaceNodes ( ) const
inline

Get number of interface nodes currently active.

◆ getQuality()

double openswmm::iface::InterfaceManager::getQuality ( int node_idx,
int pollut_idx,
double frac ) const

Interpolate a mapped pollutant concentration for an interface entry.

Caller ensures parsed value arrays/mapping are coherent. No pollutant unit conversion or concentration-range check.

Parameters
[in]node_idxInterface entry index, not project node index.
[in]pollut_idxProject pollutant index; absent or out-of-range mapping returns zero.
[in]fracInterpolation fraction, passed through without clamping.
Returns
Stored-file-unit concentration, or zero for invalid entry/missing pollutant.
Here is the caller graph for this function:

◆ init()

void openswmm::iface::InterfaceManager::init ( SimulationContext & ctx)

Close prior files and reset per-run interpolation/mapping metadata.

Sets active count zero, times/fraction zero and pollutant stride one; clears pollutant mapping but retains SoA vector contents and the prior flow-unit/report-step fields until a new header is parsed. Call before openFiles when reusing a manager.

Parameters
[in,out]ctxContext argument retained for the interface; current implementation does not read or modify it.
Here is the call graph for this function:

◆ openFiles()

int openswmm::iface::InterfaceManager::openFiles ( const std::string & infile_path,
const std::string & outfile_path )

Open optional text routing interface streams.

Output opens first and remains open if input later fails. Caller closes existing streams before reuse and calls closeFiles on failure/end; no destructor cleanup is declared. Path aliases are not checked for file identity.

Parameters
[in]infile_pathUTF-8 input path; empty disables opening input.
[in]outfile_pathUTF-8 output path; empty disables opening output. Existing file is truncated.
Returns
0 on success; -1 for exactly equal nonempty path strings, -2 for output-open failure, -3 for input-open failure.
Here is the call graph for this function:

◆ readFileHeader()

int openswmm::iface::InterfaceManager::readFileHeader ( SimulationContext & ctx)

Read interface units, constituent mapping, nodes and the first data period.

Populates manager incrementally without rollback; unmatched node IDs map to -1, unmatched pollutants remain absent. Unknown flow-unit text falls back to CFS; pollutant unit labels are read but not converted. First-period parse failure is ignored by this method, so success is not complete data validation.

Parameters
[in,out]ctxBorrowed model names/counts for lookup; model data is not changed by this header parser.
Returns
0 after a syntactically accepted header; -1 for no input or header read/format refusal.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ readInflows()

void openswmm::iface::InterfaceManager::readInflows ( SimulationContext & ctx,
double current_time )

Advance file periods and add interpolated flow/quality into model source arrays.

Lazily reads header if old_values is empty; header refusal closes both streams. Skips flows below FLOW_TOL and adds quality load only for positive flow and positive interpolated concentration. Input flow is converted to cfs; quality stays in file concentration units. No rollback on partial data parsing; no error code or clock advancement.

Parameters
[in,out]ctxAligned model source arrays; caller clears per-step iface accumulators before this additive load.
[in]current_timeAbsolute OADate days, expected nondecreasing; not elapsed simulation seconds.
Here is the call graph for this function:

◆ writeFileHeader()

void openswmm::iface::InterfaceManager::writeFileHeader ( const SimulationContext & ctx)

Write the routing interface header for current outlet nodes.

No-op without output stream. Lists FLOW in project display units, all pollutant labels as MG/L regardless of their configured units, then selected outlets. Uses printf IO without returning/checking write errors; does not flush.

Parameters
[in]ctxBorrowed aligned model options/names/type/degree arrays; report_step must be int-representable seconds.
Here is the call graph for this function:

◆ writeOutfallResults()

void openswmm::iface::InterfaceManager::writeOutfallResults ( const SimulationContext & ctx,
double current_time )

Append one period of selected outlet flow and pollutant results.

No-op without output stream. Writes node inflow converted from cfs to project flow units; unavailable concentration entries become zero. Uses current concentrations as stored, does not interpolate to report time or check/flush write errors.

Parameters
[in]ctxBorrowed model with aligned node names/inflow/type/degree arrays and optional pollutant concentration storage.
[in]current_timeAbsolute OADate timestamp decoded without timezone conversion.
Here is the call graph for this function:

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