OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
MeshData.hpp
Go to the documentation of this file.
1
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
73 // Surface properties
74 std::vector<double> mannings_n;
75 std::vector<std::string> tri_tag;
76
77 // -----------------------------------------------------------------------
78 // Vertex reconstruction stencil (pseudo-Laplacian weights)
79 // -----------------------------------------------------------------------
80 // Stored as CSR (compressed sparse row) for variable stencil sizes
81 std::vector<int> vert_stencil_ptr;
82 std::vector<int> vert_stencil_idx;
83 std::vector<double> vert_stencil_wt;
84
85 // -----------------------------------------------------------------------
86 // Coupling maps
87 // -----------------------------------------------------------------------
88
89 std::vector<int> vert_coupled_node;
90 std::vector<int> tri_coupled_node;
91
92 // Coupling parameters (per vertex/triangle coupling point)
93 std::vector<double> vert_coupling_cd;
94 std::vector<double> vert_coupling_area;
95 std::vector<double> tri_coupling_cd;
96 std::vector<double> tri_coupling_area;
97
98 // Deferred resolution names (populated during parsing, cleared after resolve)
99 std::vector<std::string> vert_coupled_node_name;
100 std::vector<std::string> tri_coupled_node_name;
101
102 // -----------------------------------------------------------------------
103 // Capacity queries
104 // -----------------------------------------------------------------------
105
106 int n_vertices() const noexcept { return static_cast<int>(vx.size()); }
107 int n_triangles() const noexcept { return static_cast<int>(tri_v0.size()); }
108
109 // -----------------------------------------------------------------------
110 // Resize / allocation
111 // -----------------------------------------------------------------------
112
113 void resize_vertices(int nv) {
114 auto n = static_cast<std::size_t>(nv);
115 vx.resize(n, 0.0);
116 vy.resize(n, 0.0);
117 vz.resize(n, 0.0);
118 vtag.resize(n);
119 vert_coupled_node.resize(n, -1);
120 vert_coupled_node_name.resize(n);
121 vert_coupling_cd.resize(n, 0.65);
122 vert_coupling_area.resize(n, 1.0);
123 }
124
125 void resize_triangles(int nt) {
126 auto n = static_cast<std::size_t>(nt);
127 tri_v0.resize(n, 0);
128 tri_v1.resize(n, 0);
129 tri_v2.resize(n, 0);
130 tri_nbr0.resize(n, -1);
131 tri_nbr1.resize(n, -1);
132 tri_nbr2.resize(n, -1);
133 tri_area.resize(n, 0.0);
134 tri_cx.resize(n, 0.0);
135 tri_cy.resize(n, 0.0);
136 tri_cz.resize(n, 0.0);
137
138 auto n3 = static_cast<std::size_t>(nt) * 3;
139 edge_length.resize(n3, 0.0);
140 edge_nx.resize(n3, 0.0);
141 edge_ny.resize(n3, 0.0);
142 edge_mx.resize(n3, 0.0);
143 edge_my.resize(n3, 0.0);
144 edge_mz.resize(n3, 0.0);
145
146 mannings_n.resize(n, 0.035);
147 tri_tag.resize(n);
148 tri_coupled_node.resize(n, -1);
149 tri_coupled_node_name.resize(n);
150 tri_coupling_cd.resize(n, 0.65);
151 tri_coupling_area.resize(n, 1.0);
152 }
153};
154
155} // namespace openswmm::twoD
156
157#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:96
std::vector< int > tri_v1
Vertex 1 index.
Definition MeshData.hpp:51
int n_triangles() const noexcept
Definition MeshData.hpp:107
std::vector< int > vert_stencil_idx
Column indices (triangle indices)
Definition MeshData.hpp:82
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:125
std::vector< std::string > tri_coupled_node_name
Definition MeshData.hpp:100
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:90
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:89
std::vector< double > vert_coupling_area
Effective exchange area (m²)
Definition MeshData.hpp:94
std::vector< double > tri_cx
Centroid X.
Definition MeshData.hpp:61
std::vector< std::string > tri_tag
Optional triangle tag.
Definition MeshData.hpp:75
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:81
std::vector< double > vz
Vertex Z (ground elevation)
Definition MeshData.hpp:42
std::vector< std::string > vert_coupled_node_name
Definition MeshData.hpp:99
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:74
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:83
int n_vertices() const noexcept
Definition MeshData.hpp:106
std::vector< double > tri_coupling_cd
Discharge coefficient.
Definition MeshData.hpp:95
void resize_vertices(int nv)
Definition MeshData.hpp:113
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:93