OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm::twoD::MeshData Struct Reference

SoA storage for 2D mixed triangle/quad mesh geometry and topology. More...

#include <MeshData.hpp>

Collaboration diagram for openswmm::twoD::MeshData:

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
 

Detailed Description

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.

Member Function Documentation

◆ cell_edge_vertices()

void openswmm::twoD::MeshData::cell_edge_vertices ( int c,
int k,
int & a,
int & b ) const
inlinenoexcept

Endpoint vertices of local edge k of cell c: v[(k+1)nv], v[(k+2)nv].

Parameters
[in]cValid zero-based cell index with a nonzero stored vertex count.
[in]kActual local edge, in [0,cell_vertex_count(c)).
[out]aFirst endpoint's zero-based vertex index.
[out]bSecond endpoint's zero-based vertex index; use a distinct output reference.
Note
Uses the shared rotated cyclic-edge convention for triangles and quads; no checks, allocation or mutation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cell_neighbour()

int openswmm::twoD::MeshData::cell_neighbour ( int c,
int k ) const
inlinenoexcept

Read one mixed-cell topology field.

Parameters
[in]cZero-based cell in [0,n_cells()); unchecked.
[in]kLocal padded slot in [0,kMaxCellVerts); caller distinguishes actual edges from padding.
Returns
Adjacent cell, -1 for exterior edges, or -2 for padding.
Note
Read-only, unchecked and allocation-free; backing arrays must be coherently sized and stable.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cell_vertex()

int openswmm::twoD::MeshData::cell_vertex ( int c,
int k ) const
inlinenoexcept

Read one mixed-cell topology field.

Parameters
[in]cZero-based cell in [0,n_cells()); unchecked.
[in]kLocal padded slot in [0,kMaxCellVerts); caller distinguishes actual edges from padding.
Returns
Zero-based referenced vertex, or -1 in a triangle padding slot.
Note
Read-only, unchecked and allocation-free; backing arrays must be coherently sized and stable.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cell_vertex_count()

int openswmm::twoD::MeshData::cell_vertex_count ( int c) const
inlinenoexcept

Read one mixed-cell topology field.

Parameters
[in]cZero-based cell in [0,n_cells()); unchecked.
Returns
Stored vertex count, normally three or four.
Note
Read-only, unchecked and allocation-free; backing arrays must be coherently sized and stable.
Here is the caller graph for this function:

◆ edge_stride()

int openswmm::twoD::MeshData::edge_stride ( ) const
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.

Note
Select the packed public edge-array stride.
Returns
Four when any quad exists, otherwise three, including an empty mesh; O(cell_count) scan.
Note
Read-only and allocation-free. Serialize reads with mesh resizing/mutation.
Here is the call graph for this function:

◆ is_quad()

bool openswmm::twoD::MeshData::is_quad ( int c) const
inlinenoexcept

Read one mixed-cell topology field.

Parameters
[in]cZero-based cell in [0,n_cells()); unchecked.
Returns
True exactly when the stored vertex count is four.
Note
Read-only, unchecked and allocation-free; backing arrays must be coherently sized and stable.

◆ n_cells()

int openswmm::twoD::MeshData::n_cells ( ) const
inlinenoexcept

Read the mixed-cell extent.

Returns
Number of cell_nv entries narrowed to int.
Note
Read-only and allocation-free. Serialize reads with mesh resizing/mutation.
Here is the caller graph for this function:

◆ n_edge_slots()

int openswmm::twoD::MeshData::n_edge_slots ( ) const
inlinenoexcept

Number of internal edge slots (n_cells * kMaxCellVerts).

Note
Read the padded internal edge-array extent.
Returns
n_cells() * kMaxCellVerts; caller ensures the int multiplication is representable.
Note
Read-only and allocation-free. Serialize reads with mesh resizing/mutation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ n_quads()

int openswmm::twoD::MeshData::n_quads ( ) const
inlinenoexcept

Number of quadrilateral cells (O(n) scan; not a hot path).

Note
Count quadrilateral cells.
Returns
Count of entries equal to four; scans all cell_nv values without validating other counts.
Note
Read-only and allocation-free. Serialize reads with mesh resizing/mutation.
Here is the caller graph for this function:

◆ n_triangles()

int openswmm::twoD::MeshData::n_triangles ( ) const
inlinenoexcept

Number of CELLS (triangles + quads). The historical name is kept for the ~200 call sites; n_cells() is the same value.

