OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm::twoD::SurfaceStateData Struct Reference

#include <SurfaceStateData.hpp>

Collaboration diagram for openswmm::twoD::SurfaceStateData:

Public Member Functions

void resize (int n_triangles, int n_vertices)
 
void save_state () noexcept
 
void reset_state () noexcept
 
void clear_reset_forcings () noexcept
 Clear RESET forcings after each step.
 
void update_statistics (const std::vector< double > &tri_area, double dt, int nthreads=1) noexcept
 

Public Attributes

const BoundaryDataboundary = nullptr
 
const NodeDatanodes_1d = nullptr
 
const std::vector< double > * node_row_conc = nullptr
 
const std::vector< CouplingPoint > * node_coupling = nullptr
 non-outfall points
 
SurfaceTransportState transport
 
std::vector< double > depth
 Mean wetted depth h̄ = V/A_wet (m) [reconstructed].
 
std::vector< double > head
 Free-surface elevation η (m) [reconstructed].
 
std::vector< double > volume
 Cell water volume V (m³) — the integrated state.
 
std::vector< double > grad_hx
 ∂h/∂x (unlimited gradient)
 
std::vector< double > grad_hy
 ∂h/∂y (unlimited gradient)
 
std::vector< double > grad_hx_lim
 Limited gradient X.
 
std::vector< double > grad_hy_lim
 Limited gradient Y.
 
std::vector< double > vert_head
 Head reconstructed at vertices.
 
std::vector< double > vert_depth_signed
 
std::vector< double > face_vx
 Cell velocity X component (m/s)
 
std::vector< double > face_vy
 Cell velocity Y component (m/s)
 
std::vector< double > cell_continuity_err
 
std::vector< double > edge_flux
 Normal flux through each edge.
 
std::vector< double > rainfall
 Rainfall intensity (m/s)
 
std::vector< double > evap_rate
 Evaporation demand rate (m/s, >= 0)
 
std::vector< double > infil_rate
 
std::vector< double > infil_applied
 
std::vector< double > coupling_flux
 Exchange with SWMM node (m/s, + = into 2D)
 
std::vector< double > coupling_applied
 
std::vector< double > net_source
 Net source/sink per cell (m/s)
 
std::vector< int8_t > rainfall_forced
 0=computed, 1=override, 2=add
 
std::vector< int8_t > rainfall_persist
 0=reset, 1=persist
 
std::vector< double > rainfall_force_val
 Forced rainfall value.
 
std::vector< int8_t > evap_forced
 0=computed, 1=override, 2=add
 
std::vector< int8_t > evap_persist
 0=reset, 1=persist
 
std::vector< double > evap_force_val
 Forced evaporation value.
 
std::vector< int8_t > coupling_forced
 0=computed, 1=override, 2=add
 
std::vector< int8_t > coupling_persist
 0=reset, 1=persist
 
std::vector< double > coupling_force_val
 Forced coupling value.
 
bool forcing_dirty = false
 
bool forcing_ever_set = false
 
std::vector< double > old_depth
 Mean depth at start of coupling interval.
 
std::vector< double > old_volume
 Volume at start of coupling interval (m³)
 
std::vector< double > stat_max_depth
 Maximum depth ψ_o seen at each cell (m)
 
std::vector< double > stat_max_velocity
 Max cell speed |v| = √(vx²+vy²) (m/s)
 
std::vector< double > stat_max_cont_err
 Max |cell_continuity_err| (m³/s)
 
std::vector< double > stat_cum_volume
 Cumulative volume through cell (m³)
 
double evap_loss_total = 0.0
 

Member Function Documentation

◆ clear_reset_forcings()

void openswmm::twoD::SurfaceStateData::clear_reset_forcings ( )
inlinenoexcept

Clear RESET forcings after each step.

◆ reset_state()

void openswmm::twoD::SurfaceStateData::reset_state ( )
inlinenoexcept

◆ resize()

void openswmm::twoD::SurfaceStateData::resize ( int n_triangles,
int n_vertices )
inline

◆ save_state()

void openswmm::twoD::SurfaceStateData::save_state ( )
inlinenoexcept

◆ update_statistics()

void openswmm::twoD::SurfaceStateData::update_statistics ( const std::vector< double > & tri_area,
double dt,
int nthreads = 1 )
inlinenoexcept

Update cumulative statistics / rendering envelopes.

Aggregates once per model (routing) step at the accepted end-of-step state. MUST be called after computeFaceVelocity and computeCellContinuity so face_vx/vy and cell_continuity_err hold the accepted values. All envelopes fuse into the single per-cell loop already walked for stat_cum_volume — no extra passes, no sub-step sampling.

Member Data Documentation

◆ boundary

const BoundaryData* openswmm::twoD::SurfaceStateData::boundary = nullptr

