34#ifndef OPENSWMM_ENGINE_2D_MESH_DATA_HPP
35#define OPENSWMM_ENGINE_2D_MESH_DATA_HPP
73 std::vector<double>
vx;
74 std::vector<double>
vy;
75 std::vector<double>
vz;
76 std::vector<std::string>
vtag;
195 int n_vertices() const noexcept {
return static_cast<int>(
vx.size()); }
203 for (uint8_t nv :
cell_nv) q += (nv == 4);
227 bool is_quad(
int c)
const noexcept {
return cell_nv[
static_cast<std::size_t
>(c)] == 4; }
231 const int nv =
cell_nv[
static_cast<std::size_t
>(c)];
232 a =
cell_v[
static_cast<std::size_t
>(
slot(c, (k + 1) % nv))];
233 b =
cell_v[
static_cast<std::size_t
>(
slot(c, (k + 2) % nv))];
237 cell_nv[
static_cast<std::size_t
>(c)] = 3;
238 cell_v[
static_cast<std::size_t
>(
slot(c, 0))] = v0;
239 cell_v[
static_cast<std::size_t
>(
slot(c, 1))] = v1;
240 cell_v[
static_cast<std::size_t
>(
slot(c, 2))] = v2;
241 cell_v[
static_cast<std::size_t
>(
slot(c, 3))] = -1;
243 void set_quad(
int c,
int v0,
int v1,
int v2,
int v3)
noexcept {
244 cell_nv[
static_cast<std::size_t
>(c)] = 4;
245 cell_v[
static_cast<std::size_t
>(
slot(c, 0))] = v0;
246 cell_v[
static_cast<std::size_t
>(
slot(c, 1))] = v1;
247 cell_v[
static_cast<std::size_t
>(
slot(c, 2))] = v2;
248 cell_v[
static_cast<std::size_t
>(
slot(c, 3))] = v3;
256 auto n =
static_cast<std::size_t
>(nv);
271 auto n =
static_cast<std::size_t
>(nt);
272 const auto old_n =
cell_nv.size();
278 for (std::size_t c = old_n; c < n; ++c) {
Definition NodeCoupling.cpp:16
constexpr int kMaxCellVerts
Definition MeshData.hpp:49
Definition MeshData.hpp:179
int node
SWMM node index (-1 until resolved)
Definition MeshData.hpp:181
bool area_set
Definition MeshData.hpp:185
std::string node_name
Deferred name (cleared after resolve)
Definition MeshData.hpp:182
double cd
Discharge coefficient.
Definition MeshData.hpp:183
double area
Effective exchange area.
Definition MeshData.hpp:184
int tri
Triangle index.
Definition MeshData.hpp:180
SoA storage for 2D mixed triangle/quad mesh geometry and topology.
Definition MeshData.hpp:67
std::vector< double > tri_coupling_area
Effective exchange area.
Definition MeshData.hpp:165
std::vector< double > edge_conveyance
Definition MeshData.hpp:133
int n_triangles() const noexcept
Definition MeshData.hpp:198
std::vector< uint8_t > vert_coupling_area_set
Definition MeshData.hpp:163
std::vector< int > vert_stencil_idx
Column indices (triangle indices)
Definition MeshData.hpp:147
std::vector< double > tri_area
Planimetric area (m²)
Definition MeshData.hpp:94
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
int n_quads() const noexcept
Number of quadrilateral cells (O(n) scan; not a hot path).
Definition MeshData.hpp:201
std::vector< double > edge_nx
Outward normal X component.
Definition MeshData.hpp:101
std::vector< double > edge_length
Length of each edge.
Definition MeshData.hpp:100
void resize_triangles(int nt)
Definition MeshData.hpp:270
std::vector< std::string > tri_coupled_node_name
Definition MeshData.hpp:169
std::vector< std::string > vtag
Optional vertex tag.
Definition MeshData.hpp:76
int cell_vertex(int c, int k) const noexcept
Definition MeshData.hpp:225
std::vector< double > tri_cy
Centroid Y (area centroid)
Definition MeshData.hpp:96
std::vector< double > vy
Vertex Y coordinate.
Definition MeshData.hpp:74
std::vector< int > tri_coupled_node
SWMM node index (-1 = none)
Definition MeshData.hpp:155
void set_triangle(int c, int v0, int v1, int v2) noexcept
Definition MeshData.hpp:236
static constexpr int slot(int c, int k) noexcept
Flat edge/vertex slot of local index k in cell c.
Definition MeshData.hpp:219
std::vector< int > vert_coupled_node
SWMM node index (-1 = none)
Definition MeshData.hpp:154
std::vector< double > tri_init_u
[2D_INITIAL_VELOCITY] u (m/s, default 0)
Definition MeshData.hpp:138
int n_cells() const noexcept
Definition MeshData.hpp:199
std::vector< double > tri_init_depth
Initial water depth (m, default 0 = dry)
Definition MeshData.hpp:137
std::vector< double > vert_coupling_area
Definition MeshData.hpp:159
std::vector< double > tri_cx
Centroid X (area centroid)
Definition MeshData.hpp:95
std::vector< std::string > tri_tag
Optional triangle tag.
Definition MeshData.hpp:140
std::vector< uint8_t > cell_nv
Vertices per cell: 3 (triangle) or 4 (quadrilateral).
Definition MeshData.hpp:83
void set_quad(int c, int v0, int v1, int v2, int v3) noexcept
Definition MeshData.hpp:243
std::vector< int > cell_v
Definition MeshData.hpp:88
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
std::vector< double > edge_my
Edge midpoint Y.
Definition MeshData.hpp:104
int cell_vertex_count(int c) const noexcept
Definition MeshData.hpp:224
std::vector< int > vert_stencil_ptr
[n_vertices + 1] row pointers
Definition MeshData.hpp:146
std::vector< double > vz
Vertex Z (ground elevation)
Definition MeshData.hpp:75
std::vector< std::string > vert_coupled_node_name
Definition MeshData.hpp:168
std::vector< double > edge_ny
Outward normal Y component.
Definition MeshData.hpp:102
std::vector< double > tri_cz
Mean of the cell's vertex elevations.
Definition MeshData.hpp:97
static constexpr int slot_local(int s) noexcept
Local index k of a flat slot; cell of a flat slot.
Definition MeshData.hpp:221
std::vector< double > quad_vfr_a
Definition MeshData.hpp:118
std::vector< double > mannings_n
Manning's roughness coefficient.
Definition MeshData.hpp:136
std::vector< double > vx
Vertex X coordinate.
Definition MeshData.hpp:73
int edge_stride() const noexcept
Definition MeshData.hpp:210
std::vector< double > edge_mx
Edge midpoint X.
Definition MeshData.hpp:103
std::vector< double > vert_stencil_wt
Pseudo-Laplacian weights.
Definition MeshData.hpp:148
int n_vertices() const noexcept
Definition MeshData.hpp:195
std::vector< double > tri_coupling_cd
Discharge coefficient.
Definition MeshData.hpp:164
void resize_vertices(int nv)
Definition MeshData.hpp:255
std::vector< double > edge_mz
Definition MeshData.hpp:105
std::vector< double > tri_init_v
[2D_INITIAL_VELOCITY] v (m/s, default 0)
Definition MeshData.hpp:139
std::vector< double > edge_dist_c
Definition MeshData.hpp:110
int cell_neighbour(int c, int k) const noexcept
Definition MeshData.hpp:226
std::vector< TriCouplingRow > tri_couplings
Definition MeshData.hpp:189
bool is_quad(int c) const noexcept
Definition MeshData.hpp:227
std::vector< int > cell_nbr
Definition MeshData.hpp:91
std::vector< double > quad_vfr_z
Definition MeshData.hpp:117
std::vector< double > vert_coupling_cd
Discharge coefficient (default 0.65)
Definition MeshData.hpp:158