OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm::twoD::swe Namespace Reference

Classes

struct  FaceFlux
 
struct  FaceSide
 

Functions

OPENSWMM_KERNEL_FN void physicalFlux (const FaceSide &s, double &fh, double &fn, double &ft) noexcept
 Physical flux of the SWE in the normal frame: [h·un, h·un² + ½g h², h·un·ut].
 
OPENSWMM_KERNEL_FN void waveSpeeds (const FaceSide &L, const FaceSide &R, double &sl, double &sr) noexcept
 Wave-speed estimates S_L ≤ S_R (Toro 2001 §10.4): two-rarefaction estimate for wet–wet faces, the exact dry-bed front speeds otherwise.
 
OPENSWMM_KERNEL_FN void hllcFlux (const FaceSide &L, const FaceSide &R, double &fh, double &fn, double &ft, double &sstar) noexcept
 HLLC flux in the face-normal frame.
 
OPENSWMM_KERNEL_FN bool faceFlux (double etaL, double hL, double qxL, double qyL, double etaR, double hR, double qxR, double qyR, double nx, double ny, double h_dry, FaceFlux &out, double &corrL_x, double &corrL_y, double &corrR_x, double &corrR_y) noexcept
 Full face evaluation: hydrostatic reconstruction, rotation, HLLC, rotation back, and the per-side bed-slope corrections.
 
OPENSWMM_KERNEL_FN bool faceFluxReconBed (double etaLf, double uxLf, double uyLf, double zL, double hL_cell, double etaRf, double uxRf, double uyRf, double zR, double hR_cell, double nx, double ny, double h_dry, FaceFlux &out, double &corrL_x, double &corrL_y, double &corrR_x, double &corrR_y, double zLf, double zRf) noexcept
 Second-order face flux with independently reconstructed depth/bed.
 
OPENSWMM_KERNEL_FN bool faceFluxRecon (double etaLf, double uxLf, double uyLf, double zL, double hL_cell, double etaRf, double uxRf, double uyRf, double zR, double hR_cell, double nx, double ny, double h_dry, FaceFlux &out, double &corrL_x, double &corrL_y, double &corrR_x, double &corrR_y) noexcept
 Piecewise-constant-bed compatibility entry point.
 
OPENSWMM_KERNEL_FN double bjLimiter (double w, double wf, double wmin, double wmax) noexcept
 Barth–Jespersen limiter factor φ ∈ [0, 1] for one cell/variable given the cell value w, the extrapolated face value wf and the min/max over the cell and its neighbours.
 
OPENSWMM_KERNEL_FN void frictionUpdate (double &qx, double &qy, double h, double n, double dt) noexcept
 Semi-implicit Manning friction on a cell's unit discharge over Δt: q⃗ ← q⃗ / (1 + g·Δt·n²·|q⃗| / h^{7/3}). Only shrinks |q⃗|; never reverses it.
 
OPENSWMM_KERNEL_FN double criticalDepth (double q) noexcept
 Critical depth for a per-metre discharge q: (q²/g)^{1/3} — the ghost depth of a prescribed-flow boundary entering a dry cell.
 
OPENSWMM_KERNEL_FN double depthFromInvariantAndDischarge (double r, double q, double h_interior) noexcept
 Ghost depth of a SUBCRITICAL prescribed-discharge boundary.
 

Variables

constexpr double kGravity = 9.80665
 

Function Documentation

◆ bjLimiter()

OPENSWMM_KERNEL_FN double openswmm::twoD::swe::bjLimiter ( double w,
double wf,
double wmin,
double wmax )
noexcept

Barth–Jespersen limiter factor φ ∈ [0, 1] for one cell/variable given the cell value w, the extrapolated face value wf and the min/max over the cell and its neighbours.

Parameters
[in]wFinite cell-centered variable in the variable's own units.
[in]wfFinite unlimited extrapolated face value in the same units.
[in]wminMinimum over the cell and neighbors; must satisfy wmin <= w.
[in]wmaxMaximum over the cell and neighbors; must satisfy w <= wmax.
Returns
Dimensionless limiter in [0,1] when the extrema bracket w; one when |wf-w| <= 1e-14. The kernel does not clamp invalid negative ratios.
Note
Pure host/device arithmetic: no allocation, exceptions, retained pointers or model state mutation. Caller supplies finite valid physical inputs; no general validation.
Here is the caller graph for this function:

◆ criticalDepth()

OPENSWMM_KERNEL_FN double openswmm::twoD::swe::criticalDepth ( double q)
noexcept

Critical depth for a per-metre discharge q: (q²/g)^{1/3} — the ghost depth of a prescribed-flow boundary entering a dry cell.

Parameters
[in]qFinite signed unit-width discharge, m2/s; sign is squared.
Returns
Nonnegative critical water depth, m; direct q*q requires caller-bounded magnitude.
Note
Pure host/device arithmetic: no allocation, exceptions, retained pointers or model state mutation. Caller supplies finite valid physical inputs; no general validation.

◆ depthFromInvariantAndDischarge()

OPENSWMM_KERNEL_FN double openswmm::twoD::swe::depthFromInvariantAndDischarge ( double r,
double q,
double h_interior )
noexcept

Ghost depth of a SUBCRITICAL prescribed-discharge boundary.

One characteristic leaves the domain there, so its Riemann invariant r = u + 2c is carried out from the interior and, with the prescribed per-metre discharge q = u·h, fixes the boundary depth:

q/h + 2·sqrt(g·h) = r      ⇔      2·sqrt(g)·s³ − r·s² + q = 0,  s = sqrt(h)

Newton on s from the interior depth with positive/finite-step guards (≤ 40 iterations); returns h_interior when it cannot converge — the caller's mass flux is prescribed either way, so a fallback only costs accuracy in the momentum flux, never conservation. Signs follow the outward normal: an inflow has q < 0.

Parameters
[in]rFinite outgoing normal Riemann invariant u+2*sqrt(g*h), m/s.
[in]qFinite prescribed normal unit-width discharge, m2/s; outward-positive, inflow negative.
[in]h_interiorFinite nonnegative interior depth/fallback, m.
Returns
Positive ghost depth in m when a physical Newton root passes convergence checks, otherwise h_interior.
Note
At most 40 Newton iterations with positive-step/finite-derivative guards, not a bracketed root solve. Nonpositive interior depth starts the iteration at 1e-6 m. Pure host/device computation; no separate failure code or retained state.

◆ faceFlux()

OPENSWMM_KERNEL_FN bool openswmm::twoD::swe::faceFlux ( double etaL,
double hL,
double qxL,
double qyL,
double etaR,
double hR,
double qxR,
double qyR,
double nx,
double ny,
double h_dry,
FaceFlux & out,
double & corrL_x,
double & corrL_y,
double & corrR_x,
double & corrR_y )
noexcept

Full face evaluation: hydrostatic reconstruction, rotation, HLLC, rotation back, and the per-side bed-slope corrections.

Returns
true when the face carries flux OR a bed-pressure correction. A blocked wet/dry face still supplies the wet cell's wall pressure. false ⇒ every output is zero.
Parameters
[in]etaLFinite left cell free surface, m.
[in]hLFinite nonnegative left mean depth, m.
[in]qxLFinite left X unit-width discharge, m2/s.
[in]qyLFinite left Y unit-width discharge, m2/s.
[in]etaRFinite right cell free surface, m.
[in]hRFinite nonnegative right mean depth, m.
[in]qxRFinite right X unit-width discharge, m2/s.
[in]qyRFinite right Y unit-width discharge, m2/s.
[in]nxFinite X component of a unit normal directed left-to-right.
[in]nyFinite Y component of the same normal.
[in]h_dryFinite nonnegative depth threshold in m for shoreline velocity suppression.
[out]outCompletely assigned Cartesian FaceFlux: mass m2/s, momentum m3/s2, sstar m/s.
[out]corrL_xLeft-side X bed-source correction, m3/s2 per unit face length.
[out]corrL_yLeft-side Y bed-source correction in the same units.
[out]corrR_xRight-side X bed-source correction with opposite outward normal, m3/s2.
[out]corrR_yRight-side Y bed-source correction, m3/s2.
Returns
True for a face flux or nonzero bed-pressure correction; false only when every output is zero.
Note
All outputs are assigned; keep outputs distinct and independent of input fields. Pure host/device function; no validation, ownership transfer, allocation or timestep update. Multiply momentum/source terms by face length and dt in the caller.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ faceFluxRecon()

OPENSWMM_KERNEL_FN bool openswmm::twoD::swe::faceFluxRecon ( double etaLf,
double uxLf,
double uyLf,
double zL,
double hL_cell,
double etaRf,
double uxRf,
double uyRf,
double zR,
double hR_cell,
double nx,
double ny,
double h_dry,
FaceFlux & out,
double & corrL_x,
double & corrL_y,
double & corrR_x,
double & corrR_y )
noexcept

Piecewise-constant-bed compatibility entry point.

Parameters
[in]etaLfFinite reconstructed left face free surface, m.
[in]uxLfFinite reconstructed left X velocity, m/s.
[in]uyLfFinite reconstructed left Y velocity, m/s.
[in]zLFinite left cell-equivalent bed elevation, m.
[in]hL_cellFinite nonnegative left cell mean depth, m.
[in]etaRfFinite reconstructed right face free surface, m.
[in]uxRfFinite reconstructed right X velocity, m/s.
[in]uyRfFinite reconstructed right Y velocity, m/s.
[in]zRFinite right cell-equivalent bed elevation, m.
[in]hR_cellFinite nonnegative right cell mean depth, m.
[in]nxFinite X component of a unit normal directed left-to-right.
[in]nyFinite Y component of the same normal.
[in]h_dryFinite nonnegative depth threshold in m for shoreline velocity suppression.
[out]outCompletely assigned Cartesian FaceFlux: mass m2/s, momentum m3/s2, sstar m/s.
[out]corrL_xLeft-side X bed-source correction, m3/s2 per unit face length.
[out]corrL_yLeft-side Y bed-source correction in the same units.
[out]corrR_xRight-side X bed-source correction with opposite outward normal, m3/s2.
[out]corrR_yRight-side Y bed-source correction, m3/s2.
Returns
True for a face flux or nonzero bed-pressure correction; false only when every output is zero.
Note
All outputs are assigned; keep outputs distinct and independent of input fields. Pure host/device function; no validation, ownership transfer, allocation or timestep update. Multiply momentum/source terms by face length and dt in the caller. This compatibility wrapper uses cell beds as face beds.
Here is the call graph for this function:

◆ faceFluxReconBed()

OPENSWMM_KERNEL_FN bool openswmm::twoD::swe::faceFluxReconBed ( double etaLf,
double uxLf,
double uyLf,
double zL,
double hL_cell,
double etaRf,
double uxRf,
double uyRf,
double zR,
double hR_cell,
double nx,
double ny,
double h_dry,
FaceFlux & out,
double & corrL_x,
double & corrL_y,
double & corrR_x,
double & corrR_y,
double zLf,
double zRf )
noexcept

Second-order face flux with independently reconstructed depth/bed.

zLf/zRf are face beds from the limited eta and depth reconstruction; zL/zR are the cell-equivalent beds. Add the hydrostatic face correction and the centered bed contribution -g*(h_cell+h_face)/2*(z_face-z_cell). The latter integrates a linear depth along the cell-to-face bed segment. For constant eta this reduces to g/2*(h_star^2-h_cell^2), preserving lake-at-rest balance even next to a first-order cell. On a flat bed the within-cell contribution vanishes. Face-depth positivity and cell-centered shoreline velocity are enforced by computeLimitedGradientsSwe().

Parameters
[in]etaLfFinite reconstructed left face free surface, m.
[in]uxLfFinite reconstructed left X velocity, m/s.
[in]uyLfFinite reconstructed left Y velocity, m/s.
[in]zLFinite left cell-equivalent bed elevation, m.
[in]hL_cellFinite nonnegative left cell mean depth, m.
[in]etaRfFinite reconstructed right face free surface, m.
[in]uxRfFinite reconstructed right X velocity, m/s.
[in]uyRfFinite reconstructed right Y velocity, m/s.
[in]zRFinite right cell-equivalent bed elevation, m.
[in]hR_cellFinite nonnegative right cell mean depth, m.
[in]nxFinite X component of a unit normal directed left-to-right.
[in]nyFinite Y component of the same normal.
[in]h_dryFinite nonnegative depth threshold in m for shoreline velocity suppression.
[out]outCompletely assigned Cartesian FaceFlux: mass m2/s, momentum m3/s2, sstar m/s.
[out]corrL_xLeft-side X bed-source correction, m3/s2 per unit face length.
[out]corrL_yLeft-side Y bed-source correction in the same units.
[out]corrR_xRight-side X bed-source correction with opposite outward normal, m3/s2.
[out]corrR_yRight-side Y bed-source correction, m3/s2.
[in]zLfFinite reconstructed left face bed elevation, m.
[in]zRfFinite reconstructed right face bed elevation, m.
Returns
True for a face flux or nonzero bed-pressure correction; false only when every output is zero.
Note
All outputs are assigned; keep outputs distinct and independent of input fields. Pure host/device function; no validation, ownership transfer, allocation or timestep update. Multiply momentum/source terms by face length and dt in the caller.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ frictionUpdate()

