![]() |
OpenSWMM Engine
6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
|
Shape-grouped cross-section manager for batch computation. More...
#include <XSectBatch.hpp>
Public Member Functions | |
| void | build (const SimulationContext &ctx) |
| Declare the context convenience overload for shape-group construction. | |
| void | attachTransectTables (const SimulationContext &ctx) |
| Attach borrowed profile tables to irregular, custom and street shape groups. | |
| void | build (const XSectParams *params, int n_links) |
| Replace shape groups from copied per-link native geometry. | |
| void | computeAreas (const double *depths, double *areas, int n_links) const |
| Compute grouped-link area ft2 in native units. | |
| void | computeHydRad (const double *depths, double *hydrad, int n_links) const |
| Compute grouped-link radius ft in native units. | |
| void | computeWidths (const double *depths, double *widths, int n_links) const |
| Compute grouped-link width ft in native units. | |
| void | computeAreaAndHydRad (const double *depths, double *areas, double *hydrad, int n_links) const |
| Compute grouped-link area ft2,radius ft in native units. | |
| 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 |
| Compute area/radius for three depth fields using one grouped pass. | |
| void | computeWidthsTriple (const double *d1, const double *d2, const double *dm, double *w1, double *w2, double *wm, int n_links) const |
| Compute width for three depth fields using one grouped pass. | |
| 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 |
| Compute area/radius for three depth fields on one caller-owned team slice. | |
| 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 |
| Compute width for three depth fields on one caller-owned team slice. | |
| 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 grouped-link native section factor in native units. | |
| void | computeDepthsFromArea (const double *areas, double *depths, int n_links) const |
| Compute grouped-link depth ft in native units. | |
| int | numGroups () const |
| Number of non-empty shape groups. | |
| const ShapeGroup & | group (int i) const |
| Borrow one indexed shape group. | |
| const ShapeGroup * | findGroup (XSectShape shape) const |
| Borrow the first group with the requested kernel shape. | |
Shape-grouped cross-section manager for batch computation.
Call build(params, n_links) 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 borrowed profile tables to irregular, custom and street shape groups.
Call after build. Clears packed/mask state, fills valid-index area/radius/width pointers and selected full dimensions, then stable-sorts each eligible group by transect index. Invalid indices retain existing/default pointer slots rather than diagnosing. Does not update every section-factor scalar; no ownership transfer. Allocation can leave partial attachment/permutation.
| [in] | ctx | Borrowed coherent link curve indices and completed transect_tables; their vector elements must remain unmoved/live throughout query use. |
| void openswmm::XSectGroups::build | ( | const SimulationContext & | ctx | ) |
Declare the context convenience overload for shape-group construction.
No definition of this overload is supplied in the current engine sources; calling it requires a separate implementation at link time. Use build(params,n_links), then attachTransectTables(ctx), in the implemented routing path.
| [in] | ctx | Borrowed model context described by this interface declaration. |
| void openswmm::XSectGroups::build | ( | const XSectParams * | params, |
| int | n_links ) |
Replace shape groups from copied per-link native geometry.
Clears prior groups/packed masks, orders groups by shape code and rows by link order, copies scalar parameters and positive-depth reciprocals. Does not copy optional transect pointers from params; attachTransectTables must supply them. No full geometry validation; allocation can leave partial construction and invalidates borrowed group references.
| [in] | params | Readable n_links-entry parameter span; NULL permitted when n_links<=0. Kernel type codes1..25 group, DUMMY/unknown skip. |
| [in] | n_links | Nonnegative link count; negative currently clears groups and performs no input reads. |
| void openswmm::XSectGroups::computeAreaAndHydRad | ( | const double * | depths, |
| double * | areas, | ||
| double * | hydrad, | ||
| int | n_links ) const |
Compute grouped-link area ft2,radius ft in native units.
Ignores the triple-only bypass mask. Mutable scratch makes simultaneous calls on one manager unsafe; source/destination spans must not overlap. Runs gather/kernel/scatter over built groups without per-call allocation; borrowed profile tables must remain live.
| [in] | depths | Readable global depth ft span covering every grouped link index. |
| [out] | areas | Writable global area ft2 span; ungrouped/DUMMY entries are not initialized. |
| [out] | hydrad | Writable global radius ft span; ungrouped/DUMMY entries are not initialized. |
| [in] | n_links | Historical total count, currently ignored; does not enforce buffer bounds. |
| 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 |
Compute area/radius for three depth fields using one grouped pass.
Uses mutable preallocated gather/scatter scratch; source/destination arrays must not overlap, and independent calls on one group manager must not run concurrently. Honors the current packed bypass mask. Serial wrapper runs worker0 of1; does not create an OpenMP team.
| [in] | d1 | Readable global link-depth span in ft; every active grouped index must be in range. |
| [in] | d2 | Readable global link-depth span in ft; every active grouped index must be in range. |
| [in] | dm | Readable global link-depth span in ft; every active grouped index must be in range. |
| [out] | a1 | Writable global link span: ft2 area for d1; bypassed/ungrouped outputs are preserved. |
| [out] | a2 | Writable global link span: ft2 area for d2; bypassed/ungrouped outputs are preserved. |
| [out] | am | Writable global link span: ft2 area for dm; bypassed/ungrouped outputs are preserved. |
| [out] | hrad1 | Writable global link span: ft radius for d1; bypassed/ungrouped outputs are preserved. |
| [out] | hrad_mid | Writable global link span: ft radius for dm; bypassed/ungrouped outputs are preserved. |
| [in] | n_links | Historical count argument; currently ignored, so spans must cover all stored global group indices regardless of this value. |
| 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 |
Compute area/radius for three depth fields on one caller-owned team slice.
Uses mutable preallocated gather/scatter scratch; source/destination arrays must not overlap, and independent calls on one group manager must not run concurrently. Honors the current packed bypass mask. Static cache-line-aligned slices are disjoint; every team member must use the same arrays/mask and wait before consumers read outputs.
| [in] | d1 | Readable global link-depth span in ft; every active grouped index must be in range. |
| [in] | d2 | Readable global link-depth span in ft; every active grouped index must be in range. |
| [in] | dm | Readable global link-depth span in ft; every active grouped index must be in range. |
| [out] | a1 | Writable global link span: ft2 area for d1; bypassed/ungrouped outputs are preserved. |
| [out] | a2 | Writable global link span: ft2 area for d2; bypassed/ungrouped outputs are preserved. |
| [out] | am | Writable global link span: ft2 area for dm; bypassed/ungrouped outputs are preserved. |
| [out] | hrad1 | Writable global link span: ft radius for d1; bypassed/ungrouped outputs are preserved. |
| [out] | hrad_mid | Writable global link span: ft radius for dm; bypassed/ungrouped outputs are preserved. |
| [in] | n_links | Historical count argument; currently ignored, so spans must cover all stored global group indices regardless of this value. |
| [in] | tid | This worker index,0<=tid<effective nthreads; caller validates. |
| [in] | nthreads | Team size; values<1 become1. Caller invokes every worker and owns completion barrier. |
| void openswmm::XSectGroups::computeAreas | ( | const double * | depths, |
| double * | areas, | ||
| int | n_links ) const |
Compute grouped-link area ft2 in native units.
Ignores the triple-only bypass mask. Mutable scratch makes simultaneous calls on one manager unsafe; source/destination spans must not overlap. Runs gather/kernel/scatter over built groups without per-call allocation; borrowed profile tables must remain live.
| [in] | depths | Readable global depth ft span covering every grouped link index. |
| [out] | areas | Writable global area ft2 span; ungrouped/DUMMY entries are not initialized. |
| [in] | n_links | Historical total count, currently ignored; does not enforce buffer bounds. |
| void openswmm::XSectGroups::computeDepthsFromArea | ( | const double * | areas, |
| double * | depths, | ||
| int | n_links ) const |
Compute grouped-link depth ft in native units.
Ignores the triple-only bypass mask. Mutable scratch makes simultaneous calls on one manager unsafe; source/destination spans must not overlap. Uses scalar paramsAt fallback, which omits optional profile pointers/s_max; this path does not reconstruct all table-backed/crown metadata.
| [in] | areas | Readable global area ft2 span covering every grouped link index. |
| [out] | depths | Writable global depth ft span; ungrouped/DUMMY entries are not initialized. |
| [in] | n_links | Historical total count, currently ignored; does not enforce buffer bounds. |
| void openswmm::XSectGroups::computeHydRad | ( | const double * | depths, |
| double * | hydrad, | ||
| int | n_links ) const |
Compute grouped-link radius ft in native units.
Ignores the triple-only bypass mask. Mutable scratch makes simultaneous calls on one manager unsafe; source/destination spans must not overlap. Runs gather/kernel/scatter over built groups without per-call allocation; borrowed profile tables must remain live.
| [in] | depths | Readable global depth ft span covering every grouped link index. |
| [out] | hydrad | Writable global radius ft span; ungrouped/DUMMY entries are not initialized. |
| [in] | n_links | Historical total count, currently ignored; does not enforce buffer bounds. |
| void openswmm::XSectGroups::computeSectionFactors | ( | const double * | areas, |
| double * | sfact, | ||
| int | n_links ) const |
Compute grouped-link native section factor in native units.
Ignores the triple-only bypass mask. Mutable scratch makes simultaneous calls on one manager unsafe; source/destination spans must not overlap. Uses scalar paramsAt fallback, which omits optional profile pointers/s_max; this path does not reconstruct all table-backed/crown metadata.
| [in] | areas | Readable global area ft2 span covering every grouped link index. |
| [out] | sfact | Writable global native section factor span; ungrouped/DUMMY entries are not initialized. |
| [in] | n_links | Historical total count, currently ignored; does not enforce buffer bounds. |
| void openswmm::XSectGroups::computeWidths | ( | const double * | depths, |
| double * | widths, | ||
| int | n_links ) const |
Compute grouped-link width ft in native units.
Ignores the triple-only bypass mask. Mutable scratch makes simultaneous calls on one manager unsafe; source/destination spans must not overlap. Runs gather/kernel/scatter over built groups without per-call allocation; borrowed profile tables must remain live.
| [in] | depths | Readable global depth ft span covering every grouped link index. |
| [out] | widths | Writable global width ft span; ungrouped/DUMMY entries are not initialized. |
| [in] | n_links | Historical total count, currently ignored; does not enforce buffer bounds. |
| void openswmm::XSectGroups::computeWidthsTriple | ( | const double * | d1, |
| const double * | d2, | ||
| const double * | dm, | ||
| double * | w1, | ||
| double * | w2, | ||
| double * | wm, | ||
| int | n_links ) const |
Compute width for three depth fields using one grouped pass.
Uses mutable preallocated gather/scatter scratch; source/destination arrays must not overlap, and independent calls on one group manager must not run concurrently. Honors the current packed bypass mask. Serial wrapper runs worker0 of1; does not create an OpenMP team.
| [in] | d1 | Readable global link-depth span in ft; every active grouped index must be in range. |
| [in] | d2 | Readable global link-depth span in ft; every active grouped index must be in range. |
| [in] | dm | Readable global link-depth span in ft; every active grouped index must be in range. |
| [out] | w1 | Writable global top-width span in ft for d1; bypassed/ungrouped outputs preserved. |
| [out] | w2 | Writable global top-width span in ft for d2; bypassed/ungrouped outputs preserved. |
| [out] | wm | Writable global top-width span in ft for dm; bypassed/ungrouped outputs preserved. |
| [in] | n_links | Historical count argument; currently ignored, so spans must cover all stored global group indices regardless of this value. |
| 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 |
Compute width for three depth fields on one caller-owned team slice.
Uses mutable preallocated gather/scatter scratch; source/destination arrays must not overlap, and independent calls on one group manager must not run concurrently. Honors the current packed bypass mask. Static cache-line-aligned slices are disjoint; every team member must use the same arrays/mask and wait before consumers read outputs.
| [in] | d1 | Readable global link-depth span in ft; every active grouped index must be in range. |
| [in] | d2 | Readable global link-depth span in ft; every active grouped index must be in range. |
| [in] | dm | Readable global link-depth span in ft; every active grouped index must be in range. |
| [out] | w1 | Writable global top-width span in ft for d1; bypassed/ungrouped outputs preserved. |
| [out] | w2 | Writable global top-width span in ft for d2; bypassed/ungrouped outputs preserved. |
| [out] | wm | Writable global top-width span in ft for dm; bypassed/ungrouped outputs preserved. |
| [in] | n_links | Historical count argument; currently ignored, so spans must cover all stored global group indices regardless of this value. |
| [in] | tid | This worker index,0<=tid<effective nthreads; caller validates. |
| [in] | nthreads | Team size; values<1 become1. Caller invokes every worker and owns completion barrier. |
| const ShapeGroup * openswmm::XSectGroups::findGroup | ( | XSectShape | shape | ) | const |
Borrow the first group with the requested kernel shape.
| [in] | shape | Kernel enum; absent/unknown/DUMMY normally has no group. |
|
inline |
Borrow one indexed shape group.
| [in] | i | Zero-based index<numGroups(); unchecked. |
|
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. |