Non-owning view of the per-edge boundary conditions (owned by SurfaceRouter2D). nullptr ⇒ all boundary edges are no-flux walls (the legacy behaviour, and what the unit-test call sites that build a bare state get). When set, computeEdgeFluxes applies the per-type boundary flux (NORMAL_FLOW / SPECIFIED_STAGE / SPECIFIED_FLOW / RATING_CURVE). The pointer is shallow-copied on assignment (it references config, not per-cell state), which is fine — both copies see the same BC config.

◆ cell_continuity_err

std::vector<double> openswmm::twoD::SurfaceStateData::cell_continuity_err

◆ coupling_applied

std::vector<double> openswmm::twoD::SurfaceStateData::coupling_applied

SIGNED per-cell coupling exchange VOLUME (m³) accumulated since the last mass-balance read, then zeroed by it. Positive = water arrived in this cell from the 1D node (spill / outfall discharge); negative = water was abstracted from this cell into the node (drain).

Signed on purpose, and per cell on purpose. The domain totals (MassBalance2D::coupling_1d_to_2d_in / coupling_2d_to_1d_out) are two unsigned accumulators and cannot answer "what did THIS cell give or take", which is the question asked of a coupling point that flip-flops within a batch: the two directions cancel in the net and both are invisible in the totals. coupling_flux is a rate that is overwritten every step, so it cannot answer it either.

Booked at the SAME dt and the same share the marcher applied, exactly like infil_applied above and for the same reason — re-deriving it from end-of-step state is first-order and under-books the cells that dried mid-step.

◆ coupling_flux

std::vector<double> openswmm::twoD::SurfaceStateData::coupling_flux

Exchange with SWMM node (m/s, + = into 2D)

◆ coupling_force_val

std::vector<double> openswmm::twoD::SurfaceStateData::coupling_force_val

Forced coupling value.

◆ coupling_forced

std::vector<int8_t> openswmm::twoD::SurfaceStateData::coupling_forced

0=computed, 1=override, 2=add

◆ coupling_persist

std::vector<int8_t> openswmm::twoD::SurfaceStateData::coupling_persist

0=reset, 1=persist

◆ depth

std::vector<double> openswmm::twoD::SurfaceStateData::depth

Mean wetted depth h̄ = V/A_wet (m) [reconstructed].

◆ edge_flux

std::vector<double> openswmm::twoD::SurfaceStateData::edge_flux

Normal flux through each edge.

◆ evap_force_val

std::vector<double> openswmm::twoD::SurfaceStateData::evap_force_val

Forced evaporation value.

◆ evap_forced

std::vector<int8_t> openswmm::twoD::SurfaceStateData::evap_forced

0=computed, 1=override, 2=add

◆ evap_loss_total

double openswmm::twoD::SurfaceStateData::evap_loss_total = 0.0

