OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm::XSectGroups Class Reference

Shape-grouped cross-section manager for batch computation. More...

#include <XSectBatch.hpp>

Collaboration diagram for openswmm::XSectGroups:

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.
 

Detailed Description

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.

Member Function Documentation

◆ attachTransectTables()

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.

Parameters
[in]ctxBorrowed coherent link curve indices and completed transect_tables; their vector elements must remain unmoved/live throughout query use.

◆ build() [1/2]

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.

Parameters
[in]ctxBorrowed model context described by this interface declaration.

◆ build() [2/2]

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.

Parameters
[in]paramsReadable n_links-entry parameter span; NULL permitted when n_links<=0. Kernel type codes1..25 group, DUMMY/unknown skip.
[in]n_linksNonnegative link count; negative currently clears groups and performs no input reads.

◆ computeAreaAndHydRad()

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.

Parameters
[in]depthsReadable global depth ft span covering every grouped link index.
[out]areasWritable global area ft2 span; ungrouped/DUMMY entries are not initialized.
[out]hydradWritable global radius ft span; ungrouped/DUMMY entries are not initialized.
[in]n_linksHistorical total count, currently ignored; does not enforce buffer bounds.

◆ computeAreaHydRadTriple()

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.

Parameters
[in]d1Readable global link-depth span in ft; every active grouped index must be in range.
[in]d2Readable global link-depth span in ft; every active grouped index must be in range.
[in]dmReadable global link-depth span in ft; every active grouped index must be in range.
[out]a1Writable global link span: ft2 area for d1; bypassed/ungrouped outputs are preserved.
[out]a2Writable global link span: ft2 area for d2; bypassed/ungrouped outputs are preserved.
[out]amWritable global link span: ft2 area for dm; bypassed/ungrouped outputs are preserved.
[out]hrad1Writable global link span: ft radius for d1; bypassed/ungrouped outputs are preserved.
[out]hrad_midWritable global link span: ft radius for dm; bypassed/ungrouped outputs are preserved.
[in]n_linksHistorical count argument; currently ignored, so spans must cover all stored global group indices regardless of this value.
Here is the call graph for this function:

◆ computeAreaHydRadTripleTeam()

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.

Parameters
[in]d1Readable global link-depth span in ft; every active grouped index must be in range.
[in]d2Readable global link-depth span in ft; every active grouped index must be in range.
[in]dmReadable global link-depth span in ft; every active grouped index must be in range.
[out]a1Writable global link span: ft2 area for d1; bypassed/ungrouped outputs are preserved.
[out]a2Writable global link span: ft2 area for d2; bypassed/ungrouped outputs are preserved.
[out]amWritable global link span: ft2 area for dm; bypassed/ungrouped outputs are preserved.
[out]hrad1Writable global link span: ft radius for d1; bypassed/ungrouped outputs are preserved.
[out]hrad_midWritable global link span: ft radius for dm; bypassed/ungrouped outputs are preserved.
[in]n_linksHistorical count argument; currently ignored, so spans must cover all stored global group indices regardless of this value.
[in]tidThis worker index,0<=tid<effective nthreads; caller validates.
[in]nthreadsTeam size; values<1 become1. Caller invokes every worker and owns completion barrier.
Here is the caller graph for this function:

◆ computeAreas()

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.

Parameters
[in]depthsReadable global depth ft span covering every grouped link index.
[out]areasWritable global area ft2 span; ungrouped/DUMMY entries are not initialized.
[in]n_linksHistorical total count, currently ignored; does not enforce buffer bounds.

◆ computeDepthsFromArea()

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.

Parameters
[in]areasReadable global area ft2 span covering every grouped link index.
[out]depthsWritable global depth ft span; ungrouped/DUMMY entries are not initialized.
[in]n_linksHistorical total count, currently ignored; does not enforce buffer bounds.
Here is the call graph for this function:

◆ computeHydRad()

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.

Parameters
[in]depthsReadable global depth ft span covering every grouped link index.
[out]hydradWritable global radius ft span; ungrouped/DUMMY entries are not initialized.
[in]n_linksHistorical total count, currently ignored; does not enforce buffer bounds.

◆ computeSectionFactors()

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.

Parameters
[in]areasReadable global area ft2 span covering every grouped link index.
[out]sfactWritable global native section factor span; ungrouped/DUMMY entries are not initialized.
[in]n_linksHistorical total count, currently ignored; does not enforce buffer bounds.
Here is the call graph for this function:

◆ computeWidths()

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.

Parameters
[in]depthsReadable global depth ft span covering every grouped link index.
[out]widthsWritable global width ft span; ungrouped/DUMMY entries are not initialized.
[in]n_linksHistorical total count, currently ignored; does not enforce buffer bounds.

◆ computeWidthsTriple()

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.

Parameters
[in]d1Readable global link-depth span in ft; every active grouped index must be in range.
[in]d2Readable global link-depth span in ft; every active grouped index must be in range.
[in]dmReadable global link-depth span in ft; every active grouped index must be in range.
[out]w1Writable global top-width span in ft for d1; bypassed/ungrouped outputs preserved.
[out]w2Writable global top-width span in ft for d2; bypassed/ungrouped outputs preserved.
[out]wmWritable global top-width span in ft for dm; bypassed/ungrouped outputs preserved.
[in]n_linksHistorical count argument; currently ignored, so spans must cover all stored global group indices regardless of this value.
Here is the call graph for this function:

◆ computeWidthsTripleTeam()

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.

Parameters
[in]d1Readable global link-depth span in ft; every active grouped index must be in range.
[in]d2Readable global link-depth span in ft; every active grouped index must be in range.
[in]dmReadable global link-depth span in ft; every active grouped index must be in range.
[out]w1Writable global top-width span in ft for d1; bypassed/ungrouped outputs preserved.
[out]w2Writable global top-width span in ft for d2; bypassed/ungrouped outputs preserved.
[out]wmWritable global top-width span in ft for dm; bypassed/ungrouped outputs preserved.
[in]n_linksHistorical count argument; currently ignored, so spans must cover all stored global group indices regardless of this value.
[in]tidThis worker index,0<=tid<effective nthreads; caller validates.
[in]nthreadsTeam size; values<1 become1. Caller invokes every worker and owns completion barrier.
Here is the caller graph for this function:

◆ findGroup()

const ShapeGroup * openswmm::XSectGroups::findGroup ( XSectShape shape) const

Borrow the first group with the requested kernel shape.

Parameters
[in]shapeKernel enum; absent/unknown/DUMMY normally has no group.
Returns
Borrowed group pointer or NULL; invalidated by build/destruction.

◆ group()

const ShapeGroup & openswmm::XSectGroups::group ( int i) const
inline

Borrow one indexed shape group.

Parameters
[in]iZero-based index<numGroups(); unchecked.
Returns
Owned group reference, invalidated by build or vector changes; table data remains externally borrowed.

◆ numGroups()

int openswmm::XSectGroups::numGroups ( ) const
inline

Number of non-empty shape groups.

◆ setBypassMask()

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.

Parameters
bypassed_by_linkPer-link flags indexed by GLOBAL link index (1 = bypassed/skip), or nullptr for all-active.
Note
const: the mask is per-iteration scratch (mutable members), set through the same const XSectGroups* the solver computes with.

The documentation for this class was generated from the following files: