OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
SurfaceFluxCalculator.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
33
34#ifndef OPENSWMM_ENGINE_2D_SURFACE_FLUX_CALCULATOR_HPP
35#define OPENSWMM_ENGINE_2D_SURFACE_FLUX_CALCULATOR_HPP
36
37#include "../data/MeshData.hpp"
40
41namespace openswmm::twoD {
42
61void computeUnlimitedGradients(const MeshData& mesh, SurfaceStateData& state, int nthreads = 1);
62
81void computeLimitedGradients(const MeshData& mesh, SurfaceStateData& state, double epsilon,
82 int nthreads = 1);
83
101inline double evapSink(double rate, double depth, double dry_depth) noexcept {
102 if (rate <= 0.0 || depth <= 0.0)
103 return 0.0;
104 if (depth >= dry_depth)
105 return rate;
106 double t = depth / dry_depth;
107 return rate * t * t * (3.0 - 2.0 * t);
108}
109
133inline double infilSink(double rate, double depth, double dry_depth) noexcept {
134 if (rate <= 0.0 || depth <= 0.0)
135 return 0.0;
136 if (depth >= dry_depth)
137 return rate;
138 double t = depth / dry_depth;
139 return rate * t * t * (3.0 - 2.0 * t);
140}
141
164double computeBoundaryEdgeFlux(const MeshData& mesh, const SurfaceStateData& state,
165 const SolverOptions2D& opts, double dh_eps, int i, int idx) noexcept;
166
193void computeCellContinuity(const MeshData& mesh, SurfaceStateData& state,
194 const SolverOptions2D& opts, double dt);
195
217void computeFaceVelocity(const MeshData& mesh, SurfaceStateData& state,
218 const SolverOptions2D& opts);
219
220} // namespace openswmm::twoD
221
222#endif // OPENSWMM_ENGINE_2D_SURFACE_FLUX_CALCULATOR_HPP
Structure-of-Arrays (SoA) storage for 2D triangular mesh geometry.
Configuration options for the 2D surface routing solver.
Structure-of-Arrays (SoA) storage for 2D surface routing state.
Definition ExchangeLaw.hpp:60
void computeFaceVelocity(const MeshData &mesh, SurfaceStateData &state, const SolverOptions2D &opts)
Reconstruct diagnostic cell velocity from wetted-edge normal velocities.
Definition SurfaceFluxCalculator.cpp:404
double infilSink(double rate, double depth, double dry_depth) noexcept
Depth-limited infiltration sink rate (m/s) for one cell (plan §5.5).
Definition SurfaceFluxCalculator.hpp:133
void computeCellContinuity(const MeshData &mesh, SurfaceStateData &state, const SolverOptions2D &opts, double dt)
Compute the per-cell continuity residual (local mass-balance check).
Definition SurfaceFluxCalculator.cpp:366
void computeLimitedGradients(const MeshData &mesh, SurfaceStateData &state, double epsilon, int nthreads)
Apply Jawahar-Kamath slope limiter (Eq. [23]–[24]).
Definition SurfaceFluxCalculator.cpp:279
void computeUnlimitedGradients(const MeshData &mesh, SurfaceStateData &state, int nthreads)
Compute unlimited gradients for all triangles via Green-Gauss theorem.
Definition SurfaceFluxCalculator.cpp:243
double evapSink(double rate, double depth, double dry_depth) noexcept
Depth-limited evaporation sink rate (m/s) for one cell.
Definition SurfaceFluxCalculator.hpp:101
double computeBoundaryEdgeFlux(const MeshData &mesh, const SurfaceStateData &state, const SolverOptions2D &opts, double dh_eps, int i, int idx) noexcept
Boundary-edge flux for cell i across flat mesh edge slot idx (m³/s, inflow-positive)....
Definition SurfaceFluxCalculator.cpp:496
SoA storage for 2D mixed triangle/quad mesh geometry and topology.
Definition MeshData.hpp:65
Definition SurfaceStateData.hpp:64