OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm::kinwave::KWSolver Class Reference

Kinematic wave solver state. More...

#include <KinematicWave.hpp>

Collaboration diagram for openswmm::kinwave::KWSolver:

Public Member Functions

void init (int n_conduits, const XSectGroups &groups)
 Allocate/reset kinematic-wave history and work vectors by global link slot.
 
void setLinkOrder (const std::vector< int > &sorted_links)
 Copy the topologically sorted global link order used for tree routing.
 
int execute (SimulationContext &ctx, double dt, hydstruct::StructureSolver *structures=nullptr)
 Route one tree-layout kinematic-wave step and update node/link native state.
 
int solveConduit (int idx, const XSectParams &xs, double q_full, double a_full, double s_full, double beta, double length, double dt, double loss_rate)
 Solve one native per-barrel KW continuity update with safeguarded Newton.
 

Public Attributes

std::vector< int > sorted_links_
 Topological link order (upstream → downstream)
 
std::vector< char > storage_updated_
 
std::vector< double > q1_
 Previous inlet flow (cfs)
 
std::vector< double > a1_
 Previous inlet area (ft2)
 
std::vector< double > q2_
 Previous outlet flow (cfs)
 
std::vector< double > a2_
 Previous outlet area (ft2)
 
std::vector< double > q_in_
 Inflow to each conduit (cfs)
 
std::vector< double > a_in_
 Inlet area from inflow (ft2)
 
std::vector< double > q_out_
 Computed outflow (cfs)
 
std::vector< double > a_out_
 Outlet area from Newton solve (ft2)
 
std::vector< double > sf_in_
 Section factor at inlet.
 
std::vector< double > y1_
 End-of-step upstream flow depth (ft)
 
std::vector< double > y2_
 End-of-step downstream flow depth (ft)
 

Detailed Description

Kinematic wave solver state.

Holds SoA working arrays for all conduits. Allocated once at init. The execute() method routes all conduits for one timestep.

Member Function Documentation

◆ execute()

int openswmm::kinwave::KWSolver::execute ( SimulationContext & ctx,
double dt,
hydstruct::StructureSolver * structures = nullptr )

Route one tree-layout kinematic-wave step and update node/link native state.

Uses configured topological order or natural fallback, updates storage before its outlet links, routes ordinary conduits per barrel, and handles DUMMY/nonconduits as pass-through/head-discharge paths. Publishes accepted KW inlet flow for quality, outlet cfs, ft depths, ft3 volumes and full-state flags, then finishes node states. Scratch/fallback order can allocate. No generic convergence-failure status or transactional rollback; caller serializes use.

Parameters
[in,out]ctxBorrowed resolved hydraulic model with old/current arrays and subtype mappings initialized; node inflow/outflow accumulators must be prepared.
[in]dtPositive finite routing seconds.
[in]structuresOptional borrowed initialized nonconduit solver; NULL causes unsupported structure paths to carry0.
Returns
Integer-truncated average continuity iteration count, or1 when no conduits solved.
Here is the call graph for this function:

◆ init()

void openswmm::kinwave::KWSolver::init ( int n_conduits,
const XSectGroups & groups )

Allocate/reset kinematic-wave history and work vectors by global link slot.

Zeros q1/a1/q2/a2 and endpoint depths; resizes other work vectors preserving prefixes. Does not construct/set topological order, despite historical declaration comment. Allocation can leave partial reset.

Parameters
[in]n_conduitsNonnegative number of global link slots required by execute (Router passes n_links despite historical name); negative unchecked.
[in]groupsBorrowed shape-group manager, currently unused and not retained.

◆ setLinkOrder()

void openswmm::kinwave::KWSolver::setLinkOrder ( const std::vector< int > & sorted_links)
inline

Copy the topologically sorted global link order used for tree routing.

Owned order copy; empty selects natural-link-order fallback at execute. Does not validate topology/order or initialize numerical state. Allocation may throw.

Parameters
[in]sorted_linksBorrowed valid global indices, with contiguous outgoing links per node and main divider outlet before diversion.

◆ solveConduit()

int openswmm::kinwave::KWSolver::solveConduit ( int idx,
const XSectParams & xs,
double q_full,
double a_full,
double s_full,
double beta,
double length,
double dt,
double loss_rate )

Solve one native per-barrel KW continuity update with safeguarded Newton.

Updates inlet/outlet areas/flows and next-step history in place. Uses WX=WT=0.6 and normalized area tolerance0.001; dry branch gives exact zero. Full/no-flow brackets and failed Newton retain selected/last candidate without an error return. Caps accepted normalized inflow at1 after solve; no output rollback, finite validation or barrel scaling.

Parameters
[in]idxValid GLOBAL link slot in all solver history/input/output vectors; q_in already populated.
[in]xsBorrowed valid native scalar section with live profile tables; matching full/s_max properties.
[in]q_fullPositive full per-barrel discharge cfs; nonpositive writes zero q_out/a_out and returns0.
[in]a_fullPositive full per-barrel area ft2; nonpositive follows zero-output branch.
[in]s_fullHistorical full section-factor argument, currently unused; xs.s_full supplies geometry.
[in]betaPositive native conveyance coefficient matching section-factor units.
[in]lengthPositive routing length ft.
[in]dtPositive finite routing seconds.
[in]loss_rateSigned per-barrel net loss cfs already donor-capped; negative represents gain.
Returns
0 for nonpositive full dimensions, otherwise positive function-evaluation/nominal count; refused/exhausted root cases are normalized to1.
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ a1_

std::vector<double> openswmm::kinwave::KWSolver::a1_

Previous inlet area (ft2)

◆ a2_

std::vector<double> openswmm::kinwave::KWSolver::a2_

Previous outlet area (ft2)

◆ a_in_

std::vector<double> openswmm::kinwave::KWSolver::a_in_

Inlet area from inflow (ft2)

◆ a_out_

std::vector<double> openswmm::kinwave::KWSolver::a_out_

Outlet area from Newton solve (ft2)

◆ q1_

std::vector<double> openswmm::kinwave::KWSolver::q1_

Previous inlet flow (cfs)

◆ q2_

std::vector<double> openswmm::kinwave::KWSolver::q2_

Previous outlet flow (cfs)

◆ q_in_

std::vector<double> openswmm::kinwave::KWSolver::q_in_

Inflow to each conduit (cfs)

◆ q_out_

std::vector<double> openswmm::kinwave::KWSolver::q_out_

Computed outflow (cfs)

◆ sf_in_

std::vector<double> openswmm::kinwave::KWSolver::sf_in_

Section factor at inlet.

◆ sorted_links_

std::vector<int> openswmm::kinwave::KWSolver::sorted_links_

Topological link order (upstream → downstream)

◆ storage_updated_

std::vector<char> openswmm::kinwave::KWSolver::storage_updated_

Per-node "already converged this step" flag for storage units (legacy Node[i].updated). Reset at the top of every execute().

◆ y1_

std::vector<double> openswmm::kinwave::KWSolver::y1_

End-of-step upstream flow depth (ft)

◆ y2_

std::vector<double> openswmm::kinwave::KWSolver::y2_

End-of-step downstream flow depth (ft)


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