OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
DiffusiveKernels.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
42
43#ifndef OPENSWMM_ENGINE_2D_DIFFUSIVE_KERNELS_HPP
44#define OPENSWMM_ENGINE_2D_DIFFUSIVE_KERNELS_HPP
45
46#include <algorithm>
47#include <cmath>
48
49#ifndef OPENSWMM_KERNEL_FN
50#define OPENSWMM_KERNEL_FN inline
51#endif
52
54
68OPENSWMM_KERNEL_FN double faceDischarge(double hf, double slope, double nf, double s_eps) noexcept {
69 if (!(hf > 0.0) || !(nf > 0.0) || slope == 0.0)
70 return 0.0;
71 const double h53 = hf * std::cbrt(hf * hf);
72 const double sa = std::fabs(slope);
73 const double sr = std::sqrt((sa > s_eps) ? sa : s_eps);
74 return -h53 * slope / (nf * sr);
75}
76
92OPENSWMM_KERNEL_FN double cellDiffusiveDt(double alpha, double lchar, double h, double n,
93 double slope_abs, double s_eps) noexcept {
94 if (!(h > 0.0))
95 return 1.0e30;
96 const double h53 = h * std::cbrt(h * h);
97 const double s = (slope_abs > s_eps) ? slope_abs : s_eps;
98 return alpha * lchar * lchar * n * std::sqrt(s) / (4.0 * h53);
99}
100
101} // namespace openswmm::twoD::diffusive
102
103#endif // OPENSWMM_ENGINE_2D_DIFFUSIVE_KERNELS_HPP
#define OPENSWMM_KERNEL_FN
Definition ExplicitKokkosSurfaceSolver.cpp:22
Definition DiffusiveKernels.hpp:53
OPENSWMM_KERNEL_FN double cellDiffusiveDt(double alpha, double lchar, double h, double n, double slope_abs, double s_eps) noexcept
Explicit-diffusion step bound for a cell of characteristic length L, depth h, Manning n and the large...
Definition DiffusiveKernels.hpp:92
OPENSWMM_KERNEL_FN double faceDischarge(double hf, double slope, double nf, double s_eps) noexcept
Manning quasi-steady face discharge (m²/s, positive L→R) for face depth hf, surface slope S = (η_R − ...
Definition DiffusiveKernels.hpp:68