![]() |
OpenSWMM Engine
6.0.0-alpha.3
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.3)
|
Shape-grouped cross-section manager for batch computation. More...
#include <XSectBatch.hpp>
Public Member Functions | |
| void | build (const SimulationContext &ctx) |
| Build shape groups from SimulationContext link data. | |
| void | attachTransectTables (const SimulationContext &ctx) |
| Attach transect tables to the IRREGULAR shape group. | |
| void | build (const XSectParams *params, int n_links) |
| Build shape groups from an array of XSectParams. | |
| void | computeAreas (const double *depths, double *areas, int n_links) const |
Compute area for every link, reading depth from depths[link]. | |
| void | computeHydRad (const double *depths, double *hydrad, int n_links) const |
| Compute hydraulic radius for every link. | |
| void | computeWidths (const double *depths, double *widths, int n_links) const |
| Compute top width for every link. | |
| void | computeAreaAndHydRad (const double *depths, double *areas, double *hydrad, int n_links) const |
| Fused area + hydraulic radius computation (single gather/scatter). | |
| void | computeAreaHydRadTriple (const double *d1, const double *d2, const double *dm, double *a1, double *a2, double *am, double *hrad1, double *hrad_mid, int n_links) const |
| Fused triple: d1→(a1,hrad1), d2→a2, dm→(am,hrad_mid) in one pass over shape groups. Replaces three separate compute calls in STEP B / STEP D of computeLinkGeometry. | |
| void | computeWidthsTriple (const double *d1, const double *d2, const double *dm, double *w1, double *w2, double *wm, int n_links) const |
| Fused triple: d1→w1, d2→w2, dm→wm in one pass over shape groups. | |
| void | computeAreaHydRadTripleTeam (const double *d1, const double *d2, const double *dm, double *a1, double *a2, double *am, double *hrad1, double *hrad_mid, int n_links, int tid, int nthreads) const |
Team-callable triple kernels: thread tid of nthreads processes only its static slice of every shape group. | |
| void | computeWidthsTripleTeam (const double *d1, const double *d2, const double *dm, double *w1, double *w2, double *wm, int n_links, int tid, int nthreads) const |
| void | setBypassMask (const std::uint8_t *bypassed_by_link) const |
| Restrict the triple kernels to non-bypassed links for the current Picard iteration. | |
| void | computeSectionFactors (const double *areas, double *sfact, int n_links) const |
| Compute section factor for every link (from area, not depth). | |
| void | computeDepthsFromArea (const double *areas, double *depths, int n_links) const |
| Compute depth from area for every link (inverse). | |
| int | numGroups () const |
| Number of non-empty shape groups. | |
| const ShapeGroup & | group (int i) const |
| Access a specific shape group. | |
| const ShapeGroup * | findGroup (XSectShape shape) const |
| Find the group for a given shape (returns nullptr if no links have that shape). | |
Shape-grouped cross-section manager for batch computation.
Call build() once after the model is loaded/built. This sorts links by shape type and builds contiguous SoA parameter blocks. Then use computeAreas(), computeHydRad(), computeWidths() in the routing hot loop — each iterates over shape groups and calls the shape-specific vectorised kernel.
Results are written directly into the caller's global arrays (indexed by link) using the scatter index link_idx.
| void openswmm::XSectGroups::attachTransectTables | ( | const SimulationContext & | ctx | ) |
Attach transect tables to the IRREGULAR shape group.
Must be called after build() when IRREGULAR shapes exist. Populates per-link area/hrad/width table pointers from the precomputed transect tables in the context.
| ctx | SimulationContext with transect_tables populated. |
| void openswmm::XSectGroups::build | ( | const SimulationContext & | ctx | ) |
Build shape groups from SimulationContext link data.
Scans all links, groups them by xsect shape, and copies the geometry parameters into contiguous SoA arrays. Only shapes that have at least one link get a group.
| ctx | SimulationContext (must have links populated). |
| void openswmm::XSectGroups::build | ( | const XSectParams * | params, |
| int | n_links ) |
Build shape groups from an array of XSectParams.
Alternative to build(ctx) — useful for testing.
| params | Array of per-link XSectParams. |
| n_links | Number of links. |
| void openswmm::XSectGroups::computeAreaAndHydRad | ( | const double * | depths, |
| double * | areas, | ||
| double * | hydrad, | ||
| int | n_links ) const |
Fused area + hydraulic radius computation (single gather/scatter).
| depths | [in] Global depth array. |
| areas | [out] Global area array. |
| hydrad | [out] Global hydraulic radius array. |
| n_links | Total number of links. |
| void openswmm::XSectGroups::computeAreaHydRadTriple | ( | const double * | d1, |
| const double * | d2, | ||
| const double * | dm, | ||
| double * | a1, | ||
| double * | a2, | ||
| double * | am, | ||
| double * | hrad1, | ||
| double * | hrad_mid, | ||
| int | n_links ) const |
Fused triple: d1→(a1,hrad1), d2→a2, dm→(am,hrad_mid) in one pass over shape groups. Replaces three separate compute calls in STEP B / STEP D of computeLinkGeometry.
| void openswmm::XSectGroups::computeAreaHydRadTripleTeam | ( | const double * | d1, |
| const double * | d2, | ||
| const double * | dm, | ||
| double * | a1, | ||
| double * | a2, | ||
| double * | am, | ||
| double * | hrad1, | ||
| double * | hrad_mid, | ||
| int | n_links, | ||
| int | tid, | ||
| int | nthreads ) const |
Team-callable triple kernels: thread tid of nthreads processes only its static slice of every shape group.
Call from EVERY thread of an OpenMP team (typically the persistent DW Picard team) with that thread's id/team size; the caller owns the barrier that orders the outputs for consumers. Slices are disjoint (single-producer per element, including the shared group-local scratch buffers, which are sliced on cache-line boundaries), and per-element results are position-independent — so results are bit-identical to the serial triple at any thread count. Honors the bypass mask exactly like the serial forms. (tid=0, nthreads=1) IS the serial form.
| void openswmm::XSectGroups::computeAreas | ( | const double * | depths, |
| double * | areas, | ||
| int | n_links ) const |
Compute area for every link, reading depth from depths[link].
| depths | [in] Global depth array (indexed by link). |
| areas | [out] Global area array (indexed by link). |
| n_links | Total number of links. |
| void openswmm::XSectGroups::computeDepthsFromArea | ( | const double * | areas, |
| double * | depths, | ||
| int | n_links ) const |
Compute depth from area for every link (inverse).
| areas | [in] Global area array. |
| depths | [out] Global depth array. |
| n_links | Total number of links. |
| void openswmm::XSectGroups::computeHydRad | ( | const double * | depths, |
| double * | hydrad, | ||
| int | n_links ) const |
Compute hydraulic radius for every link.
| depths | [in] Global depth array. |
| hydrad | [out] Global hydraulic radius array. |
| n_links | Total number of links. |
| void openswmm::XSectGroups::computeSectionFactors | ( | const double * | areas, |
| double * | sfact, | ||
| int | n_links ) const |
Compute section factor for every link (from area, not depth).
| areas | [in] Global area array. |
| sfact | [out] Global section factor array. |
| n_links | Total number of links. |
| void openswmm::XSectGroups::computeWidths | ( | const double * | depths, |
| double * | widths, | ||
| int | n_links ) const |
Compute top width for every link.
| depths | [in] Global depth array. |
| widths | [out] Global top width array. |
| n_links | Total number of links. |
| void openswmm::XSectGroups::computeWidthsTriple | ( | const double * | d1, |
| const double * | d2, | ||
| const double * | dm, | ||
| double * | w1, | ||
| double * | w2, | ||
| double * | wm, | ||
| int | n_links ) const |
Fused triple: d1→w1, d2→w2, dm→wm in one pass over shape groups.
| void openswmm::XSectGroups::computeWidthsTripleTeam | ( | const double * | d1, |
| const double * | d2, | ||
| const double * | dm, | ||
| double * | w1, | ||
| double * | w2, | ||
| double * | wm, | ||
| int | n_links, | ||
| int | tid, | ||
| int | nthreads ) const |
| const ShapeGroup * openswmm::XSectGroups::findGroup | ( | XSectShape | shape | ) | const |
Find the group for a given shape (returns nullptr if no links have that shape).
|
inline |
Access a specific shape group.
|
inline |
Number of non-empty shape groups.
| void openswmm::XSectGroups::setBypassMask | ( | const std::uint8_t * | bypassed_by_link | ) | const |
Restrict the triple kernels to non-bypassed links for the current Picard iteration.
Legacy findLinkFlows skips a "bypassed" link (both end nodes converged) entirely, leaving its geometry at the previously computed values. The batch triple kernels instead recompute every link from its (unchanged) stored depths — producing bit-identical values, i.e. pure waste that grows with the bypass fraction (Bellinge averages ~9 Picard iterations per step, so most kernel invocations run with a mostly-converged network). This packs each shape group down to its active links so the kernels and gather/scatter touch only those. Bypassed links keep their stored outputs, exactly as legacy.
Pass nullptr to clear (all links active, zero overhead). The mask only affects computeWidthsTriple and computeAreaHydRadTriple; all other compute* methods are init/reporting-path and stay unmasked.
| bypassed_by_link | Per-link flags indexed by GLOBAL link index (1 = bypassed/skip), or nullptr for all-active. |