OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm_massbalance_impl.cpp File Reference

C API implementation — continuity errors and flux totals. More...

Include dependency graph for openswmm_massbalance_impl.cpp:

Functions

SWMM_ENGINE_API int swmm_get_runoff_continuity_error (SWMM_Engine engine, double *error)
 Compute the signed runoff water-continuity residual fraction.
 
SWMM_ENGINE_API int swmm_get_routing_continuity_error (SWMM_Engine engine, double *error)
 Compute the signed routing water-continuity residual fraction.
 
SWMM_ENGINE_API int swmm_get_quality_continuity_error (SWMM_Engine engine, int pollutant_idx, double *error)
 Compute a pollutant routing-continuity residual from stored mass totals.
 
SWMM_ENGINE_API int swmm_get_runoff_total (SWMM_Engine engine, int component, double *volume)
 Read a stored runoff water-balance volume.
 
SWMM_ENGINE_API int swmm_get_routing_total (SWMM_Engine engine, int component, double *volume)
 Read a stored routing water-balance volume.
 
SWMM_ENGINE_API int swmm_get_routing_stats (SWMM_Engine engine, double *avg_step, double *min_step, double *max_step, int *n_steps, double *pct_non_converged, double *avg_iterations, double *max_courant)
 Read accumulated routing timestep and convergence diagnostics.
 
SWMM_ENGINE_API int swmm_get_max_courant (SWMM_Engine engine, double *max_courant)
 Read the largest recorded routing Courant number.
 
SWMM_ENGINE_API int swmm_get_quality_seep_loss (SWMM_Engine engine, int pollutant_idx, double *mass)
 Read cumulative pollutant amount booked to seepage.
 
SWMM_ENGINE_API int swmm_get_quality_evap_loss (SWMM_Engine engine, int pollutant_idx, double *mass)
 Read cumulative pollutant amount booked to evaporation.
 

Detailed Description

C API implementation — continuity errors and flux totals.

See also
include/openswmm/engine/openswmm_massbalance.h
Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
License
Apache-2.0

Function Documentation

◆ swmm_get_max_courant()

SWMM_ENGINE_API int swmm_get_max_courant ( SWMM_Engine engine,
double * max_courant )

Read the largest recorded routing Courant number.

Parameters
[in]engineNon-null live engine. No lifecycle guard is imposed; final totals are available after end, and running reads reflect currently accumulated state.
[out]max_courantOptional destination for the dimensionless maximum; initialized value is zero.
Returns
SWMM_OK, or SWMM_ERR_BADHANDLE for null engine.

◆ swmm_get_quality_continuity_error()

SWMM_ENGINE_API int swmm_get_quality_continuity_error ( SWMM_Engine engine,
int pollutant_idx,
double * error )

Compute a pollutant routing-continuity residual from stored mass totals.

Sums the implementation wet-deposition/runoff/wet/RDII/dry-weather/external inflow terms plus initial storage against outflow/flooding/reaction and final storage. Residuals below 0.001 native amount are zeroed; otherwise divides by input when positive, or output when only output is positive. This function does not apply a percent conversion.

Parameters
[in]engineNon-null live engine. No lifecycle guard is imposed; final totals are available after end, and running reads reflect currently accumulated state.
[in]pollutant_idxZero-based pollutant row; an unavailable/negative row writes zero and still succeeds.
[out]errorOptional signed residual fraction; NULL returns success after checking the engine.
Returns
SWMM_OK, or SWMM_ERR_BADHANDLE for null engine.

◆ swmm_get_quality_evap_loss()

SWMM_ENGINE_API int swmm_get_quality_evap_loss ( SWMM_Engine engine,
int pollutant_idx,
double * mass )

Read cumulative pollutant amount booked to evaporation.

Returns the stored loss entry only; does not infer additional losses from water fluxes or current concentrations.

Parameters
[in]engineNon-null live engine. No lifecycle guard is imposed; final totals are available after end, and running reads reflect currently accumulated state.
[in]pollutant_idxZero-based native pollutant-ledger row; out-of-range or negative rows return zero without an index error.
[out]massOptional destination for the raw stored quality-ledger amount. Routing ledger amounts use internal water volume (ft3) times the concentration row unit; no pollutant/display-mass conversion is applied here.
Returns
SWMM_OK, or SWMM_ERR_BADHANDLE for null engine.

◆ swmm_get_quality_seep_loss()

SWMM_ENGINE_API int swmm_get_quality_seep_loss ( SWMM_Engine engine,
int pollutant_idx,
double * mass )

Read cumulative pollutant amount booked to seepage.

Returns the stored loss entry only; does not infer additional losses from water fluxes or current concentrations.

