OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
InertialEdges.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2//
3// Copyright 2026 Caleb Buahin
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
46
47#ifndef OPENSWMM_ENGINE_2D_INERTIAL_EDGES_HPP
48#define OPENSWMM_ENGINE_2D_INERTIAL_EDGES_HPP
49
50#include <cstdint>
51#include <vector>
52
53namespace openswmm::twoD {
54
55struct MeshData;
56
62 int ne = 0;
63
64 // Per-edge arrays (size ne), oriented cL→cR (cL = min(t,nbr), cR = max).
65 std::vector<int> cL, cR;
66 std::vector<double> xi;
67 std::vector<double> inv_dx;
68 std::vector<double> zface;
74 std::vector<double> ze_lo, ze_hi;
75 std::vector<int> slotL, slotR;
76
77 // Explicit-marcher extension (ExplicitInertialSolver). Precomputed here so
78 // the per-substep kernels stay pure arithmetic.
79 std::vector<double> nx, ny;
80 std::vector<double> mx, my;
85 std::vector<double> inv_dx_normal;
86 std::vector<double> n2_face;
87 std::vector<double> n_face;
92 std::vector<double> cell_lchar;
97 std::vector<double> cell_lpos;
98
99 // Per-cell CSR incidence for the conservative continuity gather. For cell i,
100 // the incident edges are cell_edge[cell_ptr[i] .. cell_ptr[i+1]) with sign
101 // cell_sign (+1 if i==cL, −1 if i==cR). Then
102 // dV_i/dt (flux part) = − Σ cell_sign · q[edge] · ξ[edge].
103 std::vector<int> cell_ptr;
104 std::vector<int> cell_edge;
108 std::vector<int8_t> cell_sign;
113 std::vector<double> cell_arm_x, cell_arm_y;
114
116 void build(const MeshData& mesh);
117
118 bool empty() const noexcept { return ne == 0; }
119};
120
121} // namespace openswmm::twoD
122
123#endif // OPENSWMM_ENGINE_2D_INERTIAL_EDGES_HPP
Definition NodeCoupling.cpp:16
Canonical unique interior-edge layout + per-cell incidence for the local-inertial scheme.
Definition InertialEdges.hpp:61
bool empty() const noexcept
Definition InertialEdges.hpp:118
std::vector< double > n2_face
(½(n_L+n_R))² Manning coefficient
Definition InertialEdges.hpp:86
std::vector< double > cell_lpos
Definition InertialEdges.hpp:97
std::vector< double > n_face
Definition InertialEdges.hpp:87
std::vector< double > xi
edge length ξ (m)
Definition InertialEdges.hpp:66
std::vector< double > inv_dx
1 / centroid-to-centroid distance (1/m)
Definition InertialEdges.hpp:67
std::vector< double > mx
Definition InertialEdges.hpp:80
std::vector< double > cell_arm_y
Definition InertialEdges.hpp:113
std::vector< double > cell_lchar
Definition InertialEdges.hpp:92
std::vector< double > ze_hi
Definition InertialEdges.hpp:74
std::vector< double > cell_arm_x
Definition InertialEdges.hpp:113
void build(const MeshData &mesh)
Build the structure from mesh topology. O(n_triangles).
Definition InertialEdges.cpp:18
std::vector< double > nx
Definition InertialEdges.hpp:79
std::vector< double > zface
Definition InertialEdges.hpp:68
std::vector< int > cL
Definition InertialEdges.hpp:65
std::vector< double > ze_lo
Definition InertialEdges.hpp:74
std::vector< int > slotR
flat mesh edge slots [cell*kMaxCellVerts+e] for writeback
Definition InertialEdges.hpp:75
std::vector< int > slotL
Definition InertialEdges.hpp:75
int ne
number of interior (q-carrying) edges
Definition InertialEdges.hpp:62
std::vector< double > ny
unit normal, oriented cL→cR
Definition InertialEdges.hpp:79
std::vector< int > cell_ptr
[n_triangles + 1] CSR row pointers
Definition InertialEdges.hpp:103
std::vector< int8_t > cell_sign
Definition InertialEdges.hpp:108
std::vector< int > cell_edge
Definition InertialEdges.hpp:104
std::vector< int > cR
incident cell indices
Definition InertialEdges.hpp:65
std::vector< double > my
Definition InertialEdges.hpp:80
std::vector< double > inv_dx_normal
Definition InertialEdges.hpp:85
SoA storage for 2D mixed triangle/quad mesh geometry and topology.
Definition MeshData.hpp:67