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

The explicit-FV cross-section closure as a single-source POD kernel: one monotone cubic-Hermite table per section, with T ≡ dA/dh and I₁ ≡ ∫A by construction, and a Newton inverse on the same cubic. More...

#include <cmath>
#include <cstdint>
#include <type_traits>
Include dependency graph for FvClosureKernels.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  openswmm::fv::FvClosure
 One section's closure. Fixed-size POD: inline arrays, no pointers. More...
 
struct  openswmm::fv::kernels::ClosureEval
 A, T and I₁ at one depth, from one panel locate. More...
 

Namespaces

namespace  openswmm
 
namespace  openswmm::fv
 
namespace  openswmm::fv::kernels
 

Macros

#define OPENSWMM_KERNEL_FN   inline
 

Enumerations

enum  : uint8_t {
  openswmm::fv::kClosureTabulated = 0 ,
  openswmm::fv::kClosurePolynomial = 1
}
 The closure's representation class. More...
 

Functions

OPENSWMM_KERNEL_FN void openswmm::fv::kernels::closureLocate (const FvClosure &c, double h, int &i, double &t) noexcept
 Locate a uniform depth panel and its clamped local coordinate.
 
OPENSWMM_KERNEL_FN void openswmm::fv::kernels::closureHermite (const FvClosure &c, int i, double t, double &a, double &dadh, double &int_dh) noexcept
 Evaluate one cubic area panel, its derivative and its partial integral.
 
OPENSWMM_KERNEL_FN ClosureEval openswmm::fv::kernels::closureEval (const FvClosure &c, double h) noexcept
 Evaluate area, top width and cumulative hydrostatic integral together.
 
OPENSWMM_KERNEL_FN ClosureEval openswmm::fv::kernels::closureEval (const FvClosure &c, double h, double &radius) noexcept
 Evaluate closure area/width/integral and friction radius at one depth.
 
OPENSWMM_KERNEL_FN double openswmm::fv::kernels::closureArea (const FvClosure &c, double h) noexcept
 Evaluate the closure flow area.
 
OPENSWMM_KERNEL_FN double openswmm::fv::kernels::closureWidth (const FvClosure &c, double h) noexcept
 Evaluate the closure area derivative used as top width.
 
OPENSWMM_KERNEL_FN double openswmm::fv::kernels::closureI1 (const FvClosure &c, double h) noexcept
 Evaluate the closure hydrostatic first moment.
 
OPENSWMM_KERNEL_FN double openswmm::fv::kernels::closureHydRad (const FvClosure &c, double h) noexcept
 Evaluate the friction hydraulic radius.
 
OPENSWMM_KERNEL_FN double openswmm::fv::kernels::closureDepthOfArea (const FvClosure &c, double a) noexcept
 Invert aggregate closure area using the same forward geometry.
 

Variables

constexpr int openswmm::fv::kClosurePanels = 128
 Panels of the closure table, uniform in depth on [0, y_full].
 

Detailed Description

The explicit-FV cross-section closure as a single-source POD kernel: one monotone cubic-Hermite table per section, with T ≡ dA/dh and I₁ ≡ ∫A by construction, and a Newton inverse on the same cubic.

Plan FV1D_CLOSURE_KERNEL_PERF_PLAN_2026-09-11 §2a/§2a‴. The table is built once at mesh build (NetworkMeshBuilder::buildClosure) by sampling the EXACT section geometry (SectionGeometry.hpp) at N+1 uniform depths on [0, y_full], with the tapered Preissmann slot folded in; above y_full the closure is the analytic slot line, as it always was. Every function here is a plain inline over scalars and a const FvClosure& — no pointers, no allocation, no exceptions, no dispatch on shape — so the same bodies compile for the CPU solver and, annotated, for the device backend.

Two classes share the struct:

  • kTabulated: the Hermite table (closed shapes, table-defined shapes, transects). A per panel is a cubic in the local coordinate t ∈ [0,1]; T is its derivative; I₁ its integral plus the running sum; R is interpolated linearly.
  • kPolynomial: open sections whose area is a polynomial of degree ≤ 2 (RECT_OPEN, TRAPEZOIDAL, TRIANGULAR). Closed forms in the hot loop — cheaper than any table gather — with an exact quadratic-formula inverse (plan §2a″ cost weighting).

Why a Hermite table with the exact width as node slope: the legacy A and W tables are independent tabulations, so Newton on them was unsafe and the solver paid Brent's ~6-8 evaluations and a dependent divide chain per inversion (185 ns on a circle, of which only ~28 ns were closure calls). Here the derivative IS the closure's own, monotone by the Fritsch–Carlson limiter, so a safeguarded Newton usually converges in a few steps; the bounded inverse returns its last iterate without a separate convergence status.

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

Macro Definition Documentation

◆ OPENSWMM_KERNEL_FN

#define OPENSWMM_KERNEL_FN   inline