34#ifndef OPENSWMM_XSECT_BATCH_HPP
35#define OPENSWMM_XSECT_BATCH_HPP
37#ifndef OPENSWMM_RESTRICT
39# define OPENSWMM_RESTRICT __restrict
41# define OPENSWMM_RESTRICT __restrict__
53struct SimulationContext;
131double lookup(
double x,
const double* table,
int n_items);
132double invLookup(
double y,
const double* table,
int n_items);
133int locate(
double y,
const double* table,
int n);
253 void computeAreas(
const double* depths,
double* areas,
int n_links)
const;
262 void computeHydRad(
const double* depths,
double* hydrad,
int n_links)
const;
271 void computeWidths(
const double* depths,
double* widths,
int n_links)
const;
282 double* hydrad,
int n_links)
const;
290 const double* d1,
const double* d2,
const double* dm,
291 double* a1,
double* a2,
double* am,
292 double* hrad1,
double* hrad_mid,
int n_links)
const;
298 const double* d1,
const double* d2,
const double* dm,
299 double* w1,
double* w2,
double* wm,
int n_links)
const;
324 int numGroups()
const {
return static_cast<int>(groups_.size()); }
333 std::vector<ShapeGroup> groups_;
340namespace xsect_batch {
#define OPENSWMM_RESTRICT
Definition XSectBatch.hpp:41
Shape-grouped cross-section manager for batch computation.
Definition XSectBatch.hpp:208
void computeAreas(const double *depths, double *areas, int n_links) const
Compute area for every link, reading depth from depths[link].
Definition XSectBatch.cpp:800
void computeWidths(const double *depths, double *widths, int n_links) const
Compute top width for every link.
Definition XSectBatch.cpp:1103
void computeAreaAndHydRad(const double *depths, double *areas, double *hydrad, int n_links) const
Fused area + hydraulic radius computation (single gather/scatter).
Definition XSectBatch.cpp:965
void build(const SimulationContext &ctx)
Build shape groups from SimulationContext link data.
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....
Definition XSectBatch.cpp:1174
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.
Definition XSectBatch.cpp:1209
const ShapeGroup & group(int i) const
Access a specific shape group.
Definition XSectBatch.hpp:327
void computeDepthsFromArea(const double *areas, double *depths, int n_links) const
Compute depth from area for every link (inverse).
Definition XSectBatch.cpp:1254
void computeHydRad(const double *depths, double *hydrad, int n_links) const
Compute hydraulic radius for every link.
Definition XSectBatch.cpp:892
void computeSectionFactors(const double *areas, double *sfact, int n_links) const
Compute section factor for every link (from area, not depth).
Definition XSectBatch.cpp:1235
void attachTransectTables(const SimulationContext &ctx)
Attach transect tables to the IRREGULAR shape group.
Definition XSectBatch.cpp:120
int numGroups() const
Number of non-empty shape groups.
Definition XSectBatch.hpp:324
const ShapeGroup * findGroup(XSectShape shape) const
Find the group for a given shape (returns nullptr if no links have that shape).
Definition XSectBatch.cpp:153
void area_trapezoidal(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT y_bot, const double *OPENSWMM_RESTRICT s_bot, double *OPENSWMM_RESTRICT area, int count)
Batch area for TRAPEZOIDAL: area = (y_bot + s_bot * depth) * depth.
Definition XSectBatch.cpp:207
void width_circular(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT inv_y_full, const double *OPENSWMM_RESTRICT w_max, double *OPENSWMM_RESTRICT width, int count)
Definition XSectBatch.cpp:454
void hydrad_tabulated(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT inv_y_full, const double *OPENSWMM_RESTRICT r_full, const double *table, int table_size, double *OPENSWMM_RESTRICT hydrad, int count)
Definition XSectBatch.cpp:420
void hydrad_circular(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT inv_y_full, const double *OPENSWMM_RESTRICT r_full, double *OPENSWMM_RESTRICT hydrad, int count)
Definition XSectBatch.cpp:348
void width_rect(const double *OPENSWMM_RESTRICT w_max, double *OPENSWMM_RESTRICT width, int count)
Definition XSectBatch.cpp:505
void hydrad_triangular(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT s_bot, const double *OPENSWMM_RESTRICT r_bot, double *OPENSWMM_RESTRICT hydrad, int count)
Definition XSectBatch.cpp:391
void hydrad_trapezoidal(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT y_bot, const double *OPENSWMM_RESTRICT s_bot, const double *OPENSWMM_RESTRICT r_bot, double *OPENSWMM_RESTRICT hydrad, int count)
Definition XSectBatch.cpp:372
void width_triangular(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT s_bot, double *OPENSWMM_RESTRICT width, int count)
Definition XSectBatch.cpp:492
void hydrad_rect(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT w_max, double *OPENSWMM_RESTRICT hydrad, int count)
Definition XSectBatch.cpp:405
void area_inv_tabulated(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT inv_y_full, const double *OPENSWMM_RESTRICT a_full, const double *table, int table_size, double *OPENSWMM_RESTRICT area, int count)
Batch area for shapes using invLookup (gothic, catenary, semielliptical, semicircular).
Definition XSectBatch.cpp:294
void area_powerfunc(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT s_bot, const double *OPENSWMM_RESTRICT r_bot, double *OPENSWMM_RESTRICT area, int count)
Batch area for POWERFUNC: area = r_bot * depth^(s_bot+1).
Definition XSectBatch.cpp:251
void area_circular(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT inv_y_full, const double *OPENSWMM_RESTRICT a_full, double *OPENSWMM_RESTRICT area, int count)
Batch area for CIRCULAR/FORCE_MAIN — lookup table interpolation.
Definition XSectBatch.cpp:166
void area_rect(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT w_max, double *OPENSWMM_RESTRICT area, int count)
Batch area for RECT_CLOSED / RECT_OPEN: area = depth * w_max.
Definition XSectBatch.cpp:197
void width_tabulated(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT inv_y_full, const double *OPENSWMM_RESTRICT w_max, const double *table, int table_size, double *OPENSWMM_RESTRICT width, int count)
Definition XSectBatch.cpp:515
void width_trapezoidal(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT y_bot, const double *OPENSWMM_RESTRICT s_bot, double *OPENSWMM_RESTRICT width, int count)
Definition XSectBatch.cpp:478
void area_tabulated(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT inv_y_full, const double *OPENSWMM_RESTRICT a_full, const double *table, int table_size, double *OPENSWMM_RESTRICT area, int count)
Batch area for any tabulated shape (egg, horseshoe, arch, ellipse, etc.).
Definition XSectBatch.cpp:264
void area_triangular(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT s_bot, double *OPENSWMM_RESTRICT area, int count)
Batch area for TRIANGULAR: area = s_bot * depth^2.
Definition XSectBatch.cpp:222
void area_parabolic(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT r_bot, double *OPENSWMM_RESTRICT area, int count)
Batch area for PARABOLIC: area = (4/3) * r_bot * depth^(3/2).
Definition XSectBatch.cpp:236
double getAmax(const XSectParams &xs)
Definition XSection.cpp:796
double getdSdA(const XSectParams &xs, double a)
Definition XSection.cpp:760
double lookup(double x, const double *table, int n_items)
Definition XSection.cpp:42
double invLookup(double y, const double *table, int n_items)
Definition XSection.cpp:63
double getYofA(const XSectParams &xs, double a)
Definition XSection.cpp:639
double getScircular(double alpha)
Definition XSection.cpp:101
double getWofY(const XSectParams &xs, double y)
Definition XSection.cpp:517
double getSofA(const XSectParams &xs, double a)
Definition XSection.cpp:701
double getRofY(const XSectParams &xs, double y)
Definition XSection.cpp:583
double getYcrit(const XSectParams &xs, double q)
Definition XSection.cpp:806
int locate(double y, const double *table, int n)
Definition XSection.cpp:32
double getAofY(const XSectParams &xs, double y)
Definition XSection.cpp:455
double getAofS(const XSectParams &xs, double s_factor)
Definition XSection.cpp:773
bool isOpen(int type)
Definition XSection.cpp:903
int setParams(XSectParams &xs, int type, const double p[], double ucf)
Definition XSection.cpp:921
double getRofA(const XSectParams &xs, double a)
Definition XSection.cpp:750
double getYcircular(double alpha)
Definition XSection.cpp:95
Definition NodeCoupling.cpp:15
XSectShape
Definition XSectBatch.hpp:59
@ FORCE_MAIN
Circular force main (Hazen-Williams or D-W)
@ STREET_XSECT
Street cross-section.
@ IRREGULAR
User-supplied shape curve.
@ HORIZ_ELLIPSE
Horizontal elliptical pipe.
@ VERT_ELLIPSE
Vertical elliptical pipe.
@ CUSTOM
Shape from CURVE_SHAPE table.
@ RECT_ROUND
Rectangular-round bottom.
@ DUMMY
Dummy (no geometry)
@ RECT_TRIANG
Rectangular-triangular bottom.
double * y
Definition odesolve.c:28
SoA parameter block for all links of one cross-section shape.
Definition XSectBatch.hpp:153
std::vector< double > r_full
Hyd. radius at full (ft)
Definition XSectBatch.hpp:163
std::vector< const double * > hrad_tables
Per-link hyd-rad table.
Definition XSectBatch.hpp:179
std::vector< double > w_max
Max width (ft)
Definition XSectBatch.hpp:165
std::vector< double > buf_r
Scatter buffer for results.
Definition XSectBatch.hpp:185
std::vector< double > buf_r2
Second scatter buffer (for fused ops)
Definition XSectBatch.hpp:186
std::vector< double > inv_y_full
1.0 / y_full (or 0 if y_full==0)
Definition XSectBatch.hpp:168
XSectShape shape
Definition XSectBatch.hpp:154
int transect_tbl_size
Table size (same for all)
Definition XSectBatch.hpp:181
std::vector< double > r_bot
Definition XSectBatch.hpp:174
std::vector< double > s_bot
Definition XSectBatch.hpp:173
std::vector< double > y_bot
Definition XSectBatch.hpp:171
void resize(int n)
Resize all arrays to n elements.
Definition XSectBatch.cpp:48
std::vector< const double * > area_tables
Per-link area table.
Definition XSectBatch.hpp:178
std::vector< const double * > width_tables
Per-link width table.
Definition XSectBatch.hpp:180
std::vector< int > link_idx
link_idx[i] = index in SimulationContext
Definition XSectBatch.hpp:158
std::vector< double > buf_d
Gather buffer for depths.
Definition XSectBatch.hpp:184
int count
Definition XSectBatch.hpp:155
std::vector< double > a_bot
Definition XSectBatch.hpp:172
std::vector< double > a_full
Full area (ft2)
Definition XSectBatch.hpp:162
std::vector< double > s_full
Section factor at full.
Definition XSectBatch.hpp:164
std::vector< double > y_full
Full depth (ft)
Definition XSectBatch.hpp:161
Central, reentrant simulation context.
Definition SimulationContext.hpp:274
Definition XSectBatch.hpp:92
double s_full
Section factor when full (ft^4/3)
Definition XSectBatch.hpp:102
double s_bot
Slope of bottom section / exponent.
Definition XSectBatch.hpp:107
int culvert_code
Definition XSectBatch.hpp:94
int transect
Definition XSectBatch.hpp:95
double a_full
Area when full (ft2)
Definition XSectBatch.hpp:100
double r_bot
Radius of bottom section / coefficient.
Definition XSectBatch.hpp:108
double s_max
Section factor at max flow (ft^4/3)
Definition XSectBatch.hpp:103
int type
Definition XSectBatch.hpp:93
double a_bot
Area of bottom section.
Definition XSectBatch.hpp:106
double w_max
Width at widest point (ft)
Definition XSectBatch.hpp:98
double yw_max
Depth at widest point (ft)
Definition XSectBatch.hpp:99
double y_bot
Depth of bottom section / fill depth.
Definition XSectBatch.hpp:105
double y_full
Full depth (ft)
Definition XSectBatch.hpp:97
double r_full
Hydraulic radius when full (ft)
Definition XSectBatch.hpp:101