OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
XSectBatch.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2//
3// Copyright 2026 Caleb Buahin
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
49
50#ifndef OPENSWMM_XSECT_BATCH_HPP
51#define OPENSWMM_XSECT_BATCH_HPP
52
53#ifndef OPENSWMM_RESTRICT
54#if defined(_MSC_VER)
55#define OPENSWMM_RESTRICT __restrict
56#else
57#define OPENSWMM_RESTRICT __restrict__
58#endif
59#endif
60
61#include <vector>
62#include <cstddef>
63#include <cstdint>
64#include <cmath>
65
66#include "XSectLookup.hpp"
67
68namespace openswmm {
69
70// Forward declaration
71struct SimulationContext;
72
73// ============================================================================
74// Cross-section shape codes (matches legacy enums.h XsectType)
75// ============================================================================
76
105
106// ============================================================================
107// Cross-section parameter struct (mirrors legacy TXsect)
108// ============================================================================
109
120 int type = 0;
122 int transect = -1;
123
124 double y_full = 0.0;
125 double w_max = 0.0;
126 double yw_max = 0.0;
127 double a_full = 0.0;
128 double r_full = 0.0;
129 double s_full = 0.0;
130 double s_max = 0.0;
131
132 double y_bot = 0.0;
133 double a_bot = 0.0;
134 double s_bot = 0.0;
135 double r_bot = 0.0;
136
137 // Tabulated geometry for IRREGULAR / CUSTOM / STREET_XSECT shapes, whose
138 // A/R/W vs depth come from a per-link transect table rather than a shared
139 // static table. These point into ctx.transect_tables (stable for the run)
140 // and stay null for every self-contained shape. Without them the
141 // context-free per-element accessors return 0 for irregular sections (so
142 // e.g. init-time getDepthFromFlow could not compute normal depth/storage).
143 const double* area_tbl = nullptr;
144 const double* hrad_tbl = nullptr;
145 const double* width_tbl = nullptr;
147
151 const xsect::LocateLut* area_lut = nullptr;
152};
153
154// ============================================================================
155// Per-element functions (xsect:: namespace)
156// ============================================================================
157
158namespace xsect {
159
172double getAofY(const XSectParams& xs, double y);
185double getRofY(const XSectParams& xs, double y);
198double getWofY(const XSectParams& xs, double y);
211double getYofA(const XSectParams& xs, double a);
224double getSofA(const XSectParams& xs, double a);
237double getRofA(const XSectParams& xs, double a);
251double getdSdA(const XSectParams& xs, double a);
265double getAofS(const XSectParams& xs, double s_factor);
275double getAmax(const XSectParams& xs);
288double getYcrit(const XSectParams& xs, double q);
297bool isOpen(int type);
320int setParams(XSectParams& xs, int type, const double p[], double ucf);
321
322// Lookup table helpers (exposed for batch kernels and testing)
332double lookup(double x, const double* table, int n_items);
342double invLookup(double y, const double* table, int n_items, const LocateLut* lut = nullptr);
351int locate(double y, const double* table, int n);
359double getYcircular(double alpha);
366double getScircular(double alpha);
367
368} // namespace xsect
369
370// ============================================================================
371// Shape group — contiguous SoA for all links sharing one shape type
372// ============================================================================
373
386 int count = 0;
387
388 // Mapping back to global link arrays
389 std::vector<int> link_idx;
390
391 // Geometry parameters (contiguous, aligned for SIMD)
392 std::vector<double> y_full;
393 std::vector<double> a_full;
394 std::vector<double> r_full;
395 std::vector<double> s_full;
396 std::vector<double> w_max;
397
398 // Pre-computed reciprocal of y_full (avoids per-element division in kernels)
399 std::vector<double> inv_y_full;
400
401 // Multi-purpose parameters (meaning depends on shape)
402 std::vector<double> y_bot;
403 std::vector<double> a_bot;
404 std::vector<double> s_bot;
405 std::vector<double> r_bot;
406
407 // Per-link transect table pointers (IRREGULAR shapes only)
408 // Each pointer → a normalized table of N_TRANSECT_TBL entries.
409 std::vector<const double*> area_tables;
410 std::vector<const double*> hrad_tables;
411 std::vector<const double*> width_tables;
413
414 // Pre-allocated working buffers (avoids per-call allocation in hot loop)
415 mutable std::vector<double> buf_d;
416 mutable std::vector<double> buf_r;
417 mutable std::vector<double> buf_r2;
418
428 void resize(int n);
429};
430
431// ============================================================================
432// XSectGroups — the shape-grouped index over all links
433// ============================================================================
434
448public:
458 void build(const SimulationContext& ctx);
459
473
487 void build(const XSectParams* params, int n_links);
488
489 // ========================================================================
490 // Batch compute — results scattered to global link arrays
491 // ========================================================================
492
504 void computeAreas(const double* depths, double* areas, int n_links) const;
505
517 void computeHydRad(const double* depths, double* hydrad, int n_links) const;
518
530 void computeWidths(const double* depths, double* widths, int n_links) const;
531
544 void computeAreaAndHydRad(const double* depths, double* areas, double* hydrad,
545 int n_links) const;
546
570 void computeAreaHydRadTriple(const double* d1, const double* d2, const double* dm, double* a1,
571 double* a2, double* am, double* hrad1, double* hrad_mid,
572 int n_links) const;
573
590 void computeWidthsTriple(const double* d1, const double* d2, const double* dm, double* w1,
591 double* w2, double* wm, int n_links) const;
592
620 void computeAreaHydRadTripleTeam(const double* d1, const double* d2, const double* dm,
621 double* a1, double* a2, double* am, double* hrad1,
622 double* hrad_mid, int n_links, int tid, int nthreads) const;
623
644 void computeWidthsTripleTeam(const double* d1, const double* d2, const double* dm, double* w1,
645 double* w2, double* wm, int n_links, int tid, int nthreads) const;
646
673 void setBypassMask(const std::uint8_t* bypassed_by_link) const;
674
687 void computeSectionFactors(const double* areas, double* sfact, int n_links) const;
688
700 void computeDepthsFromArea(const double* areas, double* depths, int n_links) const;
701
702 // ========================================================================
703 // Accessors
704 // ========================================================================
705
707 int numGroups() const { return static_cast<int>(groups_.size()); }
708
716 const ShapeGroup& group(int i) const { return groups_[i]; }
717
724 const ShapeGroup* findGroup(XSectShape shape) const;
725
726private:
727 std::vector<ShapeGroup> groups_;
728
729 // Per-iteration bypass-mask state (see setBypassMask). packed_groups_[gi]
730 // is a packed view of groups_[gi] holding only the active links; it reuses
731 // the ShapeGroup layout so the gather/kernel/scatter path runs unchanged.
732 // packed_count_[gi]: kMaskFullGroup → no link in the group is bypassed
733 // (use the original group directly, no packing was done); 0..count →
734 // number of active links in the packed view. All mutable because the
735 // mask is per-Picard-iteration scratch while the compute API is const.
736 static constexpr int kMaskFullGroup = -1;
737 mutable std::vector<ShapeGroup> packed_groups_;
738 mutable std::vector<int> packed_count_;
739 mutable bool mask_active_ = false;
740
751 const ShapeGroup* maskedGroup(std::size_t gi) const {
752 const ShapeGroup* gp = &groups_[gi];
753 if (mask_active_) {
754 const int na = packed_count_[gi];
755 if (na == 0)
756 return nullptr;
757 if (na != kMaskFullGroup)
758 gp = &packed_groups_[gi];
759 }
760 return gp;
761 }
762};
763
764// ============================================================================
765// Shape-specific batch kernels (called by XSectGroups, also usable directly)
766// ============================================================================
767
768namespace xsect_batch {
769
787void area_circular(const double* OPENSWMM_RESTRICT depth, const double* OPENSWMM_RESTRICT y_full,
788 const double* OPENSWMM_RESTRICT a_full, double* OPENSWMM_RESTRICT area,
789 int count);
790
805void area_rect(const double* OPENSWMM_RESTRICT depth, const double* OPENSWMM_RESTRICT w_max,
806 double* OPENSWMM_RESTRICT area, int count);
807
823void area_trapezoidal(const double* OPENSWMM_RESTRICT depth, const double* OPENSWMM_RESTRICT y_bot,
824 const double* OPENSWMM_RESTRICT s_bot, double* OPENSWMM_RESTRICT area,
825 int count);
826
841void area_triangular(const double* OPENSWMM_RESTRICT depth, const double* OPENSWMM_RESTRICT s_bot,
842 double* OPENSWMM_RESTRICT area, int count);
843
858void area_parabolic(const double* OPENSWMM_RESTRICT depth, const double* OPENSWMM_RESTRICT r_bot,
859 double* OPENSWMM_RESTRICT area, int count);
860
876void area_powerfunc(const double* OPENSWMM_RESTRICT depth, const double* OPENSWMM_RESTRICT s_bot,
877 const double* OPENSWMM_RESTRICT r_bot, double* OPENSWMM_RESTRICT area,
878 int count);
879
901void area_tabulated(const double* OPENSWMM_RESTRICT depth, const double* OPENSWMM_RESTRICT y_full,
902 const double* OPENSWMM_RESTRICT a_full, const double* table, int table_size,
903 double* OPENSWMM_RESTRICT area, int count);
904
927void perlink_tabulated(const double* OPENSWMM_RESTRICT depth, const double* OPENSWMM_RESTRICT nrm,
928 const double* OPENSWMM_RESTRICT scale, const double* const* tables,
929 int table_size, double* OPENSWMM_RESTRICT result, int count);
930
960void perlink_tabulated_pair(const double* OPENSWMM_RESTRICT depth,
961 const double* OPENSWMM_RESTRICT nrm,
962 const double* OPENSWMM_RESTRICT scale_a,
963 const double* OPENSWMM_RESTRICT scale_b, const double* const* tables_a,
964 const double* const* tables_b, int table_size,
965 double* OPENSWMM_RESTRICT out_a, double* OPENSWMM_RESTRICT out_b,
966 int count);
967
990void area_inv_tabulated(const double* OPENSWMM_RESTRICT depth,
991 const double* OPENSWMM_RESTRICT y_full,
992 const double* OPENSWMM_RESTRICT a_full, const double* table, int table_size,
993 const xsect::LocateLut* lut, double* OPENSWMM_RESTRICT area, int count);
994
995// --- Hydraulic radius batch kernels ---
996
1014void hydrad_circular(const double* OPENSWMM_RESTRICT depth, const double* OPENSWMM_RESTRICT y_full,
1015 const double* OPENSWMM_RESTRICT r_full, double* OPENSWMM_RESTRICT hydrad,
1016 int count);
1017
1038void area_hydrad_circular(const double* OPENSWMM_RESTRICT depth,
1039 const double* OPENSWMM_RESTRICT y_full,
1040 const double* OPENSWMM_RESTRICT a_full,
1041 const double* OPENSWMM_RESTRICT r_full, double* OPENSWMM_RESTRICT area,
1042 double* OPENSWMM_RESTRICT hydrad, int count);
1043
1060void hydrad_trapezoidal(const double* OPENSWMM_RESTRICT depth,
1061 const double* OPENSWMM_RESTRICT y_bot,
1062 const double* OPENSWMM_RESTRICT s_bot,
1063 const double* OPENSWMM_RESTRICT r_bot, double* OPENSWMM_RESTRICT hydrad,
1064 int count);
1065
1081void hydrad_triangular(const double* OPENSWMM_RESTRICT depth, const double* OPENSWMM_RESTRICT s_bot,
1082 const double* OPENSWMM_RESTRICT r_bot, double* OPENSWMM_RESTRICT hydrad,
1083 int count);
1084
1100void hydrad_rect(const double* OPENSWMM_RESTRICT depth, const double* OPENSWMM_RESTRICT w_max,
1101 double* OPENSWMM_RESTRICT hydrad, int count);
1102
1124void hydrad_tabulated(const double* OPENSWMM_RESTRICT depth, const double* OPENSWMM_RESTRICT y_full,
1125 const double* OPENSWMM_RESTRICT r_full, const double* table, int table_size,
1126 double* OPENSWMM_RESTRICT hydrad, int count);
1127
1128// --- Top width batch kernels ---
1129
1147void width_circular(const double* OPENSWMM_RESTRICT depth, const double* OPENSWMM_RESTRICT y_full,
1148 const double* OPENSWMM_RESTRICT w_max, double* OPENSWMM_RESTRICT width,
1149 int count);
1150
1166void width_trapezoidal(const double* OPENSWMM_RESTRICT depth, const double* OPENSWMM_RESTRICT y_bot,
1167 const double* OPENSWMM_RESTRICT s_bot, double* OPENSWMM_RESTRICT width,
1168 int count);
1169
1184void width_triangular(const double* OPENSWMM_RESTRICT depth, const double* OPENSWMM_RESTRICT s_bot,
1185 double* OPENSWMM_RESTRICT width, int count);
1186
1200void width_rect(const double* OPENSWMM_RESTRICT w_max, double* OPENSWMM_RESTRICT width, int count);
1201
1223void width_tabulated(const double* OPENSWMM_RESTRICT depth, const double* OPENSWMM_RESTRICT y_full,
1224 const double* OPENSWMM_RESTRICT w_max, const double* table, int table_size,
1225 double* OPENSWMM_RESTRICT width, int count);
1226
1227} // namespace xsect_batch
1228
1229} // namespace openswmm
1230
1231#endif // OPENSWMM_XSECT_BATCH_HPP
#define OPENSWMM_RESTRICT
Definition KernelPointers.hpp:9
Bit-exact geometry-table interpolation — the single source of truth.
Shape-grouped cross-section manager for batch computation.
Definition XSectBatch.hpp:447
void computeAreas(const double *depths, double *areas, int n_links) const
Compute grouped-link area ft2 in native units.
Definition XSectBatch.cpp:1372
void computeWidths(const double *depths, double *widths, int n_links) const
Compute grouped-link width ft in native units.
Definition XSectBatch.cpp:1427
void setBypassMask(const std::uint8_t *bypassed_by_link) const
Restrict the triple kernels to non-bypassed links for the current Picard iteration.
Definition XSectBatch.cpp:1528
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.
Definition XSectBatch.cpp:1474
void computeAreaAndHydRad(const double *depths, double *areas, double *hydrad, int n_links) const
Compute grouped-link area ft2,radius ft in native units.
Definition XSectBatch.cpp:1404
void build(const SimulationContext &ctx)
Declare the context convenience overload for shape-group construction.
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.
Definition XSectBatch.cpp:1515
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.
Definition XSectBatch.cpp:1642
const ShapeGroup & group(int i) const
Borrow one indexed shape group.
Definition XSectBatch.hpp:716
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.
Definition XSectBatch.cpp:1608
void computeDepthsFromArea(const double *areas, double *depths, int n_links) const
Compute grouped-link depth ft in native units.
Definition XSectBatch.cpp:1664
void computeHydRad(const double *depths, double *hydrad, int n_links) const
Compute grouped-link radius ft in native units.
Definition XSectBatch.cpp:1388
void computeSectionFactors(const double *areas, double *sfact, int n_links) const
Compute grouped-link native section factor in native units.
Definition XSectBatch.cpp:1652
void attachTransectTables(const SimulationContext &ctx)
Attach borrowed profile tables to irregular, custom and street shape groups.
Definition XSectBatch.cpp:222
int numGroups() const
Number of non-empty shape groups.
Definition XSectBatch.hpp:707
const ShapeGroup * findGroup(XSectShape shape) const
Borrow the first group with the requested kernel shape.
Definition XSectBatch.cpp:273
Definition UnitConversion.cpp:31
Definition XSectBatch.cpp:285
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)
Evaluate trapezoid batch area through the shared analytic leaf.
Definition XSectBatch.cpp:318
void width_rect(const double *OPENSWMM_RESTRICT w_max, double *OPENSWMM_RESTRICT width, int count)
Copy constant rectangular widths to the batch output.
Definition XSectBatch.cpp:753
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)
Evaluate triangular batch hydraulic radius through the shared leaf.
Definition XSectBatch.cpp:606
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)
Evaluate trapezoid batch hydraulic radius through the shared leaf.
Definition XSectBatch.cpp:596
void width_triangular(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT s_bot, double *OPENSWMM_RESTRICT width, int count)
Evaluate triangular batch top widths through the shared leaf.
Definition XSectBatch.cpp:746
void hydrad_rect(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT w_max, double *OPENSWMM_RESTRICT hydrad, int count)
Evaluate the simple two-bank rectangular batch radius formula.
Definition XSectBatch.cpp:614
void hydrad_circular(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT nrm, const double *OPENSWMM_RESTRICT r_full, double *OPENSWMM_RESTRICT hydrad, int count)
Evaluate circular/force-main batch hydraulic radii from the built-in table.
Definition XSectBatch.cpp:482
void hydrad_tabulated(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT nrm, const double *OPENSWMM_RESTRICT r_full, const double *table, int table_size, double *OPENSWMM_RESTRICT hydrad, int count)
Scale one shared normalized hydraulic-radius table for a batch.
Definition XSectBatch.cpp:713
void width_circular(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT nrm, const double *OPENSWMM_RESTRICT w_max, double *OPENSWMM_RESTRICT width, int count)
Evaluate circular batch top widths from the built-in width table.
Definition XSectBatch.cpp:726
void area_inv_tabulated(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT nrm, const double *OPENSWMM_RESTRICT a_full, const double *table, int table_size, const xsect::LocateLut *lut, double *OPENSWMM_RESTRICT area, int count)
Invert one shared normalized depth-versus-area table for batch areas.
Definition XSectBatch.cpp:357
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)
Evaluate power-function batch area through the shared analytic leaf.
Definition XSectBatch.cpp:340
void area_circular(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT nrm, const double *OPENSWMM_RESTRICT a_full, double *OPENSWMM_RESTRICT area, int count)
Evaluate circular/force-main normalized area for a contiguous batch.
Definition XSectBatch.cpp:296
void area_rect(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT w_max, double *OPENSWMM_RESTRICT area, int count)
Multiply rectangular depths and widths using the shared SIMD routine.
Definition XSectBatch.cpp:309
void perlink_tabulated(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT nrm, const double *OPENSWMM_RESTRICT scale, const double *const *tables, int table_size, double *OPENSWMM_RESTRICT result, int count)
Per-link tabulated lookup (for IRREGULAR shapes where each link has its own table).
Definition XSectBatch.cpp:463
void perlink_tabulated_pair(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT nrm, const double *OPENSWMM_RESTRICT scale_a, const double *OPENSWMM_RESTRICT scale_b, const double *const *tables_a, const double *const *tables_b, int table_size, double *OPENSWMM_RESTRICT out_a, double *OPENSWMM_RESTRICT out_b, int count)
Fuse two per-element profile lookups on one normalized depth grid.
Definition XSectBatch.cpp:386
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)
Evaluate trapezoid batch top widths through the shared leaf.
Definition XSectBatch.cpp:738
void width_tabulated(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT nrm, const double *OPENSWMM_RESTRICT w_max, const double *table, int table_size, double *OPENSWMM_RESTRICT width, int count)
Scale one shared normalized width table for a batch.
Definition XSectBatch.cpp:759
void area_tabulated(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT nrm, const double *OPENSWMM_RESTRICT a_full, const double *table, int table_size, double *OPENSWMM_RESTRICT area, int count)
Scale one shared normalized area table for a batch.
Definition XSectBatch.cpp:347
void area_hydrad_circular(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT nrm, const double *OPENSWMM_RESTRICT a_full, const double *OPENSWMM_RESTRICT r_full, double *OPENSWMM_RESTRICT area, double *OPENSWMM_RESTRICT hydrad, int count)
Fuse circular batch area and hydraulic-radius table interpolation.
Definition XSectBatch.cpp:499
void area_triangular(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT s_bot, double *OPENSWMM_RESTRICT area, int count)
Evaluate triangular batch area through the shared analytic leaf.
Definition XSectBatch.cpp:326
void area_parabolic(const double *OPENSWMM_RESTRICT depth, const double *OPENSWMM_RESTRICT r_bot, double *OPENSWMM_RESTRICT area, int count)
Evaluate parabolic batch area through the shared analytic leaf.
Definition XSectBatch.cpp:333
Definition XSectBatch.hpp:158
double getAmax(const XSectParams &xs)
Read the built-in area-at-maximum-conveyance ratio.
Definition XSection.cpp:274
double getdSdA(const XSectParams &xs, double a)
Query native section-factor derivative with respect to area through the shared host evaluator.
Definition XSection.cpp:268
double lookup(double x, const double *table, int n_items)
Interpolate a borrowed equally spaced normalized geometry table.
Definition XSection.cpp:237
double getYofA(const XSectParams &xs, double a)
Query native depth from area through the shared host evaluator.
Definition XSection.cpp:259
double getScircular(double alpha)
Compute normalized circular section factor from area ratio.
Definition XSection.cpp:246
double invLookup(double y, const double *table, int n_items, const LocateLut *lut=nullptr)
Invert a borrowed normalized geometry table including the legacy declining top.
Definition XSection.cpp:240
double getWofY(const XSectParams &xs, double y)
Query native top width from depth through the shared host evaluator.
Definition XSection.cpp:253
double getSofA(const XSectParams &xs, double a)
Query native section factor from area through the shared host evaluator.
Definition XSection.cpp:262
double getRofY(const XSectParams &xs, double y)
Query native hydraulic radius from depth through the shared host evaluator.
Definition XSection.cpp:256
double getYcrit(const XSectParams &xs, double q)
Query native critical depth from discharge through the shared host evaluator.
Definition XSection.cpp:277
int locate(double y, const double *table, int n)
Find a lower bracket in a nondecreasing geometry table.
Definition XSection.cpp:234
double getAofY(const XSectParams &xs, double y)
Query native wetted area from depth through the shared host evaluator.
Definition XSection.cpp:250
double getAofS(const XSectParams &xs, double s_factor)
Query native area from section factor through the shared host evaluator.
Definition XSection.cpp:271
bool isOpen(int type)
Classify a kernel shape using the legacy open-section set.
Definition XSection.cpp:280
int setParams(XSectParams &xs, int type, const double p[], double ucf)
Derive native full-flow geometry from authored shape dimensions.
Definition XSection.cpp:295
double getRofA(const XSectParams &xs, double a)
Query native hydraulic radius from area through the shared host evaluator.
Definition XSection.cpp:265
double getYcircular(double alpha)
Compute normalized circular depth from area ratio.
Definition XSection.cpp:243
Definition ExchangeLaw.hpp:60
XSectShape
Definition XSectBatch.hpp:77
@ POWERFUNC
Definition XSectBatch.hpp:86
@ MOD_BASKET
Definition XSectBatch.hpp:89
@ DUMMY
Definition XSectBatch.hpp:78
@ TRIANGULAR
Definition LinkData.hpp:70
@ RECT_CLOSED
Definition LinkData.hpp:67
@ ARCH
Arch pipe.
Definition LinkData.hpp:85
@ FORCE_MAIN
Circular force main (Hazen-Williams or D-W)
Definition LinkData.hpp:88
@ RECT_OPEN
Definition LinkData.hpp:68
@ BASKETHANDLE
Definition LinkData.hpp:79
@ STREET_XSECT
Street cross-section.
Definition LinkData.hpp:89
@ SEMICIRCULAR
Definition LinkData.hpp:80
@ IRREGULAR
User-supplied shape curve.
Definition LinkData.hpp:86
@ HORIZ_ELLIPSE
Horizontal elliptical pipe.
Definition LinkData.hpp:83
@ VERT_ELLIPSE
Vertical elliptical pipe.
Definition LinkData.hpp:84
@ CUSTOM
Shape from CURVE_SHAPE table.
Definition LinkData.hpp:87
@ RECT_ROUND
Rectangular-round bottom.
Definition LinkData.hpp:82
@ EGGSHAPED
Definition LinkData.hpp:74
@ SEMIELLIPTICAL
Definition LinkData.hpp:78
@ CATENARY
Definition LinkData.hpp:77
@ CIRCULAR
Definition LinkData.hpp:65
@ TRAPEZOIDAL
Definition LinkData.hpp:69
@ HORSESHOE
Definition LinkData.hpp:75
@ DUMMY
Dummy (no geometry)
Definition LinkData.hpp:90
@ PARABOLIC
Definition LinkData.hpp:71
@ RECT_TRIANG
Rectangular-triangular bottom.
Definition LinkData.hpp:81
@ FILLED_CIRCULAR
Definition LinkData.hpp:66
@ GOTHIC
Definition LinkData.hpp:76
double * y
Definition odesolve.c:37
SoA parameter block for all links of one cross-section shape.
Definition XSectBatch.hpp:384
std::vector< double > r_full
Hyd. radius at full (ft)
Definition XSectBatch.hpp:394
std::vector< const double * > hrad_tables
Per-link hyd-rad table.
Definition XSectBatch.hpp:410
std::vector< double > w_max
Max width (ft)
Definition XSectBatch.hpp:396
std::vector< double > buf_r
Scatter buffer for results.
Definition XSectBatch.hpp:416
std::vector< double > buf_r2
Second scatter buffer (for fused ops)
Definition XSectBatch.hpp:417
std::vector< double > inv_y_full
1.0 / y_full (or 0 if y_full==0)
Definition XSectBatch.hpp:399
XSectShape shape
Definition XSectBatch.hpp:385
int transect_tbl_size
Table size (same for all)
Definition XSectBatch.hpp:412
std::vector< double > r_bot
Definition XSectBatch.hpp:405
std::vector< double > s_bot
Definition XSectBatch.hpp:404
std::vector< double > y_bot
Definition XSectBatch.hpp:402
void resize(int n)
Resize primary shape-group geometry and numerical work arrays.
Definition XSectBatch.cpp:76
std::vector< const double * > area_tables
Per-link area table.
Definition XSectBatch.hpp:409
std::vector< const double * > width_tables
Per-link width table.
Definition XSectBatch.hpp:411
std::vector< int > link_idx
link_idx[i] = index in SimulationContext
Definition XSectBatch.hpp:389
std::vector< double > buf_d
Gather buffer for depths.
Definition XSectBatch.hpp:415
int count
Definition XSectBatch.hpp:386
std::vector< double > a_bot
Definition XSectBatch.hpp:403
std::vector< double > a_full
Full area (ft2)
Definition XSectBatch.hpp:393
std::vector< double > s_full
Section factor at full.
Definition XSectBatch.hpp:395
std::vector< double > y_full
Full depth (ft)
Definition XSectBatch.hpp:392
Central, reentrant simulation context.
Definition SimulationContext.hpp:390
Native cross-section geometry and borrowed optional normalized transect tables.
Definition XSectBatch.hpp:119
double s_full
Section factor when full (normally ft^(8/3); FORCE_MAIN uses R^0.63)
Definition XSectBatch.hpp:129
double s_bot
Slope of bottom section / exponent.
Definition XSectBatch.hpp:134
int culvert_code
Definition XSectBatch.hpp:121
const double * hrad_tbl
Normalized hyd-radius vs y/y_full.
Definition XSectBatch.hpp:144
int transect
Definition XSectBatch.hpp:122
int transect_tbl_size
Entry count of the tables above.
Definition XSectBatch.hpp:146
const double * width_tbl
Normalized width vs y/y_full.
Definition XSectBatch.hpp:145
double a_full
Area when full (ft2)
Definition XSectBatch.hpp:127
double r_bot
Radius of bottom section / coefficient.
Definition XSectBatch.hpp:135
double s_max
Section factor at max flow (same convention as s_full)
Definition XSectBatch.hpp:130
int type
Definition XSectBatch.hpp:120
double a_bot
Area of bottom section.
Definition XSectBatch.hpp:133
const xsect::LocateLut * area_lut
Definition XSectBatch.hpp:151
double w_max
Width at widest point (ft)
Definition XSectBatch.hpp:125
double yw_max
Depth at widest point (ft)
Definition XSectBatch.hpp:126
double y_bot
Depth of bottom section / fill depth.
Definition XSectBatch.hpp:132
double y_full
Full depth (ft)
Definition XSectBatch.hpp:124
double r_full
Hydraulic radius when full (ft)
Definition XSectBatch.hpp:128
const double * area_tbl
Normalized area vs y/y_full.
Definition XSectBatch.hpp:143
Definition XSectLookup.hpp:232