![]() |
OpenSWMM Engine
6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
|
Top-level orchestrator for the 2D surface routing module. More...
#include <SurfaceRouter2D.hpp>
Classes | |
| struct | RestartState |
Public Types | |
| using | PendingBoundaryRow = twoD::PendingBoundaryRow |
Per-row buffer for [2D_BOUNDARY_CONDITIONS] parse output. | |
| using | PendingInitialQualityRow = twoD::PendingInitialQualityRow |
| using | PendingInitialBedQualityRow = twoD::PendingInitialBedQualityRow |
| using | PendingBoundaryQualityRow = twoD::PendingBoundaryQualityRow |
| using | PendingEdgeConveyanceRow = twoD::PendingEdgeConveyanceRow |
Per-row buffer for [2D_EDGE_CONVEYANCE] parse output (§11A). | |
Public Member Functions | |
| SurfaceRouter2D ()=default | |
| Create an inactive authoring router with empty owned physical/source state. | |
| ~SurfaceRouter2D ()=default | |
| Destroy owned router members and release solver/plugin resources. | |
| SurfaceRouter2D (const SurfaceRouter2D &)=delete | |
| SurfaceRouter2D & | operator= (const SurfaceRouter2D &)=delete |
| SurfaceRouter2D (SurfaceRouter2D &&)=default | |
| Move owned router members using their ordinary default move operations. | |
| SurfaceRouter2D & | operator= (SurfaceRouter2D &&)=default |
| Replace owned router members by default move assignment. | |
| void | initialize (SimulationContext &ctx) |
| Initialize the 2D module after input parsing is complete. | |
| void | initializeChannelGround (SimulationContext &ctx) |
| Bind selected finite channel contacts after 1D heat state is seeded. | |
| const ChannelGroundState & | channelGround () const noexcept |
| Borrow the shared finite channel/physical-soil thermal contact owner and cumulative J/native receipts. | |
| ChannelGroundState & | channelGround () noexcept |
| Borrow the shared finite channel/physical-soil thermal contact owner and cumulative J/native receipts. | |
| void | setCommonSourceStage (SimulationContext &ctx, CommonSourceStage &stage) |
| Internal qualification hook: externally owned stage, all cells managed, wall boundaries, no live 1D exchanges. Does not activate authored ownership. | |
| void | setJointSourceStage (SimulationContext &ctx, CommonSourceStage &stage, Router &hydraulic) |
| Internal water-only joint DW/source checkpoint, including non-outfall surface exchange and pending node delivery. Attach after both routers and LID initialization; the hydraulic router must track accepted steps. External providers, node beds and whole-engine/output state remain excluded. | |
| void | setSourceResultHistory (SourceResultHistory &history) |
| Attach a fresh borrowed accepted-source history recorder through the CPU source marcher. | |
| void | resumeSourceResultHistory (SourceResultHistory &history) |
| Resume a saved accepted-source recorder prefix at a completed router boundary. | |
| std::string | saveCheckpoint (const SimulationContext &ctx, const std::string &path) const |
| Internal router/CPU/source boundary; not a full-project hotstart. | |
| std::string | loadCheckpoint (SimulationContext &ctx, const std::string &path) |
| Read and stage a router component checkpoint into fresh matching attached owners. | |
| void | step (SimulationContext &ctx, double dt, double t) |
| Advance the 2D surface routing by one SWMM routing step. | |
| void | updateOutfallsPreRouting (SimulationContext &ctx, double dt=0.0) |
| Pre-routing hook: update outfall boundaries from 2D surface heads. | |
| void | advancePostRouting (SimulationContext &ctx, double dt, double t) |
| Post-routing hook: compute coupling exchange and advance 2D solver. | |
| void | prepareOneShotForcing (SimulationContext &ctx) |
| Prepare a RESET 2D forcing to apply on the next routing step. | |
| void | flushPendingBatch (SimulationContext &ctx) |
| Flush the pending (partial) sync batch, if any. | |
| double | reportWeight (double report_ms) const noexcept |
| Report-time interpolation weight for the 2D snapshot blend: f = (report_ms − window_old_ms)/(window_new_ms − window_old_ms), clamped to [0,1]; returns 1.0 (pure current state) when no batch has crossed a report instant yet. Unlike the 1D weight there is no legacy bit pattern to reproduce, so the clamp simply absorbs ulp-level clock skew between the router's and the engine's ms accumulators. | |
| void | bookGageRates (const SimulationContext &ctx, double runoff_start_s) |
Book the gage rates a runoff step starting at runoff_start_s (seconds since the run start) takes, after the monthly adjustment. The 2D integrates these piecewise-constant rates over each of its own windows, so a cell receives exactly the gage depth the subcatchments do over the same interval. | |
| void | reportRainfall (const SimulationContext &ctx, double report_date, std::vector< double > &out) const |
Per-cell rainfall (m/s) as the .out reports subcatchment rainfall: the source gage rate at report_date, independent of runoff cursor, mapped through RAINFALL_MODE, with the per-cell rainfall forcings applied. | |
| const std::vector< double > & | reportRainCumulative (double report_ms) const noexcept |
| Rainfall volume (m³) integrated to the report boundary, excluding the part of a routing/sync window after that boundary. Runtime totals remain available through rainCumulative(). | |
| const std::vector< double > & | reportOldDepth () const noexcept |
| Cell depth (m) at the start of the sync batch that crossed the current report instant (meaningful when reportWeight() < 1). | |
| const std::vector< double > & | reportOldHead () const noexcept |
| Cell head (m) at the start of that batch. | |
| void | finalize (SimulationContext &ctx) |
| Finalize the 2D module at simulation end. | |
| bool | isActive () const noexcept |
| Check if the 2D module is active. | |
| void | prepareLidStep (SimulationContext &, double dt, double evaporation) |
| Prepare the next finite Richards LID/mesh acceptance and conduit donor budgets. | |
| const std::vector< std::string > & | threadWarnings () const noexcept |
| Thread-count advisories produced by initialize() (THREADS above the machine limits, triangle gate reducing an explicit request). The engine forwards them to the report warnings and the host warning callback. | |
| void | computeCouplingConductances (const SimulationContext &ctx, std::vector< std::pair< int, double > > &out) const |
Windowless-coupling stabilizer: per coupled node, the exchange head sensitivity G = Σ_points −∂Q/∂h_1d ≥ 0 converted to 1D units (ft³/s per ft), for the caller to add into the dynamic-wave sumdqdh each Picard iteration. Appends (node_idx, G) pairs; cheap (O(points)). | |
| void | prepareForEdit () |
| Make the parsed mesh editable without a full initialize(). | |
| const MeshData & | mesh () const noexcept |
| Access mesh data (read-only). | |
| MeshData & | mesh () noexcept |
| Access mesh data (mutable, for input parsing). | |
| const SurfaceStateData & | state () const noexcept |
| Access surface state (read-only). | |
| SurfaceStateData & | state () noexcept |
| Access surface state (mutable, for forcing). | |
| double | surfaceReactionLoss (int row) const noexcept |
| Signed native surface reaction loss for the qualified RK2 owner. | |
| const SolverOptions2D & | options () const noexcept |
| Access solver options (read-only). | |
| SolverOptions2D & | options () noexcept |
| Access solver options (mutable). | |
| const BoundaryData & | boundary () const noexcept |
| Access per-edge boundary-condition data (read-only). | |
| BoundaryData & | boundary () noexcept |
| Access per-edge boundary-condition data (mutable, for forcing/parsing). | |
| bool | runtimeCpuAvailable () const noexcept |
| Announce that a boundary slot's TYPE changed (the API BC-type setter), so the compact non-WALL slot list the per-step boundary passes walk is rebuilt before it is next used. | |
| RuntimeSources & | runtimeSources () noexcept |
| Borrow mutable runtime prescriptions/receipts for the surface owner. | |
| bool | commonSourceAttached () const noexcept |
| Test whether an external common-source stage pointer is attached. | |
| const CommonSourceStage * | commonSourceStage () const noexcept |
| Borrow the externally attached common-source stage, if any. | |
| bool | runtimeWaterCheckpointing () const noexcept |
| Test qualification ownership for managed runtime water checkpointing. | |
| bool | runtimeBoundaryCheckpointing () const noexcept |
| Test whether the attached common source owns runtime boundary checkpointing. | |
| bool | outfallTailwaterCheckpointing () const noexcept |
| Joint checkpoints of a model with coupled outfalls carry each one's tailwater record — a distinct checkpoint version. | |
| const OutfallExchange & | outfallExchange () const noexcept |
| Coupled-outfall delivery and tailwater records (report). | |
| std::string | validateRuntimeWater (const RuntimeSources &, const RuntimeSources &, const RuntimeForcings &, double time, const BoundaryData *boundary=nullptr) const |
| Validate copied runtime water proposals through the attached common-source owner. | |
| bool | runtimeActive () const noexcept |
| Test whether any runtime surface/aquifer source, boundary override or forcing is retained. | |
| double | nextRuntimeTime (double now) const noexcept |
| Read the earliest scheduled source/forcing transition after a given time. | |
| void | expireRuntime (double now) |
| Retire all runtime source and forcing entries at an accepted completed horizon. | |
| void | invalidateBoundaryIndex () |
| Mark the compact non-wall boundary index stale and refresh attached CPU boundary work lists. | |
| void | invalidateBoundaryNames () noexcept |
| Mark symbolic boundary names unresolved after authoring/name changes. | |
| void | refreshRenderFieldsIfStale () |
| Bring the render fields (face velocity, vertex heads, output gradients, vertex render depths) up to date with the current solver state if a batch has run since they were last computed. The API getters that expose those fields call this so a reader arriving between reports is never served a stale field; it is a no-op at a report instant, where the refresh already ran. | |
| Infil2D & | infil () noexcept |
| Access the per-cell infiltration model (plan §5.5, track I). | |
| const Infil2D & | infil () const noexcept |
| Borrow the owned per-cell infiltration authoring, held capacity and model memory. | |
| GwTransportData & | gwTransport () noexcept |
U4 (2026-09-07): the [GW_*] subsurface-transport authoring rows. Reached by the parser, the writer and the C API through SimulationContext::twod_io.gw; resolved owners consume them during initialization. | |
| const GwTransportData & | gwTransport () const noexcept |
| Borrow the owned groundwater quality/thermal/source authoring and resolved SI transport metadata. | |
| SurfaceQuality2D & | surfaceQuality () noexcept |
| S7: cell coverages / buildup / washoff / sweeping (authoring + state). | |
| const SurfaceQuality2D & | surfaceQuality () const noexcept |
| Borrow the owned land-use coverage/buildup/washoff/sweeping authoring and runtime ledgers. | |
| SubsurfaceConfig & | aquiferConfig () noexcept |
G1: the authored [2D_AQUIFER*] rows, in the user's own units. Reached by the section handlers and the InpWriter through SimulationContext::twod_io.aquifer. | |
| const SubsurfaceConfig & | aquiferConfig () const noexcept |
| Borrow the owned aquifer authoring rows, retained in project input units. | |
| std::vector< std::string > & | aquiferNodeNames () noexcept |
| Borrow the owned node names parallel to aquiferConfig().node_beds authoring identity. | |
| const std::vector< std::string > & | aquiferNodeNames () const noexcept |
| Borrow the owned node names parallel to aquiferConfig().node_beds authoring identity. | |
| std::vector< std::string > & | aquiferLinkNames () noexcept |
G-X4: the [2D_AQUIFER_LINKS] row names, parallel to aquiferConfig().link_rows — the writer's round-trip key. | |
| const std::vector< std::string > & | aquiferLinkNames () const noexcept |
| Borrow the owned conduit names parallel to aquiferConfig().link_rows authoring identity. | |
| SubsurfaceSolver & | subsurface () noexcept |
The running kernel. active() is false until [2D_AQUIFER] resolves. | |
| const SubsurfaceSolver & | subsurface () const noexcept |
| Borrow the owned groundwater solver with SI hydraulic state, native rows and paired physical/source/LID receipts. | |
| const std::vector< double > & | subcatchRecharge () const noexcept |
| Ledger-consistent cumulative infiltrated depth per cell (m). | |
| void | drainSubcatchRecharge (std::vector< double > &out) |
Move the pending recharge into out (m³ per subcatchment) and zero the accumulator. out is sized to the accumulator (empty when the destination is not in use). | |
| const std::vector< int > & | cellSubcatchment () const noexcept |
| Cell → containing subcatchment index (-1 = none). Empty unless the SUBCATCH_AQUIFER destination resolved. | |
| double | infiltrationElapsed () const noexcept |
| Read elapsed duration since the last held infiltration model rate refresh. | |
| void | restoreInfiltration (const std::vector< double > &cumulative, double elapsed) |
| Replace router applied-infiltration reporting and held-model elapsed accounting. | |
| const std::vector< double > & | infilCumulative () const noexcept |
| Borrow actually applied cumulative infiltration depth. | |
| const std::vector< double > & | couplingCumulative () const noexcept |
| Signed cumulative coupling exchange per cell (m³). | |
| const std::vector< double > & | rainCumulative () const noexcept |
| Ledger-consistent cumulative rainfall volume per cell (m³). | |
| const RainfallInterpolator & | rainfallInterpolator () const noexcept |
| Static rainfall weights built at initialize() (diagnostic inspection). | |
| std::vector< PendingInitialQualityRow > & | pendingInitialQualityRows () noexcept |
| S1/S2: raw [2D_INITIAL_QUALITY] rows, resolved at initialize(). | |
| std::vector< PendingInitialBedQualityRow > & | pendingInitialBedQualityRows () noexcept |
| Borrow retained local-bed initial native quality authoring rows. | |
| std::vector< PendingBoundaryQualityRow > & | pendingBoundaryQualityRows () noexcept |
| Borrow retained boundary native quality authoring rows. | |
| std::vector< PendingBoundaryRow > & | pendingBCRows () noexcept |
| Borrow retained hydraulic boundary authoring rows. | |
| const std::vector< PendingBoundaryRow > & | pendingBCRows () const noexcept |
| Borrow retained hydraulic boundary authoring rows. | |
| std::vector< PendingEdgeConveyanceRow > & | pendingEdgeConveyanceRows () noexcept |
| Borrow retained interior/exterior edge conveyance authoring rows. | |
| const std::vector< PendingEdgeConveyanceRow > & | pendingEdgeConveyanceRows () const noexcept |
| Borrow retained interior/exterior edge conveyance authoring rows. | |
| double | totalVolume () const |
| Get total 2D surface volume (sum of depth * area). | |
| double | totalExchangeFlow () const |
| Get total exchange flow (sum of coupling flows, m³/s). | |
| long | lastSolverSteps () const |
| Read the last surface advance's base substep count. | |
| double | lastSolverStepSize () const |
| Read the last accepted surface base/tail step duration. | |
| const std::string & | backendName () const noexcept |
| Backend label chosen by SurfaceSolverFactory at initialize() ("cpu (explicit
marcher)", "omp (…)", …); empty before that. | |
Friends | |
| class | openswmm::SWMMEngine |
Top-level orchestrator for the 2D surface routing module.
Per-row buffer for [2D_BOUNDARY_CONDITIONS] parse output.
V-E3. Populated by the input parser during reading (before the mesh is finalized), drained into boundary_ during initialize() after boundary_.resize() allocates the per-edge slots. Retained after the drain so serialization (InpWriter / GeoPackage) can re-emit the authored rows (group label, TS-vs-constant choice). Hoisted to data/PendingRows2D.hpp; alias kept for call sites.
Per-row buffer for [2D_EDGE_CONVEYANCE] parse output (§11A).
Populated by the input parser during reading (vertices known but mesh topology not yet built), drained into mesh_.edge_conveyance during initialize() after buildMeshTopology has populated the neighbour table. Mirrored to both slots of an interior edge so antisymmetric FV flux integration stays mass-conservative. Retained after the drain for faithful re-serialization.
| using openswmm::twoD::SurfaceRouter2D::PendingInitialBedQualityRow = twoD::PendingInitialBedQualityRow |
|
default |
Create an inactive authoring router with empty owned physical/source state.
|
default |
Destroy owned router members and release solver/plugin resources.
|
delete |
|
default |
Move owned router members using their ordinary default move operations.
| void openswmm::twoD::SurfaceRouter2D::advancePostRouting | ( | SimulationContext & | ctx, |
| double | routing_dt, | ||
| double | t ) |
Post-routing hook: compute coupling exchange and advance 2D solver.
Consume accepted hydraulic exchange and schedule or execute the pending 2D batch.
Must be called AFTER the 1D routing step.
Consume accepted hydraulic exchange and schedule or execute the pending 2D batch.
| [in,out] | ctx | Matching accepted native hydraulic/quality state after its routing solve. |
| [in] | routing_dt | Positive finite accepted routing duration s, called dt in the declaration. |
| [in] | t | Elapsed accepted interval start s, matching sim_time_+pending_dt_ for common sources. |
|
inlinenoexcept |
Borrow the owned aquifer authoring rows, retained in project input units.
|
inlinenoexcept |
G1: the authored [2D_AQUIFER*] rows, in the user's own units. Reached by the section handlers and the InpWriter through SimulationContext::twod_io.aquifer.
Borrow the owned aquifer authoring rows, retained in project input units.
|
inlinenoexcept |
Borrow the owned conduit names parallel to aquiferConfig().link_rows authoring identity.
|
inlinenoexcept |
G-X4: the [2D_AQUIFER_LINKS] row names, parallel to aquiferConfig().link_rows — the writer's round-trip key.
Borrow the owned conduit names parallel to aquiferConfig().link_rows authoring identity.
|
inlinenoexcept |
Borrow the owned node names parallel to aquiferConfig().node_beds authoring identity.
|
inlinenoexcept |
Borrow the owned node names parallel to aquiferConfig().node_beds authoring identity.
|
inlinenoexcept |
Backend label chosen by SurfaceSolverFactory at initialize() ("cpu (explicit marcher)", "omp (…)", …); empty before that.
Borrow selected surface solver backend label.
| void openswmm::twoD::SurfaceRouter2D::bookGageRates | ( | const SimulationContext & | ctx, |
| double | runoff_start_s ) |
Book the gage rates a runoff step starting at runoff_start_s (seconds since the run start) takes, after the monthly adjustment. The 2D integrates these piecewise-constant rates over each of its own windows, so a cell receives exactly the gage depth the subcatchments do over the same interval.
| [in] | ctx | Matching post-monthly-adjustment native gage rainfall vector, extent>=n_gages. |
| [in] | runoff_start_s | Finite nondecreasing elapsed runoff interval start s. |
|
inlinenoexcept |
Access per-edge boundary-condition data (read-only).
Borrow the owned per-edge boundary descriptors/forcing/receipts, indexed by MeshData::slot.
|
inlinenoexcept |
Access per-edge boundary-condition data (mutable, for forcing/parsing).
Borrow the owned per-edge boundary descriptors/forcing/receipts, indexed by MeshData::slot.
|
inlinenoexcept |
Cell → containing subcatchment index (-1 = none). Empty unless the SUBCATCH_AQUIFER destination resolved.
Borrow resolved recharge destination lookup.
|
inlinenoexcept |
Borrow the shared finite channel/physical-soil thermal contact owner and cumulative J/native receipts.
|
inlinenoexcept |
Borrow the shared finite channel/physical-soil thermal contact owner and cumulative J/native receipts.
|
inlinenoexcept |
Test whether an external common-source stage pointer is attached.
|
inlinenoexcept |
Borrow the externally attached common-source stage, if any.
| void openswmm::twoD::SurfaceRouter2D::computeCouplingConductances | ( | const SimulationContext & | ctx, |
| std::vector< std::pair< int, double > > & | out ) const |
Windowless-coupling stabilizer: per coupled node, the exchange head sensitivity G = Σ_points −∂Q/∂h_1d ≥ 0 converted to 1D units (ft³/s per ft), for the caller to add into the dynamic-wave sumdqdh each Picard iteration. Appends (node_idx, G) pairs; cheap (O(points)).
Append positive live non-outfall coupling head derivatives in native hydraulic units.
Append positive live non-outfall coupling head derivatives in native hydraulic units.
| [in] | ctx | Matching live native node heads/depths and prepared coupling model. |
| [in,out] | out | Existing vector retained; appends (zero-based node index,G) per positive point, where G is ft3/s per ft of native 1D head. Entries for shared nodes are not aggregated here. |
|
inlinenoexcept |
Signed cumulative coupling exchange per cell (m³).
Positive = water the 1D node delivered INTO this cell (spill, submerged-outfall discharge); negative = water the node abstracted FROM it (drain). Summing the vector gives coupling_1d_to_2d_in − coupling_2d_to_1d_out, which is the check that ties this series to the domain totals.
Borrow signed accepted cumulative native-node/surface exchange.
|
inline |
Move the pending recharge into out (m³ per subcatchment) and zero the accumulator. out is sized to the accumulator (empty when the destination is not in use).
| [out] | out | Replaced by pending SI m3 per original subcatchment, then the owned accumulator is zeroed. Must not alias subcatch_recharge_ itself. Empty destination mapping yields empty output. |
|
inline |
Retire all runtime source and forcing entries at an accepted completed horizon.
| [in] | now | Finite elapsed completed time s used by each owner expire() policy. |
| void openswmm::twoD::SurfaceRouter2D::finalize | ( | SimulationContext & | ctx | ) |
Finalize the 2D module at simulation end.
Flushes any partial macro-step window (routing time accumulated since the last 2D advance) so the 2D clock ends at the simulation end instead of up to one window short, then releases the solver.
| [in,out] | ctx | Matching live context for pending physics, solver statistics and warning receipts. |
| void openswmm::twoD::SurfaceRouter2D::flushPendingBatch | ( | SimulationContext & | ctx | ) |
Flush the pending (partial) sync batch, if any.
Closes the accumulated routing span with one co-advance so the 2D clock reaches the current routing time. A no-op under default per-routing-step coupling (the batch closes every step). Used before a report snapshot — so the report-time blend brackets the report instant — and before a one-shot forcing.
| [in,out] | ctx | Matching live context; common-source mode requires the exact attached identity and a completed ready source boundary. |
|
inlinenoexcept |
Borrow the owned groundwater quality/thermal/source authoring and resolved SI transport metadata.
|
inlinenoexcept |
U4 (2026-09-07): the [GW_*] subsurface-transport authoring rows. Reached by the parser, the writer and the C API through SimulationContext::twod_io.gw; resolved owners consume them during initialization.
Borrow the owned groundwater quality/thermal/source authoring and resolved SI transport metadata.
|
inlinenoexcept |
Borrow the owned per-cell infiltration authoring, held capacity and model memory.
|
inlinenoexcept |
Access the per-cell infiltration model (plan §5.5, track I).
Mutable so SWMMEngine can publish it on ctx.twod_io.infil — the [2D_INFILTRATION*] section handlers and the InpWriter reach it there. The router owns the object, resolves it against the mesh in initialize(), and drives its INFIL_STEP cadence in coAdvanceStep().
Borrow the owned per-cell infiltration authoring, held capacity and model memory.
|
inlinenoexcept |
Borrow actually applied cumulative infiltration depth.
|
inlinenoexcept |
Read elapsed duration since the last held infiltration model rate refresh.
| void openswmm::twoD::SurfaceRouter2D::initialize | ( | SimulationContext & | ctx | ) |
Initialize the 2D module after input parsing is complete.
Prepare authored mesh, coupling, physical source owners and selected solver for a new run.
Builds mesh topology, vertex stencils, resolves coupling names, and initializes the explicit 2D solver.
Prepare authored mesh, coupling, physical source owners and selected solver for a new run.
| [in,out] | ctx | Fully parsed matching engine context with prepared node/link/gage/tables, quality/reaction/heat configuration; borrowed context/node/thermal views must outlive routing. |
Seeds initial water/native/bed storage, source rate capacities, report/render fields and water ledgers. May alter options from environment, coupling/pond/exfiltration ownership in ctx, quality queues and warnings. Does not advance the engine calendar. Channel contacts are separately bound after 1D heat initialization. Profile/name/layout/ownership errors throw std::runtime_error; allocation and delegated validation can throw after partial setup. This is not a transactional reinitialization or a safe way to preserve an evolved model's inventories.
| void openswmm::twoD::SurfaceRouter2D::initializeChannelGround | ( | SimulationContext & | ctx | ) |
Bind selected finite channel contacts after 1D heat state is seeded.
Resolve requested finite conduit/physical-ground contacts after native 1D heat initialization.
Resolve requested finite conduit/physical-ground contacts after native 1D heat initialization.
| [in,out] | ctx | Matching prepared heat/node/link context; retained thermal views must stay alive. |
| void openswmm::twoD::SurfaceRouter2D::invalidateBoundaryIndex | ( | ) |
Mark the compact non-wall boundary index stale and refresh attached CPU boundary work lists.
|
inlinenoexcept |
Mark symbolic boundary names unresolved after authoring/name changes.
|
inlinenoexcept |
Check if the 2D module is active.
|
inline |
Read the last surface advance's base substep count.
|
inline |
Read the last accepted surface base/tail step duration.
| std::string openswmm::twoD::SurfaceRouter2D::loadCheckpoint | ( | SimulationContext & | ctx, |
| const std::string & | path ) |
Read and stage a router component checkpoint into fresh matching attached owners.
| [in,out] | ctx | Exact fresh attached context; successful install updates checkpointed clocks, gage rainfall/evaporation, mass balance and qualified native/source owners. |
| [in] | path | Readable nonempty bounded checkpoint file. |
|
inlinenoexcept |
Access mesh data (read-only).
Borrow the owned mesh geometry/topology; runtime coordinates are SI after initialization, authoring may precede conversion.
|
inlinenoexcept |
Access mesh data (mutable, for input parsing).
Borrow the owned mesh geometry/topology; runtime coordinates are SI after initialization, authoring may precede conversion.
|
inlinenoexcept |
Read the earliest scheduled source/forcing transition after a given time.
| [in] | now | Finite elapsed time s, in the same origin as runtime source/forcing windows. |
|
delete |
|
default |
Replace owned router members by default move assignment.
|
inlinenoexcept |
Access solver options (read-only).
Borrow the owned resolved surface solver controls, SI for runtime geometry/rates.
|
inlinenoexcept |
Access solver options (mutable).
Borrow the owned resolved surface solver controls, SI for runtime geometry/rates.
|
inlinenoexcept |
Coupled-outfall delivery and tailwater records (report).
Borrow coupled outfall reservations, accepted receipts and tailwater diagnostics.
|
inlinenoexcept |
Joint checkpoints of a model with coupled outfalls carry each one's tailwater record — a distinct checkpoint version.
|
inlinenoexcept |
Borrow retained hydraulic boundary authoring rows.
|
inlinenoexcept |
Borrow retained hydraulic boundary authoring rows.
|
inlinenoexcept |
Borrow retained boundary native quality authoring rows.
|
inlinenoexcept |
Borrow retained interior/exterior edge conveyance authoring rows.
|
inlinenoexcept |
Borrow retained interior/exterior edge conveyance authoring rows.
|
inlinenoexcept |
Borrow retained local-bed initial native quality authoring rows.
|
inlinenoexcept |
S1/S2: raw [2D_INITIAL_QUALITY] rows, resolved at initialize().
Borrow retained surface initial native quality authoring rows.
| void openswmm::twoD::SurfaceRouter2D::prepareForEdit | ( | ) |
Make the parsed mesh editable without a full initialize().
The GUI keeps the engine in OPENED (not INITIALIZED) state so 1D property edits stay legal. In that state the 2D mesh is parsed but the [2D_BOUNDARY_CONDITIONS] / [2D_EDGE_CONVEYANCE] rows still live in the pending-row buffers, which the serializer prefers over live state. This drains those rows into BoundaryData / mesh edge slots (the same drain initialize() performs) so per-edge API edits take effect and are written on save. No-op once drained or when no mesh is loaded.
| void openswmm::twoD::SurfaceRouter2D::prepareLidStep | ( | SimulationContext & | ctx, |
| double | dt, | ||
| double | evaporation ) |
Prepare the next finite Richards LID/mesh acceptance and conduit donor budgets.
Prepare finite Richards LID/mesh acceptance for the next hydraulic interval.
| [in,out] | ctx | Matching prepared native LID/hydraulic context, borrowed for the operation. |
| [in] | dt | Positive finite interval duration s required by the admission owner. |
| [in] | evaporation | Held native evaporation input passed to prepareMeshRichardsStep. |
| void openswmm::twoD::SurfaceRouter2D::prepareOneShotForcing | ( | SimulationContext & | ctx | ) |
Prepare a RESET 2D forcing to apply on the next routing step.
Flushes any already accumulated macro-window before the new one-shot is recorded, then forces the next routing step to fire a 2D advance so the prescription applies to future time only and is cleared after use.
| [in,out] | ctx | Matching active context used to close old pending time before caller edits forcing. |
|
inlinenoexcept |
Ledger-consistent cumulative rainfall volume per cell (m³).
Booked in accumulateMassBalance() from the SAME per-cell rainfall term that feeds MassBalance2D::rainfall_in, so sum(rainCumulative()[i]) == rainfall_in holds by construction. Sized [n_triangles] from initialize(); zero-filled when no rain.
Borrow accepted cumulative rainfall source volume.
|
inlinenoexcept |
Static rainfall weights built at initialize() (diagnostic inspection).
Borrow prepared static gage-to-cell weights and mapping.
|
inline |
Bring the render fields (face velocity, vertex heads, output gradients, vertex render depths) up to date with the current solver state if a batch has run since they were last computed. The API getters that expose those fields call this so a reader arriving between reports is never served a stale field; it is a no-op at a report instant, where the refresh already ran.
|
inlinenoexcept |
Cell depth (m) at the start of the sync batch that crossed the current report instant (meaningful when reportWeight() < 1).
Borrow surface depth at the old side of the last report-crossing sync batch.
|
inlinenoexcept |
Cell head (m) at the start of that batch.
Borrow surface head at the old side of the last report-crossing sync batch.
|
inlinenoexcept |
Rainfall volume (m³) integrated to the report boundary, excluding the part of a routing/sync window after that boundary. Runtime totals remain available through rainCumulative().
| [in] | report_ms | Requested engine report boundary in elapsed milliseconds; compared exactly to stored report_rain_ms_, without tolerance or finite-value checks. |
| void openswmm::twoD::SurfaceRouter2D::reportRainfall | ( | const SimulationContext & | ctx, |
| double | report_date, | ||
| std::vector< double > & | out ) const |
Per-cell rainfall (m/s) as the .out reports subcatchment rainfall: the source gage rate at report_date, independent of runoff cursor, mapped through RAINFALL_MODE, with the per-cell rainfall forcings applied.
| [in] | ctx | Prepared matching gage/time-series/report-unit configuration. |
| [in] | report_date | Absolute engine DateTime days, not elapsed seconds. |
| [out] | out | Resized per-cell rainfall m/s, mapped by rainfall policy then composed with current per-cell replace/add forcing arrays; previous contents replaced. |
|
noexcept |
Report-time interpolation weight for the 2D snapshot blend: f = (report_ms − window_old_ms)/(window_new_ms − window_old_ms), clamped to [0,1]; returns 1.0 (pure current state) when no batch has crossed a report instant yet. Unlike the 1D weight there is no legacy bit pattern to reproduce, so the clamp simply absorbs ulp-level clock skew between the router's and the engine's ms accumulators.
| [in] | report_ms | Requested elapsed report time in ms, normally finite. |
|
inline |
Replace router applied-infiltration reporting and held-model elapsed accounting.
| [in] | cumulative | Matching per-cell actually applied depth m, copied verbatim with no shape, sign or finite-value validation. |
| [in] | elapsed | Finite nonnegative held-rate elapsed duration s, assigned without validation. |
| void openswmm::twoD::SurfaceRouter2D::resumeSourceResultHistory | ( | SourceResultHistory & | history | ) |
Resume a saved accepted-source recorder prefix at a completed router boundary.
| [in,out] | history | Compatible borrowed saved recorder prefix with exact checkpoint match; must remain stable/alive through recording. |
|
inlinenoexcept |
Test whether any runtime surface/aquifer source, boundary override or forcing is retained.
|
noexcept |
Test whether the attached common source owns runtime boundary checkpointing.
|
noexcept |
Announce that a boundary slot's TYPE changed (the API BC-type setter), so the compact non-WALL slot list the per-step boundary passes walk is rebuilt before it is next used.
Test active CPU support for the runtime prescription API route.
Test active CPU support for the runtime prescription API route.
|
inlinenoexcept |
Borrow mutable runtime prescriptions/receipts for the surface owner.
|
noexcept |
Test qualification ownership for managed runtime water checkpointing.
| std::string openswmm::twoD::SurfaceRouter2D::saveCheckpoint | ( | const SimulationContext & | ctx, |
| const std::string & | path ) const |
Internal router/CPU/source boundary; not a full-project hotstart.
Serialize and publish a qualified source/router or joint component boundary.
Serialize and publish a qualified source/router or joint component boundary.
| [in] | ctx | Exact attached context, held stable/exclusive through qualification/serialization. |
| [in] | path | Writable destination with existing parent; existing record must match profile magic. |
| void openswmm::twoD::SurfaceRouter2D::setCommonSourceStage | ( | SimulationContext & | ctx, |
| CommonSourceStage & | stage ) |
Internal qualification hook: externally owned stage, all cells managed, wall boundaries, no live 1D exchanges. Does not activate authored ownership.
Attach a borrowed all-cell source stage to a fresh first-order CPU router.
Attach a borrowed all-cell source stage to a fresh first-order CPU router.
| [in,out] | ctx | Exact matching initial context without live network coupling. |
| [in,out] | stage | Prepared matching mesh/surface/subsurface owner spanning all cells; borrowed for later routing/checkpoint and must outlive attachment with stable identities. |
| void openswmm::twoD::SurfaceRouter2D::setJointSourceStage | ( | SimulationContext & | ctx, |
| CommonSourceStage & | stage, | ||
| Router & | hydraulic ) |
Internal water-only joint DW/source checkpoint, including non-outfall surface exchange and pending node delivery. Attach after both routers and LID initialization; the hydraulic router must track accepted steps. External providers, node beds and whole-engine/output state remain excluded.
Attach matching first-order source and tracked native hydraulic owners for joint checkpoints.
Attach matching first-order source and tracked native hydraulic owners for joint checkpoints.
| [in,out] | ctx | Exact prepared initial context shared by both routers and LID setup. |
| [in,out] | stage | Borrowed matching all-cell common-source stage, stable/alive through routing. |
| [in,out] | hydraulic | Borrowed initialized tracked hydraulic owner sharing ctx; must remain alive. |
| void openswmm::twoD::SurfaceRouter2D::setSourceResultHistory | ( | SourceResultHistory & | history | ) |
Attach a fresh borrowed accepted-source history recorder through the CPU source marcher.
| [in,out] | history | Prepared compatible recorder; borrowed and must outlive attachment/use. |
|
inlinenoexcept |
Access surface state (read-only).
Borrow the owned canonical surface water/native/thermal state and pending producer receipts.
|
inlinenoexcept |
Access surface state (mutable, for forcing).
Borrow the owned canonical surface water/native/thermal state and pending producer receipts.
| void openswmm::twoD::SurfaceRouter2D::step | ( | SimulationContext & | ctx, |
| double | dt, | ||
| double | t ) |
Advance the 2D surface routing by one SWMM routing step.
Invoke the pre-outfall and post-routing surface hooks consecutively.
Sequence:
Invoke the pre-outfall and post-routing surface hooks consecutively.
| [in,out] | ctx | Matching prepared engine context with accepted hydraulic state for post-routing. |
| [in] | dt | Positive finite routing duration s expected by prepared exchange owners. |
| [in] | t | Elapsed routing interval start s, matching completed/pending source clock. |
|
inlinenoexcept |
Ledger-consistent cumulative infiltrated depth per cell (m).
Drains the SAME SurfaceStateData::infil_applied accumulator that MassBalance2D::infil_out books — the depth the marcher actually removed, summed as it was removed — so sum(infilCumulative()[i] * tri_area[i]) == infil_out holds by construction. Prefer this over Infil2D::cumulative(), which is the unramped capacity the kernels offered and therefore exceeds the applied loss on drying cells. Empty when no [2D_INFILTRATION*] model resolved.
U3 (track I-b) — per-subcatchment 2D infiltration recharge pending delivery to the legacy aquifer, in m³.
Filled in accumulateMassBalance() for every cell whose resolved row says SUBCATCH_AQUIFER and that a subcatchment contains. drainSubcatchRecharge() hands it to the runoff step (which adds it to that subcatchment's infiltration rate for GWSolver::execute) and zeroes it, so the accumulator is drained exactly once per runoff step. Empty when the destination is not in use.
Borrow unconsumed infiltration recharge awaiting legacy subcatchment delivery.
|
inlinenoexcept |
Borrow the owned groundwater solver with SI hydraulic state, native rows and paired physical/source/LID receipts.
|
inlinenoexcept |
The running kernel. active() is false until [2D_AQUIFER] resolves.
Borrow the owned groundwater solver with SI hydraulic state, native rows and paired physical/source/LID receipts.
|
inlinenoexcept |
Borrow the owned land-use coverage/buildup/washoff/sweeping authoring and runtime ledgers.
|
inlinenoexcept |
S7: cell coverages / buildup / washoff / sweeping (authoring + state).
Borrow the owned land-use coverage/buildup/washoff/sweeping authoring and runtime ledgers.
|
noexcept |
Signed native surface reaction loss for the qualified RK2 owner.
Read a CPU RK2 surface native reaction loss without consuming its receipt.
Read a CPU RK2 surface native reaction loss without consuming its receipt.
| [in] | row | Zero-based canonical native row; invalid rows return zero through CPU owner. |
|
inlinenoexcept |
Thread-count advisories produced by initialize() (THREADS above the machine limits, triangle gate reducing an explicit request). The engine forwards them to the report warnings and the host warning callback.
Borrow initialization thread-count advisories.
| double openswmm::twoD::SurfaceRouter2D::totalExchangeFlow | ( | ) | const |
Get total exchange flow (sum of coupling flows, m³/s).
Sum the current held surface coupling source-rate field over cell areas.
Sum the current held surface coupling source-rate field over cell areas.
| double openswmm::twoD::SurfaceRouter2D::totalVolume | ( | ) | const |
Get total 2D surface volume (sum of depth * area).
Sum canonical surface water volume over all prepared mesh cells.
Sum canonical surface water volume over all prepared mesh cells.
| void openswmm::twoD::SurfaceRouter2D::updateOutfallsPreRouting | ( | SimulationContext & | ctx, |
| double | dt = 0.0 ) |
Pre-routing hook: update outfall boundaries from 2D surface heads.
Freeze outfall tailwater and donor reservations before the matching 1D routing solve.
Must be called BEFORE the 1D routing step, after setOutfallDepths().
Freeze outfall tailwater and donor reservations before the matching 1D routing solve.
| [in,out] | ctx | Matching live node/hydraulic state, with native outfall depth setup completed. |
| [in] | dt | Routing interval duration s; default zero supplies no positive donor interval and cannot qualify a live joint-outfall tracked interval. |
| std::string openswmm::twoD::SurfaceRouter2D::validateRuntimeWater | ( | const RuntimeSources & | surface, |
| const RuntimeSources & | groundwater, | ||
| const RuntimeForcings & | forcing, | ||
| double | time, | ||
| const BoundaryData * | boundary = nullptr ) const |
Validate copied runtime water proposals through the attached common-source owner.
Ask an attached common-source owner to admit proposed copied runtime water prescriptions.
| [in] | surface | Proposed immutable surface runtime rows and receipts. |
| [in] | groundwater | Proposed groundwater runtime rows and receipts. |
| [in] | forcing | Proposed held forcing rows and accepted rain receipts. |
| [in] | time | Finite elapsed proposed boundary s, matching the source owner's required phase. |
| [in] | boundary | Optional borrowed proposed boundary owner; required by active boundary profile. |
|
friend |