Note
Read the historical per-cell extent.
Returns
Number of mixed cells, triangles plus quadrilaterals, narrowed to int.
Note
Read-only and allocation-free. Serialize reads with mesh resizing/mutation.
Here is the caller graph for this function:

◆ n_vertices()

int openswmm::twoD::MeshData::n_vertices ( ) const
inlinenoexcept

Read the vertex-array extent.

Returns
Number of vx entries narrowed to int; parallel vertex arrays are expected to match.
Note
Read-only and allocation-free. Serialize reads with mesh resizing/mutation.
Here is the caller graph for this function:

◆ resize_triangles()

void openswmm::twoD::MeshData::resize_triangles ( int nt)
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.

Parameters
[in]ntNonnegative target mixed-cell count; the historical name includes quads.
Postcondition
Preserves existing entries and initializes appended geometry/properties and padded slots. Does not rebuild topology/stencils, resize existing quad VFR side data, or prune tri_couplings referring to removed cells.
Note
Callers reconstruct those dependent arrays before use. Vector allocations may throw after partial resize and invalidate references; requires exclusive mesh access. No physical-unit conversion.
Here is the caller graph for this function:

◆ resize_vertices()

void openswmm::twoD::MeshData::resize_vertices ( int nv)
inline

Resize vertex coordinates, tags and vertex coupling arrays.

Parameters
[in]nvNonnegative target vertex count, representable as size_t.
Postcondition
Preserves existing entries, initializes new coordinates/tags and coupling defaults, and truncates removed entries. Does not rebuild cell references/stencils or validate dangling connectivity.
Note
Vector allocations may throw after partial resize; requires exclusive mesh access and invalidates element pointers/references. No rollback or unit conversion.
Here is the caller graph for this function:

◆ set_quad()

void openswmm::twoD::MeshData::set_quad ( int c,
int v0,
int v1,
int v2,
int v3 )
inlinenoexcept

Assign 4-vertex connectivity to one preallocated cell.

Parameters
[in]cValid zero-based cell index with allocated cell_nv/cell_v storage.
[in]v0Valid vertex index in cyclic order; not checked.
[in]v1Valid vertex index in cyclic order; not checked.
[in]v2Valid vertex index in cyclic order; not checked.
[in]v3Valid vertex index in cyclic order; not checked.
Postcondition
Updates only vertex count/connectivity. Neighbor topology, geometry, quad VFR and stencils must be rebuilt by the caller. No allocation, orientation validation, or runtime state changes.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_triangle()

void openswmm::twoD::MeshData::set_triangle ( int c,
int v0,
int v1,
int v2 )
inlinenoexcept

Assign 3-vertex connectivity to one preallocated cell.

Parameters
[in]cValid zero-based cell index with allocated cell_nv/cell_v storage.
[in]v0Valid vertex index in cyclic order; not checked.
[in]v1Valid vertex index in cyclic order; not checked.
[in]v2Valid vertex index in cyclic order; not checked.
Postcondition
Updates only vertex count/connectivity; the fourth vertex slot becomes -1. Neighbor topology, geometry, quad VFR and stencils must be rebuilt by the caller. No allocation, orientation validation, or runtime state changes.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ slot()

static constexpr int openswmm::twoD::MeshData::slot ( int c,
int k )
inlinestaticconstexprnoexcept

Flat edge/vertex slot of local index k in cell c.

Note
Convert mixed-mesh padded slot coordinates.
Parameters
[in]cNonnegative zero-based cell index.
[in]kLocal padded slot in [0,kMaxCellVerts).
Returns
Padded internal offset c*kMaxCellVerts+k; arithmetic and ranges are unchecked.
Note
Pure integer mapping; caller prevents signed overflow.
Here is the caller graph for this function:

◆ slot_cell()

static constexpr int openswmm::twoD::MeshData::slot_cell ( int s)
inlinestaticconstexprnoexcept

Convert mixed-mesh padded slot coordinates.

Parameters
[in]sNonnegative padded internal slot.
Returns
Owning cell offset s / kMaxCellVerts.
Note
Pure integer mapping; caller prevents signed overflow.
Here is the caller graph for this function:

◆ slot_local()

static constexpr int openswmm::twoD::MeshData::slot_local ( int s)
inlinestaticconstexprnoexcept

Local index k of a flat slot; cell of a flat slot.

Note
Convert mixed-mesh padded slot coordinates.
Parameters
[in]sNonnegative padded internal slot.
Returns
Local padded offset s % kMaxCellVerts.
Note
Pure integer mapping; caller prevents signed overflow.
Here is the caller graph for this function:

Member Data Documentation

