42#ifndef OPENSWMM_ENGINE_2D_SERIALIZE_2D_HPP
43#define OPENSWMM_ENGINE_2D_SERIALIZE_2D_HPP
52#include <unordered_map>
53#include <unordered_set>
83 const std::vector<PendingBoundaryRow>* pending,
86 double flow_to_si_applied = 1.0) {
88 const double flow_to_display =
89 (flow_to_si_applied > 0.0) ? 1.0 / flow_to_si_applied : 1.0;
92 if (pending && !pending->empty())
return *pending;
97 std::vector<PendingBoundaryRow> rows;
98 if (!boundary)
return rows;
100 const int n = boundary->
size();
101 for (
int idx = 0; idx < n; ++idx) {
109 r.
bc_type =
static_cast<int>(type);
133 rows.push_back(std::move(r));
138 if (pending && !pending->empty() && !rows.empty()) {
139 std::unordered_map<int, const std::string*> groups;
140 groups.reserve(pending->size());
141 for (
const auto& p : *pending) {
142 if (!p.group.empty()) groups[
MeshData::slot(p.tri, p.edge)] = &p.group;
144 if (!groups.empty()) {
145 for (
auto& r : rows) {
147 if (it != groups.end()) r.group = *it->second;
174 const std::vector<PendingEdgeConveyanceRow>* pending,
178 if (!drained && pending && !pending->empty())
return *pending;
180 std::vector<PendingEdgeConveyanceRow> rows;
181 if (!mesh)
return rows;
188 std::unordered_set<std::int64_t> seen;
189 for (
int t = 0; t < nt; ++t) {
191 for (
int e = 0; e < nvc; ++e) {
193 if (k == 1.0)
continue;
196 const int va = std::min(ea, eb);
197 const int vb = std::max(ea, eb);
198 const std::int64_t key =
199 (
static_cast<std::int64_t
>(va) << 32)
200 | (
static_cast<std::int64_t
>(vb) & 0xFFFFFFFFLL);
201 if (!seen.insert(key).second)
continue;
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 NodeCoupling.cpp:16
std::vector< PendingBoundaryRow > collectBCRows(const std::vector< PendingBoundaryRow > *pending, const BoundaryData *boundary, bool drained, double flow_to_si_applied=1.0)
Collect [2D_BOUNDARY_CONDITIONS]-shaped rows for serialization.
Definition Serialize2D.hpp:82
std::vector< PendingEdgeConveyanceRow > collectConveyanceRows(const std::vector< PendingEdgeConveyanceRow > *pending, const MeshData *mesh, bool drained)
Collect [2D_EDGE_CONVEYANCE]-shaped rows for serialization.
Definition Serialize2D.hpp:173
BoundaryType
Boundary condition types for 2D mesh edges.
Definition BoundaryData.hpp:56
@ RATING_CURVE
Stage → flow lookup (curve registry index)
Definition BoundaryData.hpp:61
@ SPECIFIED_FLOW
Prescribed discharge per metre of edge (constant or TS)
Definition BoundaryData.hpp:60
@ NORMAL_FLOW
Manning outflow using bed slope.
Definition BoundaryData.hpp:58
@ WALL
Zero-flux wall (default)
Definition BoundaryData.hpp:57
@ SPECIFIED_STAGE
Prescribed water surface elevation (constant or TS)
Definition BoundaryData.hpp:59
SoA storage for per-edge boundary conditions.
Definition BoundaryData.hpp:71
std::vector< std::string > edge_bc_flow_tseries_name
Timeseries name for deferred resolution (cleared after resolve).
Definition BoundaryData.hpp:112
std::vector< int8_t > edge_bc_type
Boundary condition type per edge (cast from BoundaryType)
Definition BoundaryData.hpp:74
std::vector< std::string > edge_bc_tseries_name
Timeseries name for deferred resolution (cleared after resolve).
Definition BoundaryData.hpp:91
std::vector< double > edge_bed_slope
Definition BoundaryData.hpp:79
std::vector< double > edge_bc_flow
Definition BoundaryData.hpp:104
std::vector< double > edge_bc_head
Definition BoundaryData.hpp:83
int size() const noexcept
Definition BoundaryData.hpp:148
std::vector< std::string > edge_bc_rating_curve_name
Curve name for deferred resolution (cleared after resolve).
Definition BoundaryData.hpp:123
SoA storage for 2D mixed triangle/quad mesh geometry and topology.
Definition MeshData.hpp:67
std::vector< double > edge_conveyance
Definition MeshData.hpp:133
int n_triangles() const noexcept
Definition MeshData.hpp:198
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:230
static constexpr int slot(int c, int k) noexcept
Flat edge/vertex slot of local index k in cell c.
Definition MeshData.hpp:219
int n_edge_slots() const noexcept
Number of internal edge slots (n_cells * kMaxCellVerts).
Definition MeshData.hpp:212
static constexpr int slot_cell(int s) noexcept
Definition MeshData.hpp:222
int cell_vertex_count(int c) const noexcept
Definition MeshData.hpp:224
static constexpr int slot_local(int s) noexcept
Local index k of a flat slot; cell of a flat slot.
Definition MeshData.hpp:221
Per-row buffer for [2D_BOUNDARY_CONDITIONS] parse output.
Definition PendingRows2D.hpp:53
double param1
slope (NormalFlow) / head (Stage) / flow (Flow)
Definition PendingRows2D.hpp:57
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