![]() |
OpenSWMM Engine
6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
|
Namespaces | |
| namespace | shape |
| The analytic shape formulas — the single definition of each. | |
Classes | |
| struct | LocateLut |
| struct | XsectEval |
| The geometry layer itself, parameterized on where its tables live. More... | |
| struct | XsectTables |
Enumerations | |
| enum class | LutId : int { Y_Gothic = 0 , Y_Catenary , Y_SemiEllip , Y_SemiCirc , A_HorizEllipse , A_VertEllipse , A_Arch , S_Circ , S_Egg , S_Horseshoe , S_Gothic , S_Catenary , S_SemiEllip , S_BasketHandle , S_SemiCirc , COUNT } |
| Pointers to the shared geometry tables, in whichever memory space the consumer runs in. More... | |
Functions | |
| double | getAofY (const XSectParams &xs, double y) |
| Query native wetted area from depth through the shared host evaluator. | |
| double | getRofY (const XSectParams &xs, double y) |
| Query native hydraulic radius from depth through the shared host evaluator. | |
| double | getWofY (const XSectParams &xs, double y) |
| Query native top width from depth through the shared host evaluator. | |
| double | getYofA (const XSectParams &xs, double a) |
| Query native depth from area through the shared host evaluator. | |
| double | getSofA (const XSectParams &xs, double a) |
| Query native section factor from area through the shared host evaluator. | |
| double | getRofA (const XSectParams &xs, double a) |
| Query native hydraulic radius from area through the shared host evaluator. | |
| double | getdSdA (const XSectParams &xs, double a) |
| Query native section-factor derivative with respect to area through the shared host evaluator. | |
| double | getAofS (const XSectParams &xs, double s_factor) |
| Query native area from section factor through the shared host evaluator. | |
| double | getAmax (const XSectParams &xs) |
| Read the built-in area-at-maximum-conveyance ratio. | |
| double | getYcrit (const XSectParams &xs, double q) |
| Query native critical depth from discharge through the shared host evaluator. | |
| bool | isOpen (int type) |
| Classify a kernel shape using the legacy open-section set. | |
| int | setParams (XSectParams &xs, int type, const double p[], double ucf) |
| Derive native full-flow geometry from authored shape dimensions. | |
| double | lookup (double x, const double *table, int n_items) |
| Interpolate a borrowed equally spaced normalized geometry table. | |
| double | invLookup (double y, const double *table, int n_items, const LocateLut *lut=nullptr) |
| Invert a borrowed normalized geometry table including the legacy declining top. | |
| int | locate (double y, const double *table, int n) |
| Find a lower bracket in a nondecreasing geometry table. | |
| double | getYcircular (double alpha) |
| Compute normalized circular depth from area ratio. | |
| double | getScircular (double alpha) |
| Compute normalized circular section factor from area ratio. | |
| const XsectTables & | hostTables () |
| Borrow host pointers, lengths and inverse maps for every built-in geometry table. | |
| const XsectEval & | hostEval () |
| Borrow the immutable host evaluator bound to process-lifetime tables. | |
| double | lookup_exact (double x, const double *t, int n) noexcept |
| Interpolate a normalized geometry table with the legacy arithmetic grouping. | |
| double | lookup_fast (double x, const double *t, int n) noexcept |
| Interpolate normalized geometry using reciprocal multiplication and endpoint clamps. | |
| double | norm_x (double depth, double param) noexcept |
| Normalize a depth with the selected exact or fast-lookup operand convention. | |
| double | norm_lookup (double depth, double param, const double *t, int n) noexcept |
| Normalize a depth and dispatch the build-selected table interpolation. | |
| int | lut_bucket (const LocateLut &L, double y) noexcept |
| Map a value to one of64 locate-acceleration buckets. | |
| int | locate_bisect (double y, const double *table, int jLast) noexcept |
| Find a lower bracketing index in a nondecreasing table. | |
| void | build_locate_lut (LocateLut &L, const double *table, int jLast) noexcept |
| Build a byte-indexed acceleration map for a monotone geometry table. | |
| int | locate_lut (double y, const double *table, int jLast, const LocateLut &L) noexcept |
| Find the same lower bracket using a prebuilt bucket map. | |
| int | locate_maybe_lut (double y, const double *table, int jLast, const LocateLut *L) noexcept |
| Use a matching enabled bucket map or fall back to plain bisection. | |
| void | build_invlookup_lut (LocateLut &L, const double *table, int n_items) noexcept |
| Build a map for the actual truncated extent used by inverse geometry lookup. | |
Variables | |
| constexpr double | TINY = 1.0e-6 |
| constexpr double | PI = 3.141592654 |
| constexpr double | GRAVITY = 32.2 |
| constexpr double | RECT_ALFMAX = 0.97 |
| constexpr double | RECT_TRIANG_ALFMAX = 0.98 |
| constexpr double | RECT_ROUND_ALFMAX = 0.98 |
|
strong |
Pointers to the shared geometry tables, in whichever memory space the consumer runs in.
Plain POD: trivially copyable into a device kernel by value. The member names are deliberately identical to the xsect_tables:: symbols they bind to, so the moved bodies differ from the originals by exactly one token.
The tables invLookup() inverts, and so the ones that carry a LocateLut (plan XSECT_LOOKUP_ACCEL §4 item A1).
Every other shared table is only ever read forward, where the index is a divide-and-truncate and there is no search to accelerate. Keeping the maps in one array indexed by this enum costs XsectTables a single pointer instead of fifteen, and keeps the host binding (XSection.cpp hostTables) and any device binding to one block to copy.
| Enumerator | |
|---|---|
| Y_Gothic | |
| Y_Catenary | |
| Y_SemiEllip | |
| Y_SemiCirc | |
| A_HorizEllipse | |
| A_VertEllipse | |
| A_Arch | |
| S_Circ | |
| S_Egg | |
| S_Horseshoe | |
| S_Gothic | |
| S_Catenary | |
| S_SemiEllip | |
| S_BasketHandle | |
| S_SemiCirc | |
| COUNT | |
|
inlinenoexcept |
Build a map for the actual truncated extent used by inverse geometry lookup.
When table[n-3]>table[n-1], excludes the two nonmonotone top rows before building. Does not alter source data or accelerate the inverse lookup's separate top-branch interpolation.
| [out] | L | Reset/filled map; NULL/short source disables it. |
| [in] | table | Optional readable n_items-entry finite well-scaled geometry table; same safety preconditions as build_locate_lut. |
| [in] | n_items | Logical table length; fewer than4 disables map. |
|
inlinenoexcept |
Build a byte-indexed acceleration map for a monotone geometry table.
Refuses nonmonotone comparisons (including NaN) and nonpositive span by leaving scale0. Caller supplies finite well-scaled geometry values; infinities/underflow/overflow are not independently guarded. Builds65 bucket lower bounds without allocation. Rebuild after table values change.
| [out] | L | Reset to disabled first, then populated in place when eligible. |
| [in] | table | NULL disables; otherwise readable0..jLast table with finite bounded values making scale/mapped products finite and int-representable. |
| [in] | jLast | Inclusive extent; only2..254 can enable the map, otherwise disabled. |
| double openswmm::xsect::getAmax | ( | const XSectParams & | xs | ) |
Read the built-in area-at-maximum-conveyance ratio.
Returns a ratio rather than the physical custom/irregular xs.a_bot area.
| [in] | xs | Borrowed initialized native geometry with kernel shape numbering and live applicable tables/LUTs; queried physical shape must be supported. |
| double openswmm::xsect::getAofS | ( | const XSectParams & | xs, |
| double | s_factor ) |
Query native area from section factor through the shared host evaluator.
Nonpositive factor/DUMMY returns0; table inverse or Newton candidate is returned without a convergence flag. Direct-table normalized input precedes local s_max cap, preserving current legacy arithmetic. No display-unit conversion, allocation on normal query path or ownership transfer.
| [in] | xs | Borrowed initialized native geometry with kernel shape numbering and live applicable tables/LUTs; queried physical shape must be supported. |
| [in] | s_factor | Finite nonnegative factor in xs.s_full conventions. |
| double openswmm::xsect::getAofY | ( | const XSectParams & | xs, |
| double | y ) |
Query native wetted area from depth through the shared host evaluator.
Nonpositive depth/full depth returns0; tabulated shapes hold endpoints, analytic open profiles can extend beyond full depth. No display-unit conversion, allocation on normal query path or ownership transfer.
| [in] | xs | Borrowed initialized native geometry with kernel shape numbering and live applicable tables/LUTs; queried physical shape must be supported. |
| [in] | y | Finite nonnegative depth ft. |
| double openswmm::xsect::getdSdA | ( | const XSectParams & | xs, |
| double | a ) |
Query native section-factor derivative with respect to area through the shared host evaluator.
Uses analytic/table-segment derivative or normalized-area finite difference; no complete area/finiteness validation. No display-unit conversion, allocation on normal query path or ownership transfer.
| [in] | xs | Borrowed initialized native geometry with kernel shape numbering and live applicable tables/LUTs; queried physical shape must be supported. |
| [in] | a | Finite nonnegative wetted area ft2. |
| double openswmm::xsect::getRofA | ( | const XSectParams & | xs, |
| double | a ) |
Query native hydraulic radius from area through the shared host evaluator.
Nonpositive area returns0; unsupported/DUMMY positive area is invalid for generic recursive radius dispatch. No display-unit conversion, allocation on normal query path or ownership transfer.
| [in] | xs | Borrowed initialized native geometry with kernel shape numbering and live applicable tables/LUTs; queried physical shape must be supported. |
| [in] | a | Finite nonnegative wetted area ft2. |
| double openswmm::xsect::getRofY | ( | const XSectParams & | xs, |
| double | y ) |
Query native hydraulic radius from depth through the shared host evaluator.
Requires valid positive full geometry; optional missing radius table returns0. Unsupported/DUMMY positive-area radius queries are outside the valid domain. No display-unit conversion, allocation on normal query path or ownership transfer.
| [in] | xs | Borrowed initialized native geometry with kernel shape numbering and live applicable tables/LUTs; queried physical shape must be supported. |
| [in] | y | Finite nonnegative depth ft. |
| double openswmm::xsect::getScircular | ( | double | alpha | ) |
Compute normalized circular section factor from area ratio.
| [in] | alpha | Finite area/full-area ratio; <=0 returns0, >=1 returns1. |
| double openswmm::xsect::getSofA | ( | const XSectParams & | xs, |
| double | a ) |
Query native section factor from area through the shared host evaluator.
Ordinary units are ft^(8/3), with the FORCE_MAIN full-factor convention described on XSectParams. Uses specialized S tables/crown corrections or A*R^(2/3); valid non-DUMMY supported geometry is required. No display-unit conversion, allocation on normal query path or ownership transfer.
| [in] | xs | Borrowed initialized native geometry with kernel shape numbering and live applicable tables/LUTs; queried physical shape must be supported. |
| [in] | a | Finite nonnegative wetted area ft2. |
| double openswmm::xsect::getWofY | ( | const XSectParams & | xs, |
| double | y ) |
Query native top width from depth through the shared host evaluator.
Shape-specific dry/crown rules apply; closed rectangle returns0 at exact full depth. Missing optional width table/unsupported code returns0. No display-unit conversion, allocation on normal query path or ownership transfer.
| [in] | xs | Borrowed initialized native geometry with kernel shape numbering and live applicable tables/LUTs; queried physical shape must be supported. |
| [in] | y | Finite nonnegative depth ft. |
| double openswmm::xsect::getYcircular | ( | double | alpha | ) |
Compute normalized circular depth from area ratio.
| [in] | alpha | Finite area/full-area ratio; <=0 returns0, >=1 returns1. |
| double openswmm::xsect::getYcrit | ( | const XSectParams & | xs, |
| double | q ) |
Query native critical depth from discharge through the shared host evaluator.
Nonpositive discharge/DUMMY returns0. Uses analytic,25-interval enumeration or Ridder solve; upper depth capped y_full and no separate root-failure status. No display-unit conversion, allocation on normal query path or ownership transfer.
| [in] | xs | Borrowed initialized native geometry with kernel shape numbering and live applicable tables/LUTs; queried physical shape must be supported. |
| [in] | q | Finite nonnegative discharge cfs; caller prevents q*q overflow. |
| double openswmm::xsect::getYofA | ( | const XSectParams & | xs, |
| double | a ) |
Query native depth from area through the shared host evaluator.
Nonpositive area returns0. Uses analytic inverses, direct Y tables or inversion of borrowed A tables; no universal above-full clamp. No display-unit conversion, allocation on normal query path or ownership transfer.
| [in] | xs | Borrowed initialized native geometry with kernel shape numbering and live applicable tables/LUTs; queried physical shape must be supported. |
| [in] | a | Finite nonnegative wetted area ft2. |
| const XsectEval & openswmm::xsect::hostEval | ( | ) |
Borrow the immutable host evaluator bound to process-lifetime tables.
Local-static first initialization binds hostTables; normal queries perform no evaluator allocation or state mutation.
| const XsectTables & openswmm::xsect::hostTables | ( | ) |
Borrow host pointers, lengths and inverse maps for every built-in geometry table.
Initialized once through thread-safe local static; does not copy/allocate the table sample arrays. Device code requires its own accessible bindings.
The host-bound table set and evaluator: hostTables() binds every pointer straight back to the xsect_tables:: arrays, so hostEval() reproduces the pre-extraction code exactly. A device consumer builds its own pair over device copies of the same arrays.
| double openswmm::xsect::invLookup | ( | double | y, |
| const double * | table, | ||
| int | n_items, | ||
| const LocateLut * | lut = nullptr ) |
Invert a borrowed normalized geometry table including the legacy declining top.
| [in] | y | Finite dependent table-unit value. |
| [in] | table | Readable n_items entries, monotone except the supported two-row declining top. |
| [in] | n_items | Logical count>=4. |
| [in] | lut | Optional live map built for the same unchanged table/search extent. |
| bool openswmm::xsect::isOpen | ( | int | type | ) |
Classify a kernel shape using the legacy open-section set.
| [in] | type | Kernel XSectShape ordinal, not model-storage enum. |
| int openswmm::xsect::locate | ( | double | y, |
| const double * | table, | ||
| int | n ) |
Find a lower bracket in a nondecreasing geometry table.
| [in] | y | Query in table units, endpoint held; NaN resolves index0. |
| [in] | table | Readable nondecreasing indices0..n. |
| [in] | n | Nonnegative inclusive last index, rather than entry count. |
|
inlinenoexcept |
Find a lower bracketing index in a nondecreasing table.
Interior equal values follow the bisection comparison; all-equal/bottom endpoint returns0. No interpolation or table validation.
| [in] | y | Query in table units; endpoint queries clamp, NaN resolves to0. |
| [in] | table | Borrowed ascending/nondecreasing table with readable indices0..jLast; lifetime covers query. |
| [in] | jLast | Nonnegative inclusive final search index; caller prevents midpoint integer overflow. |
|
inlinenoexcept |
Find the same lower bracket using a prebuilt bucket map.
Does not validate map identity/extent; stale maps can produce incorrect or unsafe brackets.
| [in] | y | Query in table units; NaN/below-first returns0 and above-last returns jLast. |
| [in] | table | Borrowed ascending/nondecreasing table with readable indices0..jLast; lifetime covers query. |
| [in] | jLast | Nonnegative inclusive final search index; caller prevents midpoint integer overflow. |
| [in] | L | Borrowed enabled map built from this unchanged table and extent; interior mapped expression must fit int. |
|
inlinenoexcept |
Use a matching enabled bucket map or fall back to plain bisection.
| [in] | y | Query in table units; same value-domain requirements as selected implementation. |
| [in] | table | Borrowed ascending/nondecreasing table with readable indices0..jLast; lifetime covers query. |
| [in] | jLast | Nonnegative inclusive final search index; caller prevents midpoint integer overflow. |
| [in] | L | Optional borrowed map; scale>0 and matching j_last select it. Caller ensures table identity/content still match. |
| double openswmm::xsect::lookup | ( | double | x, |
| const double * | table, | ||
| int | n_items ) |
Interpolate a borrowed equally spaced normalized geometry table.
| [in] | x | Normalized coordinate; nonpositive/NaN selects first, >1 selects final entry. |
| [in] | table | Readable n_items-entry table, n_items>=4 for low-end quadratic lookahead. |
| [in] | n_items | Logical count>=4. |
|
inlinenoexcept |
Interpolate a normalized geometry table with the legacy arithmetic grouping.
Uses exact division and a positive low-end quadratic refinement. No negative-input clamp; caller must prevent unsafe indices/nonfinite casts. No allocation or ownership transfer; bitwise legacy agreement requires compatible FP/compiler settings.
| [in] | x | Finite nonnegative normalized coordinate, normally0..1; x/(1/(n-1)) must fit int. Values>=1 return final entry. |
| [in] | t | Borrowed readable n-entry equally spaced table on0..1; n>=4 for low-end quadratic lookahead. |
| [in] | n | Logical entry count>=4; no local validation. |
|
inlinenoexcept |
Interpolate normalized geometry using reciprocal multiplication and endpoint clamps.
Faster arithmetic can differ by ULPs from lookup_exact; no NaN guard before integer cast. No allocation or table mutation.
| [in] | x | Non-NaN normalized coordinate; values below0/above1, including infinities, clamp to endpoints. |
| [in] | t | Borrowed readable n-entry equally spaced table; n>=4 for quadratic lookahead. |
| [in] | n | Logical count>=4, caller-validated. |
|
inlinenoexcept |
Map a value to one of64 locate-acceleration buckets.
Clamping occurs after the integer cast; it does not make nonfinite or enormous inputs safe. No table lookup or mutation.
| [in] | L | Borrowed initialized map; scale positive and mapped query expression representable as int. |
| [in] | y | Value in the same units as L.t0; (y-t0)*scale must be finite/int-representable. |
|
inlinenoexcept |
Normalize a depth and dispatch the build-selected table interpolation.
| [in] | depth | Depth in consistent native length units, finite and safely normalizable. |
| [in] | param | Default full-depth denominator or FAST_LOOKUP reciprocal, matching norm_x build convention. |
| [in] | t | Borrowed readable normalized geometry table with n>=4 entries. |
| [in] | n | Logical entry count>=4. |
|
inlinenoexcept |
Normalize a depth with the selected exact or fast-lookup operand convention.
The fast branch does not catch NaN multiplication. Supplying a full depth to a reciprocal build (or reverse) silently misnormalizes; no units or finiteness validation.
| [in] | depth | Depth in the same length convention as full depth; finite inputs supplied by caller. |
| [in] | param | Default build: positive full depth; FAST_LOOKUP build: its precomputed reciprocal. |
| int openswmm::xsect::setParams | ( | XSectParams & | xs, |
| int | type, | ||
| const double | p[], | ||
| double | ucf ) |
Derive native full-flow geometry from authored shape dimensions.
Trapezoid uses p1 bottom width,p2/p3 side slopes; triangle/parabola/power use height/width with power exponent p2. Standard ellipse/arch code selects inch-based catalogue dimensions; otherwise custom dimensions apply. Arc radius is raised to at least width/2. FORCE_MAIN retains p1 as C/roughness without conversion and uses R^0.63 full factor. This is not complete validation: many nonpositive/nonfinite dimensions can return0, and -1 can leave partial fields changed.
| [in,out] | xs | Borrowed destination; type is assigned first, applicable geometry fields change incrementally and unrelated fields/pointers are retained. |
| [in] | type | Kernel XSectShape ordinal. Table-backed IRREGULAR/CUSTOM/STREET, DUMMY and unknown codes change only type and return0. |
| [in] | p | Readable four-double shape parameter span. Slot0 is height/diameter or standard-size code; slot1 width, sediment depth or FORCE_MAIN roughness; slot2 exponent, arc radius, excluded-bank count or standard ellipse/arch code; slot3 second trapezoid side slope. Caller supplies shape-valid finite values. |
| [in] | ucf | Positive finite authored-length-units per native ft; length slots divide by it, dimensionless slopes/codes/exponents remain unscaled. |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |