OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
openswmm::dynwave::DWSolver Class Reference

Dynamic wave solver — operates on entire link/node system. More...

#include <DynamicWave.hpp>

Collaboration diagram for openswmm::dynwave::DWSolver:

Public Types

using NonConduitFlowFunc = std::function< void(SimulationContext &, double, int)>
 

Public Member Functions

void init (int n_nodes, int n_links, const XSectGroups &groups, const SimulationContext &ctx)
 
void setNumThreads (int n)
 Set the number of OpenMP threads for parallel loops.
 
int execute (SimulationContext &ctx, double dt, NonConduitFlowFunc non_conduit_fn=nullptr)
 Execute one DW routing timestep.
 
double getRoutingStep (SimulationContext &ctx, double fixed_step, double courant_factor)
 Compute CFL-based variable timestep.
 
uint8_t & nodeSurchargedFlag (int idx)
 Direct write access to the per-node is_surcharged flag (for tests/non-conduit scatter).
 
double * nodeNewSurfAreaDataMut ()
 Mutable pointer to the per-node new_surf_area array (for HydStructures scatter).
 
double & nodeSumDqdh (int n)
 Mutable reference to the per-node sumdqdh accumulator at index n.
 
const std::vector< uint8_t > & aaSkipFlags () const
 Access per-node AA skip flags (read-only, for testing/diagnostics).
 
const DPSLinkArraysdpsState () const
 Read-only access to DPS per-conduit state arrays (for tests/diagnostics).
 
const DPSConfigdpsConfig () const
 Read-only access to DPS configuration (for tests/diagnostics).
 
DPSLinkArraysdpsStateMut ()
 Mutable access to DPS state for tests that need to seed slot conditions.
 

Public Attributes

double head_tol = DEFAULT_HEAD_TOL
 
int max_trials = DEFAULT_MAX_TRIALS
 
double omega = OMEGA
 
SurchargeMethod surcharge_method = SurchargeMethod::EXTRAN
 
NodeContinuity node_continuity = NodeContinuity::EXPLICIT
 
bool anderson_accel = false
 Enable Anderson acceleration.
 
double evap_rate = 0.0
 

Detailed Description

Dynamic wave solver — operates on entire link/node system.

Working arrays are allocated once at init and reused each timestep. The solver pre-computes all cross-section geometry via XSectGroups batch API before entering the momentum arithmetic loop, ensuring the inner loop is branch-free and vectorisable.

Member Typedef Documentation

◆ NonConduitFlowFunc

using openswmm::dynwave::DWSolver::NonConduitFlowFunc = std::function<void(SimulationContext&, double, int)>

Callback for computing non-conduit link flows inside the Picard loop. Parameters: (ctx, dt, picard_step) where step=0 is first iteration.

Member Function Documentation

◆ aaSkipFlags()

const std::vector< uint8_t > & openswmm::dynwave::DWSolver::aaSkipFlags ( ) const
inline

Access per-node AA skip flags (read-only, for testing/diagnostics).

◆ dpsConfig()

const DPSConfig & openswmm::dynwave::DWSolver::dpsConfig ( ) const
inline

Read-only access to DPS configuration (for tests/diagnostics).

◆ dpsState()

const DPSLinkArrays & openswmm::dynwave::DWSolver::dpsState ( ) const
inline

Read-only access to DPS per-conduit state arrays (for tests/diagnostics).

◆ dpsStateMut()

DPSLinkArrays & openswmm::dynwave::DWSolver::dpsStateMut ( )
inline

Mutable access to DPS state for tests that need to seed slot conditions.

◆ execute()

int openswmm::dynwave::DWSolver::execute ( SimulationContext ctx,
double  dt,
DWSolver::NonConduitFlowFunc  non_conduit_fn = nullptr 
)

Execute one DW routing timestep.

Parameters
ctxSimulation context.
dtTimestep (seconds).
non_conduit_fnOptional callback to compute pump/orifice/weir/outlet flows inside the Picard iteration loop (matching legacy).
Returns
Number of Picard iterations used.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRoutingStep()

double openswmm::dynwave::DWSolver::getRoutingStep ( SimulationContext ctx,
double  fixed_step,
double  courant_factor 
)

Compute CFL-based variable timestep.

Also updates per-node/link CFL-critical counters (matching legacy stats_updateCriticalTimeCount).

Here is the caller graph for this function:

◆ init()

void openswmm::dynwave::DWSolver::init ( int  n_nodes,
int  n_links,
const XSectGroups groups,
const SimulationContext ctx 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nodeNewSurfAreaDataMut()

double * openswmm::dynwave::DWSolver::nodeNewSurfAreaDataMut ( )
inline

Mutable pointer to the per-node new_surf_area array (for HydStructures scatter).

◆ nodeSumDqdh()

double & openswmm::dynwave::DWSolver::nodeSumDqdh ( int  n)
inline

Mutable reference to the per-node sumdqdh accumulator at index n.

◆ nodeSurchargedFlag()

uint8_t & openswmm::dynwave::DWSolver::nodeSurchargedFlag ( int  idx)
inline

Direct write access to the per-node is_surcharged flag (for tests/non-conduit scatter).

◆ setNumThreads()

void openswmm::dynwave::DWSolver::setNumThreads ( int  n)

Set the number of OpenMP threads for parallel loops.

Called after init() when the thread count is finalized. A threshold is applied: if n_links < 4 * n, threading is disabled (matching legacy dynwave.c behaviour).

Parameters
nRequested thread count (0 = use omp_get_max_threads()).
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ anderson_accel

bool openswmm::dynwave::DWSolver::anderson_accel = false

Enable Anderson acceleration.

◆ evap_rate

double openswmm::dynwave::DWSolver::evap_rate = 0.0

Evaporation rate (ft/s) — set by Router::step() each timestep so that solveMomentumBatch can recompute dq6 per Picard iteration (Gap #14).

◆ head_tol

double openswmm::dynwave::DWSolver::head_tol = DEFAULT_HEAD_TOL

◆ max_trials

int openswmm::dynwave::DWSolver::max_trials = DEFAULT_MAX_TRIALS

◆ node_continuity

NodeContinuity openswmm::dynwave::DWSolver::node_continuity = NodeContinuity::EXPLICIT

◆ omega

double openswmm::dynwave::DWSolver::omega = OMEGA

◆ surcharge_method

SurchargeMethod openswmm::dynwave::DWSolver::surcharge_method = SurchargeMethod::EXTRAN

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