OpenSWMM Engine  6.0.0-alpha.3
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.3)
Loading...
Searching...
No Matches
openswmm::twoD::SurfaceRouter2D Class Reference

Top-level orchestrator for the 2D surface routing module. More...

#include <SurfaceRouter2D.hpp>

Collaboration diagram for openswmm::twoD::SurfaceRouter2D:

Public Types

using PendingBoundaryRow = twoD::PendingBoundaryRow
 Per-row buffer for [2D_BOUNDARY_CONDITIONS] parse output.
 
using PendingEdgeConveyanceRow = twoD::PendingEdgeConveyanceRow
 Per-row buffer for [2D_EDGE_CONVEYANCE] parse output (§11A).
 

Public Member Functions

 SurfaceRouter2D ()=default
 
 ~SurfaceRouter2D ()=default
 
 SurfaceRouter2D (const SurfaceRouter2D &)=delete
 
SurfaceRouter2Doperator= (const SurfaceRouter2D &)=delete
 
 SurfaceRouter2D (SurfaceRouter2D &&)=default
 
SurfaceRouter2Doperator= (SurfaceRouter2D &&)=default
 
void initialize (SimulationContext &ctx)
 Initialize the 2D module after input parsing is complete.
 
void step (SimulationContext &ctx, double dt, double t)
 Advance the 2D surface routing by one SWMM routing step.
 
void updateOutfallsPreRouting (SimulationContext &ctx)
 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 finalize (SimulationContext &ctx)
 Finalize the 2D module at simulation end.
 
double computeCflHint (const SimulationContext &ctx) const
 Compute a CFL-like stability hint for the 2D domain.
 
bool isActive () const noexcept
 Check if the 2D module is active.
 
void prepareForEdit ()
 Make the parsed mesh editable without a full initialize().
 
const MeshDatamesh () const noexcept
 Access mesh data (read-only).
 
MeshDatamesh () noexcept
 Access mesh data (mutable, for input parsing).
 
const SurfaceStateDatastate () const noexcept
 Access surface state (read-only).
 
SurfaceStateDatastate () noexcept
 Access surface state (mutable, for forcing).
 
const SolverOptions2Doptions () const noexcept
 Access solver options (read-only).
 
SolverOptions2Doptions () noexcept
 Access solver options (mutable).
 
const BoundaryDataboundary () const noexcept
 Access per-edge boundary-condition data (read-only).
 
BoundaryDataboundary () noexcept
 Access per-edge boundary-condition data (mutable, for forcing/parsing).
 
std::vector< PendingBoundaryRow > & pendingBCRows () noexcept
 
const std::vector< PendingBoundaryRow > & pendingBCRows () const noexcept
 
std::vector< PendingEdgeConveyanceRow > & pendingEdgeConveyanceRows () noexcept
 
const std::vector< PendingEdgeConveyanceRow > & pendingEdgeConveyanceRows () const noexcept
 
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 lastCvodeSteps () const
 
double lastCvodeStepSize () const
 

Detailed Description

Top-level orchestrator for the 2D surface routing module.

Member Typedef Documentation

◆ PendingBoundaryRow

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.

◆ PendingEdgeConveyanceRow

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.

Constructor & Destructor Documentation

◆ SurfaceRouter2D() [1/3]

openswmm::twoD::SurfaceRouter2D::SurfaceRouter2D ( )
default
Here is the caller graph for this function:

◆ ~SurfaceRouter2D()

openswmm::twoD::SurfaceRouter2D::~SurfaceRouter2D ( )
default

◆ SurfaceRouter2D() [2/3]

openswmm::twoD::SurfaceRouter2D::SurfaceRouter2D ( const SurfaceRouter2D & )
delete
Here is the call graph for this function:

◆ SurfaceRouter2D() [3/3]

openswmm::twoD::SurfaceRouter2D::SurfaceRouter2D ( SurfaceRouter2D && )
default
Here is the call graph for this function:

Member Function Documentation

◆ advancePostRouting()

void openswmm::twoD::SurfaceRouter2D::advancePostRouting ( SimulationContext & ctx,
double dt,
double t )

Post-routing hook: compute coupling exchange and advance 2D solver.

Must be called AFTER the 1D routing step.

Parameters
ctxSimulation context.
dtSWMM routing timestep (seconds).
tCurrent simulation time (seconds from start).
Here is the caller graph for this function:

◆ boundary() [1/2]

const BoundaryData & openswmm::twoD::SurfaceRouter2D::boundary ( ) const
inlinenoexcept

Access per-edge boundary-condition data (read-only).

◆ boundary() [2/2]

BoundaryData & openswmm::twoD::SurfaceRouter2D::boundary ( )
inlinenoexcept

Access per-edge boundary-condition data (mutable, for forcing/parsing).

◆ computeCflHint()

double openswmm::twoD::SurfaceRouter2D::computeCflHint ( const SimulationContext & ctx) const

Compute a CFL-like stability hint for the 2D domain.

Returns an advisory maximum dt based on mesh resolution and wave speeds. CVODE handles its own sub-stepping, but this prevents the coupling interval from being too large. Returns a value cached at the last 2D advance (the state cannot change between advances), so the per-routing- step call is O(1).

Parameters
ctxSimulation context.
Returns
Advisory maximum timestep (seconds).

◆ finalize()

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.

Parameters
ctxSimulation context (needed for the flush advance).

◆ initialize()

void openswmm::twoD::SurfaceRouter2D::initialize ( SimulationContext & ctx)

Initialize the 2D module after input parsing is complete.

Builds mesh topology, vertex stencils, resolves coupling names, and initializes the CVODE solver.

Parameters
ctxSimulation context (must have mesh_2d populated from parsing).
Here is the call graph for this function:

◆ isActive()

bool openswmm::twoD::SurfaceRouter2D::isActive ( ) const
inlinenoexcept

Check if the 2D module is active.

◆ lastCvodeSteps()

long openswmm::twoD::SurfaceRouter2D::lastCvodeSteps ( ) const
inline

◆ lastCvodeStepSize()

double openswmm::twoD::SurfaceRouter2D::lastCvodeStepSize ( ) const
inline

◆ mesh() [1/2]

const MeshData & openswmm::twoD::SurfaceRouter2D::mesh ( ) const
inlinenoexcept

Access mesh data (read-only).

◆ mesh() [2/2]

MeshData & openswmm::twoD::SurfaceRouter2D::mesh ( )
inlinenoexcept

Access mesh data (mutable, for input parsing).

◆ operator=() [1/2]

SurfaceRouter2D & openswmm::twoD::SurfaceRouter2D::operator= ( const SurfaceRouter2D & )
delete
Here is the call graph for this function:

◆ operator=() [2/2]

SurfaceRouter2D & openswmm::twoD::SurfaceRouter2D::operator= ( SurfaceRouter2D && )
default
Here is the call graph for this function:

◆ options() [1/2]

const SolverOptions2D & openswmm::twoD::SurfaceRouter2D::options ( ) const
inlinenoexcept

Access solver options (read-only).

◆ options() [2/2]

SolverOptions2D & openswmm::twoD::SurfaceRouter2D::options ( )
inlinenoexcept

Access solver options (mutable).

◆ pendingBCRows() [1/2]

const std::vector< PendingBoundaryRow > & openswmm::twoD::SurfaceRouter2D::pendingBCRows ( ) const
inlinenoexcept

◆ pendingBCRows() [2/2]

std::vector< PendingBoundaryRow > & openswmm::twoD::SurfaceRouter2D::pendingBCRows ( )
inlinenoexcept

◆ pendingEdgeConveyanceRows() [1/2]

const std::vector< PendingEdgeConveyanceRow > & openswmm::twoD::SurfaceRouter2D::pendingEdgeConveyanceRows ( ) const
inlinenoexcept

◆ pendingEdgeConveyanceRows() [2/2]

std::vector< PendingEdgeConveyanceRow > & openswmm::twoD::SurfaceRouter2D::pendingEdgeConveyanceRows ( )
inlinenoexcept

◆ prepareForEdit()

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.

◆ prepareOneShotForcing()

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.

◆ state() [1/2]

const SurfaceStateData & openswmm::twoD::SurfaceRouter2D::state ( ) const
inlinenoexcept

Access surface state (read-only).

◆ state() [2/2]

SurfaceStateData & openswmm::twoD::SurfaceRouter2D::state ( )
inlinenoexcept

Access surface state (mutable, for forcing).

◆ step()

void openswmm::twoD::SurfaceRouter2D::step ( SimulationContext & ctx,
double dt,
double t )

Advance the 2D surface routing by one SWMM routing step.

Sequence:

  1. Update outfall boundary heads from 2D state (before 1D routing)
  2. After 1D routing: compute coupling exchange flows
  3. Update 2D rainfall from system gages
  4. Advance CVODE by dt_swmm
  5. Transfer outfall discharges into 2D cells
  6. Update statistics
Parameters
ctxSimulation context.
dtSWMM routing timestep (seconds).
tCurrent simulation time (seconds from start).
Here is the call graph for this function:

◆ totalExchangeFlow()

double openswmm::twoD::SurfaceRouter2D::totalExchangeFlow ( ) const

Get total exchange flow (sum of coupling flows, m³/s).

◆ totalVolume()

double openswmm::twoD::SurfaceRouter2D::totalVolume ( ) const

Get total 2D surface volume (sum of depth * area).

Here is the caller graph for this function:

◆ updateOutfallsPreRouting()

void openswmm::twoD::SurfaceRouter2D::updateOutfallsPreRouting ( SimulationContext & ctx)

Pre-routing hook: update outfall boundaries from 2D surface heads.

Must be called BEFORE the 1D routing step, after setOutfallDepths().

Parameters
ctxSimulation context.
Here is the call graph for this function:
Here is the caller graph for this function:

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