OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
InertialKernels.hpp File Reference

Single-source flat kernels for the explicit local-inertial marcher. More...

#include <algorithm>
#include <cmath>
#include "../data/MeshData.hpp"
#include "../data/SolverOptions2D.hpp"
#include "../mesh/VfrClosure.hpp"
#include "../mesh/QuadVfr.hpp"
Include dependency graph for InertialKernels.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  openswmm
 
namespace  openswmm::twoD
 
namespace  openswmm::twoD::inertial
 

Macros

#define OPENSWMM_KERNEL_FN   inline
 
#define OPENSWMM_2D_NOINLINE
 

Functions

OPENSWMM_KERNEL_FN double openswmm::twoD::inertial::qMagnitude (double x, double y) noexcept
 
OPENSWMM_KERNEL_FN void openswmm::twoD::inertial::etaDepthScalar (double area, double cz, double z1, double z2, double z3, bool vfr, double vfr_min_wet_frac, double V, double &eta, double &depth) noexcept
 
OPENSWMM_KERNEL_FN double openswmm::twoD::inertial::volumeFromEtaScalar (double area, double cz, double z1, double z2, double z3, bool vfr, double vfr_min_wet_frac, double eta) noexcept
 Scalar core of the η → V inverse (device-callable).
 
OPENSWMM_KERNEL_FN void openswmm::twoD::inertial::etaDepthQuadScalar (double area, double cz, const double *zs, double A1, double A2, bool vfr, double vfr_min_wet_frac, double V, double &eta, double &depth) noexcept
 
OPENSWMM_KERNEL_FN double openswmm::twoD::inertial::volumeFromEtaQuadScalar (double area, double cz, const double *zs, double A1, double A2, bool vfr, double vfr_min_wet_frac, double eta) noexcept
 Quad η → V inverse (device-callable).
 
OPENSWMM_2D_NOINLINE void openswmm::twoD::inertial::cellEtaDepthQuad (const MeshData &m, const SolverOptions2D &o, int i, double V, double &eta, double &depth) noexcept
 
void openswmm::twoD::inertial::cellEtaDepth (const MeshData &m, const SolverOptions2D &o, int i, double V, double &eta, double &depth) noexcept
 
double openswmm::twoD::inertial::cellVolumeFromEta (const MeshData &m, const SolverOptions2D &o, int i, double eta) noexcept
 
OPENSWMM_KERNEL_FN double openswmm::twoD::inertial::faceFlowDepth (double etaL, double etaR, double zface) noexcept
 
OPENSWMM_KERNEL_FN double openswmm::twoD::inertial::faceDepthFromEta (double eta, double z_lo, double z_hi) noexcept
 
OPENSWMM_KERNEL_FN double openswmm::twoD::inertial::faceFlowDepthVfr (double etaL, double etaR, double z_lo, double z_hi) noexcept
 
OPENSWMM_KERNEL_FN double openswmm::twoD::inertial::inertialFaceUpdate (double q, double qhat, double hf, double dt, double slope, double n2, double q_mag, double adv=0.0) noexcept
 
OPENSWMM_KERNEL_FN double openswmm::twoD::inertial::inertialAdvection (double q_f, double unL, double hL, double unR, double hR, double inv_dx_normal) noexcept
 
OPENSWMM_KERNEL_FN double openswmm::twoD::inertial::froudeCap (double q, double hf, double fr_max) noexcept
 
OPENSWMM_KERNEL_FN double openswmm::twoD::inertial::cellCflDt (double alpha, double lchar, double h, double speed) noexcept
 
OPENSWMM_KERNEL_FN double openswmm::twoD::inertial::positivityScale (double V, double outflow_m3s, double dt, double beta) noexcept
 

Variables

constexpr double openswmm::twoD::inertial::kGravity = 9.80665
 matches the existing kernels
 
constexpr double openswmm::twoD::inertial::kEtaDeadband = 1.0e-12
 

Detailed Description

Single-source flat kernels for the explicit local-inertial marcher.

The numerical core of ExplicitInertialSolver (2026-07-29 2D reimplementation plan): the de Almeida & Bates (2013) local-inertial face update on unstructured unique faces, the FLAT/VFR volume→η closure, the Froude clamp, and the CFL step bound. Everything here is a plain inline function over scalars/raw pointers — no owning containers, no allocation, no exceptions — so the same bodies can be annotated for Kokkos in the deferred parallel phase.

Scheme summary (face e between cells L,R; q = unit-width discharge normal to the face, positive cL→cR; SI, g = 9.80665):

h_f = max(η_L, η_R) − max(z_L, z_R) flow depth at face (FACE_RECONSTRUCTION=MEAN; VFR_FACE uses the B&S Eq. 14 wetted-edge depth over the edge's true endpoint beds) S_f = (η_R − η_L) · inv_dx_normal surface slope q̂ = θ·q + (1−θ)·½(q⃗_L + q⃗_R)·n̂ lateral θ-average q* = (q̂ − g·h_f·Δt·S_f) / (1 + g·Δt·n_f²·|q|/h_f^{7/3}) q^{n+1} = clamp(q*, ±Fr_max·h_f·√(g·h_f))

The friction denominator is the exact semi-implicit form used by the ARKODE inertial path (unconditionally stable in friction); θ = 1 recovers Bates et al. (2010). Well-balancedness: at rest η_L = η_R ⇒ S_f = 0 and q stays exactly 0 for any bathymetry; a dry neighbour standing higher gives h_f ≤ 0 ⇒ wall (no uphill creep).

Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
License\n Apache-2.0

Macro Definition Documentation

◆ OPENSWMM_2D_NOINLINE

#define OPENSWMM_2D_NOINLINE

◆ OPENSWMM_KERNEL_FN

#define OPENSWMM_KERNEL_FN   inline