Cumulative evaporation loss over the whole simulation (m³). Kept here (not in core's MassBalance2D, owned by another work stream) and folded into the API-level totals by Api2D.cpp.

◆ evap_persist

std::vector<int8_t> openswmm::twoD::SurfaceStateData::evap_persist

0=reset, 1=persist

◆ evap_rate

std::vector<double> openswmm::twoD::SurfaceStateData::evap_rate

Evaporation demand rate (m/s, >= 0)

◆ face_vx

std::vector<double> openswmm::twoD::SurfaceStateData::face_vx

Cell velocity X component (m/s)

◆ face_vy

std::vector<double> openswmm::twoD::SurfaceStateData::face_vy

Cell velocity Y component (m/s)

◆ forcing_dirty

bool openswmm::twoD::SurfaceStateData::forcing_dirty = false

Set by the forcing API and by clear_reset_forcings() when any flag changes; consumed by the co-advance to bypass its coarse (30 s) forcing-refresh cadence, so a one-shot (RESET) prescription applies on the very next step and expires on the step after — the per-step semantics the swmm_2d_force_* API documents.

◆ forcing_ever_set

bool openswmm::twoD::SurfaceStateData::forcing_ever_set = false

Sticky companion to forcing_dirty: set by the forcing API the first time any prescription is written, never cleared. clear_reset_forcings() is called once per routing step and is O(n_cells); on a model that never uses the forcing API (every deck without an external controller) the whole sweep is dead work, and this flag skips it.

◆ grad_hx

std::vector<double> openswmm::twoD::SurfaceStateData::grad_hx

∂h/∂x (unlimited gradient)

◆ grad_hx_lim

std::vector<double> openswmm::twoD::SurfaceStateData::grad_hx_lim

Limited gradient X.

◆ grad_hy

std::vector<double> openswmm::twoD::SurfaceStateData::grad_hy

∂h/∂y (unlimited gradient)

◆ grad_hy_lim

std::vector<double> openswmm::twoD::SurfaceStateData::grad_hy_lim

Limited gradient Y.

◆ head

std::vector<double> openswmm::twoD::SurfaceStateData::head

Free-surface elevation η (m) [reconstructed].

◆ infil_applied

std::vector<double> openswmm::twoD::SurfaceStateData::infil_applied

Infiltration APPLIED depth (m) accumulated since the last mass-balance read, then zeroed by it. Every site that integrates the infiltration sink into volume adds infilSink(...) * dt here with the SAME depth and the SAME dt it used, so the ledger books what the marcher actually removed. Re-deriving the loss from the accepted end-of-step depth is only first-order: a cell that dries mid-step is sunk at the higher early-step rate but re-derived at the ramped end-of-step rate, and the lazy tier integrates a stale depth across a whole sync interval. Both leave storage falling by more than the ledger books.

◆ infil_rate

std::vector<double> openswmm::twoD::SurfaceStateData::infil_rate

Infiltration loss rate (m/s, >= 0) — a HELD rate (plan §5.5.2, D-I1): Infil2D::updateRates republishes it on the INFIL_STEP cadence and it is held constant in between, exactly as rainfall is. The marcher NEVER evaluates an infiltration kernel per substep; it only consumes this array through infilSink(), so infiltration has no interaction with the LTS tiering or active set. All-zero when no [2D_INFILTRATION*] rows resolved — the bitwise-regression fast path (gate I7).

◆ net_source

std::vector<double> openswmm::twoD::SurfaceStateData::net_source

Net source/sink per cell (m/s)

◆ node_coupling

const std::vector<CouplingPoint>* openswmm::twoD::SurfaceStateData::node_coupling = nullptr

non-outfall points

◆ node_row_conc

const std::vector<double>* openswmm::twoD::SurfaceStateData::node_row_conc = nullptr

S4: the 1D nodes' PUBLISHED row values, [node * n_species + s] in the 2D transport row order (pollutant conc, MSX conc, age, temperature), assembled by the router before each advance and frozen for the batch. What a 1D→2D spill or outfall discharge arrives at.

◆ nodes_1d

const NodeData* openswmm::twoD::SurfaceStateData::nodes_1d = nullptr

Live node-coupling view, set by SurfaceRouter2D. The marcher evaluates the 1D↔2D orifice exchange per substep against the CURRENT 2D head (so it self-limits) and accumulates the exact ∫Q dt per point. nodes_1d is the 1D node data, frozen for the duration of the batch.

◆ old_depth

std::vector<double> openswmm::twoD::SurfaceStateData::old_depth

Mean depth at start of coupling interval.

◆ old_volume

std::vector<double> openswmm::twoD::SurfaceStateData::old_volume

Volume at start of coupling interval (m³)

◆ rainfall

std::vector<double> openswmm::twoD::SurfaceStateData::rainfall

Rainfall intensity (m/s)

◆ rainfall_force_val

std::vector<double> openswmm::twoD::SurfaceStateData::rainfall_force_val

Forced rainfall value.

◆ rainfall_forced

std::vector<int8_t> openswmm::twoD::SurfaceStateData::rainfall_forced

0=computed, 1=override, 2=add

◆ rainfall_persist

std::vector<int8_t> openswmm::twoD::SurfaceStateData::rainfall_persist

0=reset, 1=persist

◆ stat_cum_volume

std::vector<double> openswmm::twoD::SurfaceStateData::stat_cum_volume

Cumulative volume through cell (m³)

◆ stat_max_cont_err

std::vector<double> openswmm::twoD::SurfaceStateData::stat_max_cont_err

Max |cell_continuity_err| (m³/s)

◆ stat_max_depth

std::vector<double> openswmm::twoD::SurfaceStateData::stat_max_depth

Maximum depth ψ_o seen at each cell (m)

◆ stat_max_velocity

std::vector<double> openswmm::twoD::SurfaceStateData::stat_max_velocity

Max cell speed |v| = √(vx²+vy²) (m/s)

◆ transport

SurfaceTransportState openswmm::twoD::SurfaceStateData::transport

S1 — overland species transport. transport.active() is false (and every marcher species branch is skipped) unless the router sized it, so a hydrodynamics-only model pays one predicate per firing and is otherwise untouched. Embedded rather than pointed-to: it is per-cell STATE, sized with volume, and it is copied when the state is.

◆ vert_depth_signed

std::vector<double> openswmm::twoD::SurfaceStateData::vert_depth_signed

Render/output-only SIGNED vertex depth η_v − z_v (m) — wet-masked, depth-weighted reconstruction (reconstructVertexRenderDepths). Unlike vert_head, dry-cell bed elevations never contribute, and a wet cell votes only where its η reaches the corner (wetted-contact gate), so this field is safe to interpolate for the water surface. Emitted values are strictly positive or the 0 no-data sentinel (no qualifying incident cell); negatives appear only in files from older engines — readers stay negative-tolerant. NOT used by the solver.

◆ vert_head

std::vector<double> openswmm::twoD::SurfaceStateData::vert_head

Head reconstructed at vertices.

◆ volume

std::vector<double> openswmm::twoD::SurfaceStateData::volume

Cell water volume V (m³) — the integrated state.


The documentation for this struct was generated from the following file: