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);
227 void computeAreas(
const double* depths,
double* areas,
int n_links)
const;
236 void computeHydRad(
const double* depths,
double* hydrad,
int n_links)
const;
245 void computeWidths(
const double* depths,
double* widths,
int n_links)
const;
270 int numGroups()
const {
return static_cast<int>(groups_.size()); }
279 std::vector<ShapeGroup> groups_;
286namespace xsect_batch {
#define OPENSWMM_RESTRICT
Definition XSectBatch.hpp:41
Shape-grouped cross-section manager for batch computation.
Definition XSectBatch.hpp:193
void computeAreas(const double *depths, double *areas, int n_links) const
Compute area for every link, reading depth from depths[link].
Definition XSectBatch.cpp:612
void computeWidths(const double *depths, double *widths, int n_links) const
Compute top width for every link.
Definition XSectBatch.cpp:760
void build(const SimulationContext &ctx)
Build shape groups from SimulationContext link data.
const ShapeGroup & group(int i) const
Access a specific shape group.
Definition XSectBatch.hpp:273
void computeDepthsFromArea(const double *areas, double *depths, int n_links) const
Compute depth from area for every link (inverse).
Definition XSectBatch.cpp:840
void computeHydRad(const double *depths, double *hydrad, int n_links) const
Compute hydraulic radius for every link.
Definition XSectBatch.cpp:695
void computeSectionFactors(const double *areas, double *sfact, int n_links) const
Compute section factor for every link (from area, not depth).
Definition XSectBatch.cpp:821
int numGroups() const
Number of non-empty shape groups.
Definition XSectBatch.hpp:270
const ShapeGroup * findGroup(XSectShape shape) const
Find the group for a given shape (returns nullptr if no links have that shape).
Definition XSectBatch.cpp:101
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:165
void width_rect(const double *OPENSWMM_RESTRICT w_max, double *OPENSWMM_RESTRICT width, int count)
Definition XSectBatch.cpp:481
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:342
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:321
void width_triangular(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT s_bot, double *OPENSWMM_RESTRICT width, int count)
Definition XSectBatch.cpp:466
void hydrad_rect(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT w_max, double *OPENSWMM_RESTRICT hydrad, int count)
Definition XSectBatch.cpp:358
void hydrad_circular(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT y_full, const double *OPENSWMM_RESTRICT r_full, double *OPENSWMM_RESTRICT hydrad, int count)
Definition XSectBatch.cpp:284
void hydrad_tabulated(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT y_full, const double *OPENSWMM_RESTRICT r_full, const double *table, int table_size, double *OPENSWMM_RESTRICT hydrad, int count)
Definition XSectBatch.cpp:375
void width_circular(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT y_full, const double *OPENSWMM_RESTRICT w_max, double *OPENSWMM_RESTRICT width, int count)
Definition XSectBatch.cpp:416
void area_inv_tabulated(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT 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:261
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:211
void area_circular(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT 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:114
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:155
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:450
void width_tabulated(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT y_full, const double *OPENSWMM_RESTRICT w_max, const double *table, int table_size, double *OPENSWMM_RESTRICT width, int count)
Definition XSectBatch.cpp:491
void area_tabulated(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT 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:224
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:182
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:198
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 Controls.cpp:24
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.
@ 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< double > w_max
Max width (ft)
Definition XSectBatch.hpp:165
XSectShape shape
Definition XSectBatch.hpp:154
std::vector< double > r_bot
Definition XSectBatch.hpp:171
std::vector< double > s_bot
Definition XSectBatch.hpp:170
std::vector< double > y_bot
Definition XSectBatch.hpp:168
void resize(int n)
Resize all arrays to n elements.
Definition XSectBatch.cpp:35
std::vector< int > link_idx
link_idx[i] = index in SimulationContext
Definition XSectBatch.hpp:158
int count
Definition XSectBatch.hpp:155
std::vector< double > a_bot
Definition XSectBatch.hpp:169
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:141
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