OpenSWMM Engine  6.0.0-alpha.3
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.3)
Loading...
Searching...
No Matches
MeshData.hpp
Go to the documentation of this file.
1
17
18#ifndef OPENSWMM_ENGINE_2D_MESH_DATA_HPP
19#define OPENSWMM_ENGINE_2D_MESH_DATA_HPP
20
21#include <vector>
22#include <string>
23#include <cstdint>
24
25namespace openswmm::twoD {
26
34struct MeshData {
35
36 // -----------------------------------------------------------------------
37 // Vertex arrays — indexed by vertex index [0, n_vertices)
38 // -----------------------------------------------------------------------
39
40 std::vector<double> vx;
41 std::vector<double> vy;
42 std::vector<double> vz;
43 std::vector<std::string> vtag;
44
45 // -----------------------------------------------------------------------
46 // Triangle static properties — indexed by triangle index [0, n_triangles)
47 // -----------------------------------------------------------------------
48
49 // Connectivity (3 vertex indices per triangle)
50 std::vector<int> tri_v0;
51 std::vector<int> tri_v1;
52 std::vector<int> tri_v2;
53
54 // Neighbour connectivity (3 adjacent triangle indices, -1 = boundary)
55 std::vector<int> tri_nbr0;
56 std::vector<int> tri_nbr1;
57 std::vector<int> tri_nbr2;
58
59 // Precomputed geometry
60 std::vector<double> tri_area;
61 std::vector<double> tri_cx;
62 std::vector<double> tri_cy;
63 std::vector<double> tri_cz;
64
65 // Edge geometry — flat 2D: [tri * 3 + edge]
66 std::vector<double> edge_length;
67 std::vector<double> edge_nx;
68 std::vector<double> edge_ny;
69 std::vector<double> edge_mx;
70 std::vector<double> edge_my;
71 std::vector<double> edge_mz;
72
86 std::vector<double> edge_conveyance;
87
88 // Surface properties
89 std::vector<double> mannings_n;
90 std::vector<std::string> tri_tag;
91
92 // -----------------------------------------------------------------------
93 // Vertex reconstruction stencil (pseudo-Laplacian weights)
94 // -----------------------------------------------------------------------
95 // Stored as CSR (compressed sparse row) for variable stencil sizes
96 std::vector<int> vert_stencil_ptr;
97 std::vector<int> vert_stencil_idx;
98 std::vector<double> vert_stencil_wt;
99
100 // -----------------------------------------------------------------------
101 // Coupling maps
102 // -----------------------------------------------------------------------
103
104 std::vector<int> vert_coupled_node;
105 std::vector<int> tri_coupled_node;
106
107 // Coupling parameters (per vertex/triangle coupling point)
108 std::vector<double> vert_coupling_cd;
109 std::vector<double> vert_coupling_area;
110 std::vector<double> tri_coupling_cd;
111 std::vector<double> tri_coupling_area;
112
113 // Deferred resolution names (populated during parsing, cleared after resolve)
114 std::vector<std::string> vert_coupled_node_name;
115 std::vector<std::string> tri_coupled_node_name;
116
117 // -----------------------------------------------------------------------
118 // Capacity queries
119 // -----------------------------------------------------------------------
120
121 int n_vertices() const noexcept { return static_cast<int>(vx.size()); }
122 int n_triangles() const noexcept { return static_cast<int>(tri_v0.size()); }
123
124 // -----------------------------------------------------------------------
125 // Resize / allocation
126 // -----------------------------------------------------------------------
127
128 void resize_vertices(int nv) {
129 auto n = static_cast<std::size_t>(nv);
130 vx.resize(n, 0.0);
131 vy.resize(n, 0.0);
132 vz.resize(n, 0.0);
133 vtag.resize(n);
134 vert_coupled_node.resize(n, -1);
135 vert_coupled_node_name.resize(n);
136 vert_coupling_cd.resize(n, 0.65);
137 vert_coupling_area.resize(n, 1.0);
138 }
139
140 void resize_triangles(int nt) {
141 auto n = static_cast<std::size_t>(nt);
142 tri_v0.resize(n, 0);
143 tri_v1.resize(n, 0);
144 tri_v2.resize(n, 0);
145 tri_nbr0.resize(n, -1);
146 tri_nbr1.resize(n, -1);
147 tri_nbr2.resize(n, -1);
148 tri_area.resize(n, 0.0);
149 tri_cx.resize(n, 0.0);
150 tri_cy.resize(n, 0.0);
151 tri_cz.resize(n, 0.0);
152
153 auto n3 = static_cast<std::size_t>(nt) * 3;
154 edge_length.resize(n3, 0.0);
155 edge_nx.resize(n3, 0.0);
156 edge_ny.resize(n3, 0.0);
157 edge_mx.resize(n3, 0.0);
158 edge_my.resize(n3, 0.0);
159 edge_mz.resize(n3, 0.0);
160 edge_conveyance.resize(n3, 1.0); // §11A — default unrestricted
161
162 mannings_n.resize(n, 0.035);
163 tri_tag.resize(n);
164 tri_coupled_node.resize(n, -1);
165 tri_coupled_node_name.resize(n);
166 tri_coupling_cd.resize(n, 0.65);
167 tri_coupling_area.resize(n, 1.0);
168 }
169};
170
171} // namespace openswmm::twoD
172
173#endif // OPENSWMM_ENGINE_2D_MESH_DATA_HPP
Definition NodeCoupling.cpp:15
SoA storage for 2D triangular mesh geometry and topology.
Definition MeshData.hpp:34
std::vector< double > tri_coupling_area
Effective exchange area.
Definition MeshData.hpp:111
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 > vert_stencil_idx
Column indices (triangle indices)
Definition MeshData.hpp:97
std::vector< double > tri_area
Planimetric area (m²)
Definition MeshData.hpp:60
std::vector< double > edge_nx
Outward normal X component.
Definition MeshData.hpp:67
std::vector< double > edge_length
Length of each edge.
Definition MeshData.hpp:66
void resize_triangles(int nt)
Definition MeshData.hpp:140
std::vector< std::string > tri_coupled_node_name
Definition MeshData.hpp:115
std::vector< std::string > vtag
Optional vertex tag.
Definition MeshData.hpp:43
std::vector< double > tri_cy
Centroid Y.
Definition MeshData.hpp:62
std::vector< double > vy
Vertex Y coordinate.
Definition MeshData.hpp:41
std::vector< int > tri_coupled_node
SWMM node index (-1 = none)
Definition MeshData.hpp:105
std::vector< int > tri_nbr1
Neighbour across edge opposite v1.
Definition MeshData.hpp:56
std::vector< int > vert_coupled_node
SWMM node index (-1 = none)
Definition MeshData.hpp:104
std::vector< double > vert_coupling_area
Effective exchange area (m²)
Definition MeshData.hpp:109
std::vector< double > tri_cx
Centroid X.
Definition MeshData.hpp:61
std::vector< std::string > tri_tag
Optional triangle tag.
Definition MeshData.hpp:90
std::vector< double > edge_my
Edge midpoint Y.
Definition MeshData.hpp:70
std::vector< int > tri_v2
Vertex 2 index.
Definition MeshData.hpp:52
std::vector< int > vert_stencil_ptr
[n_vertices + 1] row pointers
Definition MeshData.hpp:96
std::vector< double > vz
Vertex Z (ground elevation)
Definition MeshData.hpp:42
std::vector< std::string > vert_coupled_node_name
Definition MeshData.hpp:114
std::vector< double > edge_ny
Outward normal Y component.
Definition MeshData.hpp:68
std::vector< double > tri_cz
Centroid Z (avg of vertex elevations)
Definition MeshData.hpp:63
std::vector< double > mannings_n
Manning's roughness coefficient.
Definition MeshData.hpp:89
std::vector< double > vx
Vertex X coordinate.
Definition MeshData.hpp:40
std::vector< int > tri_v0
Vertex 0 index.
Definition MeshData.hpp:50
std::vector< double > edge_mx
Edge midpoint X.
Definition MeshData.hpp:69
std::vector< int > tri_nbr2
Neighbour across edge opposite v2.
Definition MeshData.hpp:57
std::vector< double > vert_stencil_wt
Pseudo-Laplacian weights.
Definition MeshData.hpp:98
int n_vertices() const noexcept
Definition MeshData.hpp:121
std::vector< double > tri_coupling_cd
Discharge coefficient.
Definition MeshData.hpp:110
void resize_vertices(int nv)
Definition MeshData.hpp:128
std::vector< double > edge_mz
Edge midpoint Z (interpolated)
Definition MeshData.hpp:71
std::vector< int > tri_nbr0
Neighbour across edge opposite v0.
Definition MeshData.hpp:55
std::vector< double > vert_coupling_cd
Discharge coefficient (default 0.65)
Definition MeshData.hpp:108