◆ cell_nbr

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).

◆ cell_nv

std::vector<uint8_t> openswmm::twoD::MeshData::cell_nv

Vertices per cell: 3 (triangle) or 4 (quadrilateral).

◆ cell_v

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).

◆ edge_conveyance

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).

◆ edge_dist_c

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.

◆ edge_length

std::vector<double> openswmm::twoD::MeshData::edge_length

Length of each edge.

◆ edge_mx

std::vector<double> openswmm::twoD::MeshData::edge_mx

Edge midpoint X.

◆ edge_my

std::vector<double> openswmm::twoD::MeshData::edge_my

Edge midpoint Y.

◆ edge_mz

std::vector<double> openswmm::twoD::MeshData::edge_mz

Edge midpoint Z (interpolated)

◆ edge_nx

std::vector<double> openswmm::twoD::MeshData::edge_nx

Outward normal X component.

◆ edge_ny

std::vector<double> openswmm::twoD::MeshData::edge_ny

Outward normal Y component.

◆ mannings_n

std::vector<double> openswmm::twoD::MeshData::mannings_n

Manning's roughness coefficient.

◆ quad_vfr_a

std::vector<double> openswmm::twoD::MeshData::quad_vfr_a

◆ quad_vfr_z

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.

◆ tri_area

std::vector<double> openswmm::twoD::MeshData::tri_area

Planimetric area (m²)

◆ tri_coupled_node

std::vector<int> openswmm::twoD::MeshData::tri_coupled_node

SWMM node index (-1 = none)

◆ tri_coupled_node_name

std::vector<std::string> openswmm::twoD::MeshData::tri_coupled_node_name

◆ tri_coupling_area

std::vector<double> openswmm::twoD::MeshData::tri_coupling_area

Effective exchange area.

◆ tri_coupling_cd

std::vector<double> openswmm::twoD::MeshData::tri_coupling_cd

Discharge coefficient.

◆ tri_couplings

std::vector<TriCouplingRow> openswmm::twoD::MeshData::tri_couplings

◆ tri_cx

std::vector<double> openswmm::twoD::MeshData::tri_cx

Centroid X (area centroid)

◆ tri_cy

std::vector<double> openswmm::twoD::MeshData::tri_cy

Centroid Y (area centroid)

◆ tri_cz

std::vector<double> openswmm::twoD::MeshData::tri_cz

Mean of the cell's vertex elevations.

◆ tri_init_depth

std::vector<double> openswmm::twoD::MeshData::tri_init_depth

Initial water depth (m, default 0 = dry)

◆ tri_init_u

std::vector<double> openswmm::twoD::MeshData::tri_init_u

[2D_INITIAL_VELOCITY] u (m/s, default 0)

◆ tri_init_v

std::vector<double> openswmm::twoD::MeshData::tri_init_v

[2D_INITIAL_VELOCITY] v (m/s, default 0)

◆ tri_tag

std::vector<std::string> openswmm::twoD::MeshData::tri_tag

Optional triangle tag.

◆ vert_coupled_node

std::vector<int> openswmm::twoD::MeshData::vert_coupled_node

SWMM node index (-1 = none)

◆ vert_coupled_node_name

std::vector<std::string> openswmm::twoD::MeshData::vert_coupled_node_name

◆ vert_coupling_area

std::vector<double> openswmm::twoD::MeshData::vert_coupling_area

Effective exchange area (m²)

◆ vert_coupling_area_set

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.

◆ vert_coupling_cd

std::vector<double> openswmm::twoD::MeshData::vert_coupling_cd

Discharge coefficient (default 0.65)

◆ vert_coupling_cd_set

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.

◆ vert_stencil_idx

std::vector<int> openswmm::twoD::MeshData::vert_stencil_idx

Column indices (triangle indices)

◆ vert_stencil_ptr

std::vector<int> openswmm::twoD::MeshData::vert_stencil_ptr

[n_vertices + 1] row pointers

◆ vert_stencil_wt

std::vector<double> openswmm::twoD::MeshData::vert_stencil_wt

Pseudo-Laplacian weights.

◆ vtag

std::vector<std::string> openswmm::twoD::MeshData::vtag

Optional vertex tag.

◆ vx

std::vector<double> openswmm::twoD::MeshData::vx

Vertex X coordinate.

◆ vy

std::vector<double> openswmm::twoD::MeshData::vy

Vertex Y coordinate.

◆ vz

std::vector<double> openswmm::twoD::MeshData::vz

Vertex Z (ground elevation)


The documentation for this struct was generated from the following file: