26#ifndef OPENSWMM_ENGINE_2D_SERIALIZE_2D_HPP
27#define OPENSWMM_ENGINE_2D_SERIALIZE_2D_HPP
36#include <unordered_map>
37#include <unordered_set>
60 const std::vector<PendingBoundaryRow>* pending,
65 if (pending && !pending->empty())
return *pending;
70 std::vector<PendingBoundaryRow> rows;
71 if (!boundary)
return rows;
73 const int n = boundary->
size();
74 for (
int idx = 0; idx < n; ++idx) {
82 r.
bc_type =
static_cast<int>(type);
106 rows.push_back(std::move(r));
111 if (pending && !pending->empty() && !rows.empty()) {
112 std::unordered_map<int, const std::string*> groups;
113 groups.reserve(pending->size());
114 for (
const auto& p : *pending) {
115 if (!p.group.empty()) groups[p.tri * 3 + p.edge] = &p.group;
117 if (!groups.empty()) {
118 for (
auto& r : rows) {
119 auto it = groups.find(r.tri * 3 + r.edge);
120 if (it != groups.end()) r.group = *it->second;
147 const std::vector<PendingEdgeConveyanceRow>* pending,
151 if (!drained && pending && !pending->empty())
return *pending;
153 std::vector<PendingEdgeConveyanceRow> rows;
154 if (!mesh)
return rows;
161 std::unordered_set<std::int64_t> seen;
162 for (
int t = 0; t < nt; ++t) {
164 for (
int e = 0; e < 3; ++e) {
166 if (k == 1.0)
continue;
167 const int va = std::min(v[(e + 1) % 3], v[(e + 2) % 3]);
168 const int vb = std::max(v[(e + 1) % 3], v[(e + 2) % 3]);
169 const std::int64_t key =
170 (
static_cast<std::int64_t
>(va) << 32)
171 | (
static_cast<std::int64_t
>(vb) & 0xFFFFFFFFLL);
172 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:15
std::vector< PendingBoundaryRow > collectBCRows(const std::vector< PendingBoundaryRow > *pending, const BoundaryData *boundary, bool drained)
Collect [2D_BOUNDARY_CONDITIONS]-shaped rows for serialization.
Definition Serialize2D.hpp:59
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:146
BoundaryType
Boundary condition types for 2D mesh edges.
Definition BoundaryData.hpp:40
@ RATING_CURVE
Stage → flow lookup (curve registry index)
Definition BoundaryData.hpp:45
@ SPECIFIED_FLOW
Prescribed discharge per metre of edge (constant or TS)
Definition BoundaryData.hpp:44
@ NORMAL_FLOW
Manning outflow using bed slope.
Definition BoundaryData.hpp:42
@ WALL
Zero-flux wall (default)
Definition BoundaryData.hpp:41
@ SPECIFIED_STAGE
Prescribed water surface elevation (constant or TS)
Definition BoundaryData.hpp:43
SoA storage for per-edge boundary conditions.
Definition BoundaryData.hpp:55
std::vector< std::string > edge_bc_flow_tseries_name
Timeseries name for deferred resolution (cleared after resolve).
Definition BoundaryData.hpp:95
std::vector< int8_t > edge_bc_type
Boundary condition type per edge (cast from BoundaryType)
Definition BoundaryData.hpp:58
std::vector< std::string > edge_bc_tseries_name
Timeseries name for deferred resolution (cleared after resolve).
Definition BoundaryData.hpp:74
std::vector< double > edge_bed_slope
Definition BoundaryData.hpp:62
std::vector< double > edge_bc_flow
Definition BoundaryData.hpp:87
std::vector< double > edge_bc_head
Definition BoundaryData.hpp:66
int size() const noexcept
Definition BoundaryData.hpp:131
std::vector< std::string > edge_bc_rating_curve_name
Curve name for deferred resolution (cleared after resolve).
Definition BoundaryData.hpp:106
SoA storage for 2D triangular mesh geometry and topology.
Definition MeshData.hpp:34
std::vector< int > tri_v1
Vertex 1 index.
Definition MeshData.hpp:51
std::vector< double > edge_conveyance
Definition MeshData.hpp:86
int n_triangles() const noexcept
Definition MeshData.hpp:122
std::vector< int > tri_v2
Vertex 2 index.
Definition MeshData.hpp:52
std::vector< int > tri_v0
Vertex 0 index.
Definition MeshData.hpp:50
Per-row buffer for [2D_BOUNDARY_CONDITIONS] parse output.
Definition PendingRows2D.hpp:37
double param1
slope (NormalFlow) / head (Stage) / flow (Flow)
Definition PendingRows2D.hpp:41
std::string name
TS name or curve name (TS_/Rating variants)
Definition PendingRows2D.hpp:42
int bc_type
openswmm::twoD::BoundaryType cast
Definition PendingRows2D.hpp:40
int tri
Definition PendingRows2D.hpp:38
int edge
0..2
Definition PendingRows2D.hpp:39
Per-row buffer for [2D_EDGE_CONVEYANCE] parse output (§11A).
Definition PendingRows2D.hpp:56