Parameters
[in]engineNon-null live engine. No lifecycle guard is imposed; final totals are available after end, and running reads reflect currently accumulated state.
[in]pollutant_idxZero-based native pollutant-ledger row; out-of-range or negative rows return zero without an index error.
[out]massOptional destination for the raw stored quality-ledger amount. Routing ledger amounts use internal water volume (ft3) times the concentration row unit; no pollutant/display-mass conversion is applied here.
Returns
SWMM_OK, or SWMM_ERR_BADHANDLE for null engine.

◆ swmm_get_routing_continuity_error()

SWMM_ENGINE_API int swmm_get_routing_continuity_error ( SWMM_Engine engine,
double * error )

Compute the signed routing water-continuity residual fraction.

Uses the current stored balance totals without converting units or updating final storage. A running query may therefore differ from the finalized end-of-run balance.

Parameters
[in]engineNon-null live engine. No lifecycle guard is imposed; final totals are available after end, and running reads reflect currently accumulated state.
[out]errorOptional fraction output, e.g. 0.001 means 0.1%. Positive indicates accounted input exceeds output/storage; zero when total input including initial storage is nonpositive.
Returns
SWMM_OK, or SWMM_ERR_BADHANDLE for null engine.

◆ swmm_get_routing_stats()

SWMM_ENGINE_API int swmm_get_routing_stats ( SWMM_Engine engine,
double * avg_step,
double * min_step,
double * max_step,
int * n_steps,
double * pct_non_converged,
double * avg_iterations,
double * max_courant )

Read accumulated routing timestep and convergence diagnostics.

All output pointers may be NULL independently; this getter does not advance or finalize the simulation.

Parameters
[in]engineNon-null live engine. No lifecycle guard is imposed; final totals are available after end, and running reads reflect currently accumulated state.
[out]avg_stepOptional mean physical routing step in seconds; zero when no steps are counted.
[out]min_stepOptional minimum step in seconds; the uninitialized sentinel is returned as zero.
[out]max_stepOptional maximum step in seconds.
[out]n_stepsOptional number of counted routing steps, converted to int.
[out]pct_non_convergedOptional percent of counted steps that did not converge, in [0,100] under normal accounting.
[out]avg_iterationsOptional mean solver iterations per counted step.
[out]max_courantOptional maximum recorded Courant number (dimensionless).
Returns
SWMM_OK, or SWMM_ERR_BADHANDLE for null engine.

◆ swmm_get_routing_total()

SWMM_ENGINE_API int swmm_get_routing_total ( SWMM_Engine engine,
int component,
double * volume )

Read a stored routing water-balance volume.

Includes cumulative flux and initial/final storage selectors. The value is read directly from the current mass-balance accumulator; final storage is only as current as the last balance update.

Parameters
[in]engineNon-null live engine. No lifecycle guard is imposed; final totals are available after end, and running reads reflect currently accumulated state.
[in]componentSWMM_RoutingTotal selector declared in this header.
[out]volumeNon-null destination in internal cubic feet (ft3), regardless of project display units. No display-volume conversion is performed.
Returns
SWMM_OK; SWMM_ERR_BADHANDLE for null engine or SWMM_ERR_BADPARAM for null volume/unknown component.

◆ swmm_get_runoff_continuity_error()

SWMM_ENGINE_API int swmm_get_runoff_continuity_error ( SWMM_Engine engine,
double * error )

Compute the signed runoff water-continuity residual fraction.

Uses the current stored balance totals without converting units or updating final storage. A running query may therefore differ from the finalized end-of-run balance.

Parameters
[in]engineNon-null live engine. No lifecycle guard is imposed; final totals are available after end, and running reads reflect currently accumulated state.
[out]errorOptional fraction output, e.g. 0.001 means 0.1%. Positive indicates accounted input exceeds output/storage; zero when total input including initial storage is nonpositive.
Returns
SWMM_OK, or SWMM_ERR_BADHANDLE for null engine.

◆ swmm_get_runoff_total()

SWMM_ENGINE_API int swmm_get_runoff_total ( SWMM_Engine engine,
int component,
double * volume )

Read a stored runoff water-balance volume.

Includes cumulative flux and initial/final storage selectors. The value is read directly from the current mass-balance accumulator; final storage is only as current as the last balance update.

Parameters
[in]engineNon-null live engine. No lifecycle guard is imposed; final totals are available after end, and running reads reflect currently accumulated state.
[in]componentSWMM_RunoffTotal selector declared in this header.
[out]volumeNon-null destination in internal cubic feet (ft3), regardless of project display units. No display-volume conversion is performed.
Returns
SWMM_OK; SWMM_ERR_BADHANDLE for null engine or SWMM_ERR_BADPARAM for null volume/unknown component.