OPENSWMM_KERNEL_FN void openswmm::twoD::swe::frictionUpdate ( double & qx,
double & qy,
double h,
double n,
double dt )
noexcept

Semi-implicit Manning friction on a cell's unit discharge over Δt: q⃗ ← q⃗ / (1 + g·Δt·n²·|q⃗| / h^{7/3}). Only shrinks |q⃗|; never reverses it.

Parameters
[in,out]qxX unit-width discharge, m2/s.
[in,out]qyY unit-width discharge, m2/s; distinct from qx.
[in]hFinite cell mean depth, m; nonpositive zeros both discharges.
[in]nFinite nonnegative Manning roughness, s/m^(1/3).
[in]dtFinite nonnegative update duration, s.
Note
In-place pure host/device scalar update; semi-implicit denominator preserves direction for valid inputs. No allocation, ledger update, or other model-state mutation.
Here is the caller graph for this function:

◆ hllcFlux()

OPENSWMM_KERNEL_FN void openswmm::twoD::swe::hllcFlux ( const FaceSide & L,
const FaceSide & R,
double & fh,
double & fn,
double & ft,
double & sstar )
noexcept

HLLC flux in the face-normal frame.

Parameters
[in]LBorrowed finite reconstructed face state: nonnegative h in m and normal/tangential velocities in m/s.
[in]RBorrowed finite reconstructed face state: nonnegative h in m and normal/tangential velocities in m/s.
[out]fhMass flux in m2/s, positive left-to-right.
[out]fnNormal momentum flux in m3/s2.
[out]ftTangential momentum flux in m3/s2.
[out]sstarContact-wave speed in m/s for passive-scalar donor selection.
Note
All outputs are assigned, including zero for both-dry faces; degenerate contact denominator falls back to mean normal velocity. Distinct outputs and finite nonnegative depths are required. No allocation or model-state mutation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ physicalFlux()

OPENSWMM_KERNEL_FN void openswmm::twoD::swe::physicalFlux ( const FaceSide & s,
double & fh,
double & fn,
double & ft )
noexcept

Physical flux of the SWE in the normal frame: [h·un, h·un² + ½g h², h·un·ut].

Parameters
[in]sBorrowed finite reconstructed face state: nonnegative h in m and normal/tangential velocities in m/s.
[out]fhMass/unit-width volume flux in m2/s.
[out]fnNormal momentum flux in m3/s2.
[out]ftTangential momentum flux in m3/s2.
Note
Pure scalar host/device evaluation; outputs must be distinct and must not alias input fields. No validation, allocation or state mutation.
Here is the caller graph for this function:

◆ waveSpeeds()

OPENSWMM_KERNEL_FN void openswmm::twoD::swe::waveSpeeds ( const FaceSide & L,
const FaceSide & R,
double & sl,
double & sr )
noexcept

Wave-speed estimates S_L ≤ S_R (Toro 2001 §10.4): two-rarefaction estimate for wet–wet faces, the exact dry-bed front speeds otherwise.

Parameters
[in]LBorrowed finite reconstructed face state: nonnegative h in m and normal/tangential velocities in m/s.
[in]RBorrowed finite reconstructed face state: nonnegative h in m and normal/tangential velocities in m/s.
[out]slEstimated leftmost wave speed, m/s.
[out]srEstimated rightmost wave speed, m/s.
Note
Both-dry faces return zero speeds. Caller supplies distinct output scalars and valid finite depths; no allocation, mutation or robust-predicate error status.
Here is the caller graph for this function:

Variable Documentation

◆ kGravity

double openswmm::twoD::swe::kGravity = 9.80665
inlineconstexpr