42#ifndef OPENSWMM_ENGINE_2D_SERIALIZE_2D_HPP
43#define OPENSWMM_ENGINE_2D_SERIALIZE_2D_HPP
52#include <unordered_map>
53#include <unordered_set>
77inline std::vector<PendingBoundaryRow>
collectBCRows(
const std::vector<PendingBoundaryRow>* pending,
79 double flow_to_si_applied = 1.0) {
81 const double flow_to_display = (flow_to_si_applied > 0.0) ? 1.0 / flow_to_si_applied : 1.0;
84 if (pending && !pending->empty())
90 std::vector<PendingBoundaryRow> rows;
94 std::unordered_map<int, std::string> groups;
96 for (
const auto& p : *pending) groups[
MeshData::slot(p.tri,p.edge)] = p.group;
97 const int n = boundary->
size();
98 for (
int idx = 0; idx < n; ++idx) {
101 (groups.find(idx) == groups.end() || groups.at(idx).empty()))
107 r.
bc_type =
static_cast<int>(type);
108 if (
auto it = groups.find(idx); it != groups.end()) r.
group = it->second;
133 rows.push_back(std::move(r));
152inline std::vector<PendingEdgeConveyanceRow>
156 if (!drained && pending && !pending->empty())
159 std::vector<PendingEdgeConveyanceRow> rows;
164 if (nt < 1 || mesh->edge_conveyance.size() <
static_cast<std::size_t
>(mesh->
n_edge_slots()))
167 std::unordered_set<std::int64_t> seen;
168 for (
int t = 0; t < nt; ++t) {
170 for (
int e = 0; e < nvc; ++e) {
176 const int va = std::min(ea, eb);
177 const int vb = std::max(ea, eb);
178 const std::int64_t key = (
static_cast<std::int64_t
>(va) << 32) |
179 (
static_cast<std::int64_t
>(vb) & 0xFFFFFFFFLL);
180 if (!seen.insert(key).second)
Structure-of-Arrays (SoA) storage for 2D mesh boundary conditions.
Structure-of-Arrays (SoA) storage for 2D triangular mesh geometry.
Parse-time scratch rows for [2D_BOUNDARY_CONDITIONS] and [2D_EDGE_CONVEYANCE] input sections.
Definition ExchangeLaw.hpp:60
std::vector< PendingBoundaryRow > collectBCRows(const std::vector< PendingBoundaryRow > *pending, const BoundaryData *boundary, bool drained, double flow_to_si_applied=1.0)
Copy authored boundary rows or reconstruct them from live edge storage.
Definition Serialize2D.hpp:77
std::vector< PendingEdgeConveyanceRow > collectConveyanceRows(const std::vector< PendingEdgeConveyanceRow > *pending, const MeshData *mesh, bool drained)
Copy authored conveyance rows or reconstruct unique nondefault mesh edges.
Definition Serialize2D.hpp:153
BoundaryType
Boundary condition types for 2D mesh edges.
Definition BoundaryData.hpp:58
@ RATING_CURVE
Stage → flow lookup (curve registry index)
Definition BoundaryData.hpp:63
@ SPECIFIED_FLOW
Prescribed discharge per metre of edge (constant or TS)
Definition BoundaryData.hpp:62
@ NORMAL_FLOW
Manning outflow using bed slope.
Definition BoundaryData.hpp:60
@ WALL
Zero-flux wall (default)
Definition BoundaryData.hpp:59
@ SPECIFIED_STAGE
Prescribed water surface elevation (constant or TS)
Definition BoundaryData.hpp:61
SoA storage for per-edge boundary conditions.
Definition BoundaryData.hpp:73
std::vector< std::string > edge_bc_flow_tseries_name
Timeseries name for deferred resolution (cleared after resolve).
Definition BoundaryData.hpp:120
std::vector< int8_t > edge_bc_type
Boundary condition type per edge (cast from BoundaryType)
Definition BoundaryData.hpp:76
std::vector< std::string > edge_bc_tseries_name
Timeseries name for deferred resolution (cleared after resolve).
Definition BoundaryData.hpp:99
std::vector< double > edge_bed_slope
Definition BoundaryData.hpp:87
std::vector< double > edge_bc_flow
Definition BoundaryData.hpp:112
std::vector< double > edge_bc_head
Definition BoundaryData.hpp:91
int size() const noexcept
Report the number of padded boundary edge slots.
Definition BoundaryData.hpp:247
std::vector< std::string > edge_bc_rating_curve_name
Curve name for deferred resolution (cleared after resolve).
Definition BoundaryData.hpp:131
std::vector< double > edge_wall_drag
Optional tangential wall drag: tau/rho = -Cw |ut| ut. Zero = free slip.
Definition BoundaryData.hpp:79
SoA storage for 2D mixed triangle/quad mesh geometry and topology.
Definition MeshData.hpp:65
std::vector< double > edge_conveyance
Definition MeshData.hpp:131
int n_triangles() const noexcept
Number of CELLS (triangles + quads). The historical name is kept for the ~200 call sites; n_cells() i...
Definition MeshData.hpp:213
void cell_edge_vertices(int c, int k, int &a, int &b) const noexcept
Endpoint vertices of local edge k of cell c: v[(k+1)nv], v[(k+2)nv].
Definition MeshData.hpp:336
static constexpr int slot(int c, int k) noexcept
Flat edge/vertex slot of local index k in cell c.
Definition MeshData.hpp:267
int n_edge_slots() const noexcept
Number of internal edge slots (n_cells * kMaxCellVerts).
Definition MeshData.hpp:252
static constexpr int slot_cell(int s) noexcept
Convert mixed-mesh padded slot coordinates.
Definition MeshData.hpp:283
int cell_vertex_count(int c) const noexcept
Read one mixed-cell topology field.
Definition MeshData.hpp:292
static constexpr int slot_local(int s) noexcept
Local index k of a flat slot; cell of a flat slot.
Definition MeshData.hpp:276
Per-row buffer for [2D_BOUNDARY_CONDITIONS] parse output.
Definition PendingRows2D.hpp:53
double param1
slope / head / flow / Cw (WALL_DRAG)
Definition PendingRows2D.hpp:57
std::string group
named group ("" = none)
Definition PendingRows2D.hpp:59
std::string name
TS name or curve name (TS_/Rating variants)
Definition PendingRows2D.hpp:58
int bc_type
openswmm::twoD::BoundaryType cast
Definition PendingRows2D.hpp:56
int tri
Definition PendingRows2D.hpp:54
int edge
0..2
Definition PendingRows2D.hpp:55
Per-row buffer for [2D_EDGE_CONVEYANCE] parse output (§11A).
Definition PendingRows2D.hpp:72