![]() |
OpenSWMM Engine
6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
|
Kinematic wave solver state. More...
#include <KinematicWave.hpp>
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) | |
Kinematic wave solver state.
Holds SoA working arrays for all conduits. Allocated once at init. The execute() method routes all conduits for one timestep.
| 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.
| [in,out] | ctx | Borrowed resolved hydraulic model with old/current arrays and subtype mappings initialized; node inflow/outflow accumulators must be prepared. |
| [in] | dt | Positive finite routing seconds. |
| [in] | structures | Optional borrowed initialized nonconduit solver; NULL causes unsupported structure paths to carry0. |
| 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.
| [in] | n_conduits | Nonnegative number of global link slots required by execute (Router passes n_links despite historical name); negative unchecked. |
| [in] | groups | Borrowed shape-group manager, currently unused and not retained. |
|
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.
| [in] | sorted_links | Borrowed valid global indices, with contiguous outgoing links per node and main divider outlet before diversion. |
| 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.
| [in] | idx | Valid GLOBAL link slot in all solver history/input/output vectors; q_in already populated. |
| [in] | xs | Borrowed valid native scalar section with live profile tables; matching full/s_max properties. |
| [in] | q_full | Positive full per-barrel discharge cfs; nonpositive writes zero q_out/a_out and returns0. |
| [in] | a_full | Positive full per-barrel area ft2; nonpositive follows zero-output branch. |
| [in] | s_full | Historical full section-factor argument, currently unused; xs.s_full supplies geometry. |
| [in] | beta | Positive native conveyance coefficient matching section-factor units. |
| [in] | length | Positive routing length ft. |
| [in] | dt | Positive finite routing seconds. |
| [in] | loss_rate | Signed per-barrel net loss cfs already donor-capped; negative represents gain. |
| std::vector<double> openswmm::kinwave::KWSolver::a1_ |
Previous inlet area (ft2)
| std::vector<double> openswmm::kinwave::KWSolver::a2_ |
Previous outlet area (ft2)
| std::vector<double> openswmm::kinwave::KWSolver::a_in_ |
Inlet area from inflow (ft2)
| std::vector<double> openswmm::kinwave::KWSolver::a_out_ |
Outlet area from Newton solve (ft2)
| std::vector<double> openswmm::kinwave::KWSolver::q1_ |
Previous inlet flow (cfs)
| std::vector<double> openswmm::kinwave::KWSolver::q2_ |
Previous outlet flow (cfs)
| std::vector<double> openswmm::kinwave::KWSolver::q_in_ |
Inflow to each conduit (cfs)
| std::vector<double> openswmm::kinwave::KWSolver::q_out_ |
Computed outflow (cfs)
| std::vector<double> openswmm::kinwave::KWSolver::sf_in_ |
Section factor at inlet.
| std::vector<int> openswmm::kinwave::KWSolver::sorted_links_ |
Topological link order (upstream → downstream)
| 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().
| std::vector<double> openswmm::kinwave::KWSolver::y1_ |
End-of-step upstream flow depth (ft)
| std::vector<double> openswmm::kinwave::KWSolver::y2_ |
End-of-step downstream flow depth (ft)