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
45
46#ifndef OPENSWMM_ENGINE_2D_INERTIAL_EDGES_HPP
47#define OPENSWMM_ENGINE_2D_INERTIAL_EDGES_HPP
48
49#include <cstdint>
50#include <vector>
51
52namespace openswmm::twoD {
53
54struct MeshData;
55
61 int ne = 0;
62
63 // Per-edge arrays (size ne), oriented cL→cR (cL = min(t,nbr), cR = max).
64 std::vector<int> cL, cR;
65 std::vector<double> xi;
66 std::vector<double> conveyance;
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] · ξ[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
129 void build(const MeshData& mesh);
130
134 bool refreshConveyance(const MeshData& mesh);
135
141 bool empty() const noexcept { return ne == 0; }
142};
143
144} // namespace openswmm::twoD
145
146#endif // OPENSWMM_ENGINE_2D_INERTIAL_EDGES_HPP
Definition ExchangeLaw.hpp:60
Canonical unique interior-edge layout + per-cell incidence for the local-inertial scheme.
Definition InertialEdges.hpp:60
bool empty() const noexcept
Test whether the built layout has any interior discharge edges.
Definition InertialEdges.hpp:141
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 > conveyance
face transmissivity ψ in [0, 1], separate from CFL geometry
Definition InertialEdges.hpp:66
std::vector< double > xi
geometric edge length ξ (m), unchanged by conveyance
Definition InertialEdges.hpp:65
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
bool refreshConveyance(const MeshData &mesh)
Definition InertialEdges.cpp:199
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:22
std::vector< double > nx
Definition InertialEdges.hpp:79
std::vector< double > zface
Definition InertialEdges.hpp:68
std::vector< int > cL
Definition InertialEdges.hpp:64
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:61
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:64
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:65