![]() |
OpenSWMM Engine
6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
|
SoA storage for 2D mixed triangle/quad mesh geometry and topology. More...
#include <MeshData.hpp>
Classes | |
| struct | TriCouplingRow |
Public Member Functions | |
| int | n_vertices () const noexcept |
| Read the vertex-array extent. | |
| int | n_triangles () const noexcept |
Number of CELLS (triangles + quads). The historical name is kept for the ~200 call sites; n_cells() is the same value. | |
| int | n_cells () const noexcept |
| Read the mixed-cell extent. | |
| int | n_quads () const noexcept |
| Number of quadrilateral cells (O(n) scan; not a hot path). | |
| int | edge_stride () const noexcept |
| Edge-slot stride of the PUBLIC (API / HDF5) layout: 3 for an all-triangle mesh (byte-compatible with every existing consumer), kMaxCellVerts once a quad exists. Internal SoAs always use kMaxCellVerts. | |
| int | n_edge_slots () const noexcept |
| Number of internal edge slots (n_cells * kMaxCellVerts). | |
| int | cell_vertex_count (int c) const noexcept |
| Read one mixed-cell topology field. | |
| int | cell_vertex (int c, int k) const noexcept |
| Read one mixed-cell topology field. | |
| int | cell_neighbour (int c, int k) const noexcept |
| Read one mixed-cell topology field. | |
| bool | is_quad (int c) const noexcept |
| Read one mixed-cell topology field. | |
| 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]. | |
| void | set_triangle (int c, int v0, int v1, int v2) noexcept |
| Assign 3-vertex connectivity to one preallocated cell. | |
| void | set_quad (int c, int v0, int v1, int v2, int v3) noexcept |
| Assign 4-vertex connectivity to one preallocated cell. | |
| void | resize_vertices (int nv) |
| Resize vertex coordinates, tags and vertex coupling arrays. | |
| void | resize_triangles (int nt) |
| Resize the per-cell arrays to nt cells. New cells are TRIANGLES (cell_nv = 3, vertex slots 0 / padding −1) until set_quad() is called. | |
Static Public Member Functions | |
| static constexpr int | slot (int c, int k) noexcept |
| Flat edge/vertex slot of local index k in cell c. | |
| static constexpr int | slot_local (int s) noexcept |
| Local index k of a flat slot; cell of a flat slot. | |
| static constexpr int | slot_cell (int s) noexcept |
| Convert mixed-mesh padded slot coordinates. | |
Public Attributes | |
| std::vector< double > | vx |
| Vertex X coordinate. | |
| std::vector< double > | vy |
| Vertex Y coordinate. | |
| std::vector< double > | vz |
| Vertex Z (ground elevation) | |
| std::vector< std::string > | vtag |
| Optional vertex tag. | |
| std::vector< uint8_t > | cell_nv |
| Vertices per cell: 3 (triangle) or 4 (quadrilateral). | |
| std::vector< int > | cell_v |
| std::vector< int > | cell_nbr |
| std::vector< double > | tri_area |
| Planimetric area (m²) | |
| std::vector< double > | tri_cx |
| Centroid X (area centroid) | |
| std::vector< double > | tri_cy |
| Centroid Y (area centroid) | |
| std::vector< double > | tri_cz |
| Mean of the cell's vertex elevations. | |
| std::vector< double > | edge_length |
| Length of each edge. | |
| std::vector< double > | edge_nx |
| Outward normal X component. | |
| std::vector< double > | edge_ny |
| Outward normal Y component. | |
| std::vector< double > | edge_mx |
| Edge midpoint X. | |
| std::vector< double > | edge_my |
| Edge midpoint Y. | |
| std::vector< double > | edge_mz |
| std::vector< double > | edge_dist_c |
| std::vector< double > | quad_vfr_z |
| std::vector< double > | quad_vfr_a |
| std::vector< double > | edge_conveyance |
| std::vector< double > | mannings_n |
| Manning's roughness coefficient. | |
| std::vector< double > | tri_init_depth |
| Initial water depth (m, default 0 = dry) | |
| std::vector< double > | tri_init_u |
| [2D_INITIAL_VELOCITY] u (m/s, default 0) | |
| std::vector< double > | tri_init_v |
| [2D_INITIAL_VELOCITY] v (m/s, default 0) | |
| std::vector< std::string > | tri_tag |
| Optional triangle tag. | |
| std::vector< int > | vert_stencil_ptr |
| [n_vertices + 1] row pointers | |
| std::vector< int > | vert_stencil_idx |
| Column indices (triangle indices) | |
| std::vector< double > | vert_stencil_wt |
| Pseudo-Laplacian weights. | |
| std::vector< int > | vert_coupled_node |
| SWMM node index (-1 = none) | |
| std::vector< int > | tri_coupled_node |
| SWMM node index (-1 = none) | |
| std::vector< double > | vert_coupling_cd |
| std::vector< uint8_t > | vert_coupling_cd_set |
| std::vector< double > | vert_coupling_area |
| std::vector< uint8_t > | vert_coupling_area_set |
| std::vector< double > | tri_coupling_cd |
| Discharge coefficient. | |
| std::vector< double > | tri_coupling_area |
| Effective exchange area. | |
| std::vector< std::string > | vert_coupled_node_name |
| std::vector< std::string > | tri_coupled_node_name |
| std::vector< TriCouplingRow > | tri_couplings |
SoA storage for 2D mixed triangle/quad mesh geometry and topology.
All vertex arrays are indexed by vertex index [0, n_vertices). All cell arrays are indexed by cell index [0, n_triangles()) — the historical tri_* names are kept for the per-cell scalar arrays; a "tri" is any cell (triangle or quad). Cells are ordered triangles first, then quads (the [2D_TRIANGLES] rows, then the [2D_QUADS] rows). Edge / connectivity arrays are flat 2D: [cell * kMaxCellVerts + k] for k in [0, cell_nv[cell]).
Local-edge convention (unified for both shapes): edge k has endpoints v[(k+1) % nv], v[(k+2) % nv]. For a triangle this is the historical "edge k is opposite vertex k" rule, so every existing TRI EDGE row keeps its meaning; for a quad it is a fixed rotation of the natural numbering.
|
inlinenoexcept |
Endpoint vertices of local edge k of cell c: v[(k+1)nv], v[(k+2)nv].
| [in] | c | Valid zero-based cell index with a nonzero stored vertex count. |
| [in] | k | Actual local edge, in [0,cell_vertex_count(c)). |
| [out] | a | First endpoint's zero-based vertex index. |
| [out] | b | Second endpoint's zero-based vertex index; use a distinct output reference. |
|
inlinenoexcept |
Read one mixed-cell topology field.
| [in] | c | Zero-based cell in [0,n_cells()); unchecked. |
| [in] | k | Local padded slot in [0,kMaxCellVerts); caller distinguishes actual edges from padding. |
|
inlinenoexcept |
Read one mixed-cell topology field.
| [in] | c | Zero-based cell in [0,n_cells()); unchecked. |
| [in] | k | Local padded slot in [0,kMaxCellVerts); caller distinguishes actual edges from padding. |
|
inlinenoexcept |
Read one mixed-cell topology field.
| [in] | c | Zero-based cell in [0,n_cells()); unchecked. |
|
inlinenoexcept |
Edge-slot stride of the PUBLIC (API / HDF5) layout: 3 for an all-triangle mesh (byte-compatible with every existing consumer), kMaxCellVerts once a quad exists. Internal SoAs always use kMaxCellVerts.
|
inlinenoexcept |
Read one mixed-cell topology field.
| [in] | c | Zero-based cell in [0,n_cells()); unchecked. |
|
inlinenoexcept |
Read the mixed-cell extent.
|
inlinenoexcept |
Number of internal edge slots (n_cells * kMaxCellVerts).
|
inlinenoexcept |
Number of quadrilateral cells (O(n) scan; not a hot path).
|
inlinenoexcept |
Number of CELLS (triangles + quads). The historical name is kept for the ~200 call sites; n_cells() is the same value.
|
inlinenoexcept |
Read the vertex-array extent.
|
inline |
Resize the per-cell arrays to nt cells. New cells are TRIANGLES (cell_nv = 3, vertex slots 0 / padding −1) until set_quad() is called.
| [in] | nt | Nonnegative target mixed-cell count; the historical name includes quads. |
|
inline |
Resize vertex coordinates, tags and vertex coupling arrays.
| [in] | nv | Nonnegative target vertex count, representable as size_t. |
|
inlinenoexcept |
Assign 4-vertex connectivity to one preallocated cell.
| [in] | c | Valid zero-based cell index with allocated cell_nv/cell_v storage. |
| [in] | v0 | Valid vertex index in cyclic order; not checked. |
| [in] | v1 | Valid vertex index in cyclic order; not checked. |
| [in] | v2 | Valid vertex index in cyclic order; not checked. |
| [in] | v3 | Valid vertex index in cyclic order; not checked. |
|
inlinenoexcept |
Assign 3-vertex connectivity to one preallocated cell.
| [in] | c | Valid zero-based cell index with allocated cell_nv/cell_v storage. |
| [in] | v0 | Valid vertex index in cyclic order; not checked. |
| [in] | v1 | Valid vertex index in cyclic order; not checked. |
| [in] | v2 | Valid vertex index in cyclic order; not checked. |
|
inlinestaticconstexprnoexcept |
Flat edge/vertex slot of local index k in cell c.
| [in] | c | Nonnegative zero-based cell index. |
| [in] | k | Local padded slot in [0,kMaxCellVerts). |
|
inlinestaticconstexprnoexcept |
Convert mixed-mesh padded slot coordinates.
| [in] | s | Nonnegative padded internal slot. |
|
inlinestaticconstexprnoexcept |
Local index k of a flat slot; cell of a flat slot.
| [in] | s | Nonnegative padded internal slot. |
| std::vector<int> openswmm::twoD::MeshData::cell_nbr |
Neighbour across local edge k, padded: [cell * kMaxCellVerts + k]. −1 = boundary edge, −2 = padding slot (k ≥ cell_nv).
| std::vector<uint8_t> openswmm::twoD::MeshData::cell_nv |
Vertices per cell: 3 (triangle) or 4 (quadrilateral).
| std::vector<int> openswmm::twoD::MeshData::cell_v |
Connectivity, padded: [cell * kMaxCellVerts + k]; −1 in padding slots. Counter-clockwise order (MeshBuilder orients the outward normals from the centroid, so a clockwise triangle still works; quads are validated CCW + convex at parse time).
| std::vector<double> openswmm::twoD::MeshData::edge_conveyance |
Per-edge conveyance factor in [0, 1], flat 2D [cell * kMaxCellVerts + k]. Default 1.0 (unrestricted) for every edge. Scales transported and reported interior face flux; zero blocks exchange. The explicit local-inertial solvers keep ψ separate from geometric width and CFL lengths. Symmetric: an interior edge's two MeshData::slot(cell, edge) entries must carry the same value; SurfaceRouter2D::initialize enforces this when draining the [2D_EDGE_CONVEYANCE] pending rows. See §11A of docs/2dModelStrategy.md.
Cross-reference: this is the edge transmissivity ψ in the Integral-Porosity Shallow-Water literature (Sanders 2008; Bruwier et al. 2017).
| std::vector<double> openswmm::twoD::MeshData::edge_dist_c |
Centroid → edge-midpoint distance along the outward normal, (m⃗_e − c⃗)·n̂_e (m). For a triangle this equals the classic 2A/(3ξ) (the centroid sits one third of the altitude up); for a quad it is the exact normal distance. The ghost-cell arm every boundary-edge law uses.
| std::vector<double> openswmm::twoD::MeshData::edge_length |
Length of each edge.
| std::vector<double> openswmm::twoD::MeshData::edge_mx |
Edge midpoint X.
| std::vector<double> openswmm::twoD::MeshData::edge_my |
Edge midpoint Y.
| std::vector<double> openswmm::twoD::MeshData::edge_mz |
Edge midpoint Z (interpolated)
| std::vector<double> openswmm::twoD::MeshData::edge_nx |
Outward normal X component.
| std::vector<double> openswmm::twoD::MeshData::edge_ny |
Outward normal Y component.
| std::vector<double> openswmm::twoD::MeshData::mannings_n |
Manning's roughness coefficient.
| std::vector<double> openswmm::twoD::MeshData::quad_vfr_a |
| std::vector<double> openswmm::twoD::MeshData::quad_vfr_z |
Quad VFR precomputed data (B&S 2007 two-plane storage model, see mesh/QuadVfr.hpp): per CELL, six sorted sub-triangle elevations [cell*6 + k] and two sub-triangle areas [cell*2 + k]. Allocated only when the mesh holds at least one quad (empty otherwise); triangle rows are zero and never read. Rebuilt by MeshBuilder with the z-dependents.
| std::vector<double> openswmm::twoD::MeshData::tri_area |
Planimetric area (m²)
| std::vector<int> openswmm::twoD::MeshData::tri_coupled_node |
SWMM node index (-1 = none)
| std::vector<std::string> openswmm::twoD::MeshData::tri_coupled_node_name |
| std::vector<double> openswmm::twoD::MeshData::tri_coupling_area |
Effective exchange area.
| std::vector<double> openswmm::twoD::MeshData::tri_coupling_cd |
Discharge coefficient.
| std::vector<TriCouplingRow> openswmm::twoD::MeshData::tri_couplings |
| std::vector<double> openswmm::twoD::MeshData::tri_cx |
Centroid X (area centroid)
| std::vector<double> openswmm::twoD::MeshData::tri_cy |
Centroid Y (area centroid)
| std::vector<double> openswmm::twoD::MeshData::tri_cz |
Mean of the cell's vertex elevations.
| std::vector<double> openswmm::twoD::MeshData::tri_init_depth |
Initial water depth (m, default 0 = dry)
| std::vector<double> openswmm::twoD::MeshData::tri_init_u |
[2D_INITIAL_VELOCITY] u (m/s, default 0)
| std::vector<double> openswmm::twoD::MeshData::tri_init_v |
[2D_INITIAL_VELOCITY] v (m/s, default 0)
| std::vector<std::string> openswmm::twoD::MeshData::tri_tag |
Optional triangle tag.
| std::vector<int> openswmm::twoD::MeshData::vert_coupled_node |
SWMM node index (-1 = none)
| std::vector<std::string> openswmm::twoD::MeshData::vert_coupled_node_name |
| std::vector<double> openswmm::twoD::MeshData::vert_coupling_area |
Effective exchange area (m²)
| std::vector<uint8_t> openswmm::twoD::MeshData::vert_coupling_area_set |
1 when the [2D_VERTEX_NODE_MAP] row authored an explicit AREA token. Rows without one keep the 1.0 default value but are eligible for the COUPLING_AREA AUTO derivation at coupling-point resolve.
| std::vector<double> openswmm::twoD::MeshData::vert_coupling_cd |
Discharge coefficient (default 0.65)
| std::vector<uint8_t> openswmm::twoD::MeshData::vert_coupling_cd_set |
1 when the coupling CD was authored (a [2D_VERTEX_NODE_MAP] CD token or an API edit). Coupling points without one take [2D_OPTIONS] COUPLING_CD.
| std::vector<int> openswmm::twoD::MeshData::vert_stencil_idx |
Column indices (triangle indices)
| std::vector<int> openswmm::twoD::MeshData::vert_stencil_ptr |
[n_vertices + 1] row pointers
| std::vector<double> openswmm::twoD::MeshData::vert_stencil_wt |
Pseudo-Laplacian weights.
| std::vector<std::string> openswmm::twoD::MeshData::vtag |
Optional vertex tag.
| std::vector<double> openswmm::twoD::MeshData::vx |
Vertex X coordinate.
| std::vector<double> openswmm::twoD::MeshData::vy |
Vertex Y coordinate.
| std::vector<double> openswmm::twoD::MeshData::vz |
Vertex Z (ground elevation)