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
58OPENSWMM_KERNEL_FN double faceDischarge(double hf, double slope, double nf,
59 double s_eps) noexcept {
60 if (!(hf > 0.0) || !(nf > 0.0) || slope == 0.0) return 0.0;
61 const double h53 = hf * std::cbrt(hf * hf);
62 const double sa = std::fabs(slope);
63 const double sr = std::sqrt((sa > s_eps) ? sa : s_eps);
64 return -h53 * slope / (nf * sr);
65}
66
71OPENSWMM_KERNEL_FN double cellDiffusiveDt(double alpha, double lchar, double h,
72 double n, double slope_abs,
73 double s_eps) noexcept {
74 if (!(h > 0.0)) return 1.0e30;
75 const double h53 = h * std::cbrt(h * h);
76 const double s = (slope_abs > s_eps) ? slope_abs : s_eps;
77 return alpha * lchar * lchar * n * std::sqrt(s) / (4.0 * h53);
78}
79
80} // namespace openswmm::twoD::diffusive
81
82#endif // OPENSWMM_ENGINE_2D_DIFFUSIVE_KERNELS_HPP
#define OPENSWMM_KERNEL_FN
Definition ExplicitKokkosSurfaceSolver.cpp:18
Definition DiffusiveKernels.hpp:53
OPENSWMM_KERNEL_FN double cellDiffusiveDt(double alpha, double lchar, double h, double n, double slope_abs, double s_eps) noexcept
Definition DiffusiveKernels.hpp:71
OPENSWMM_KERNEL_FN double faceDischarge(double hf, double slope, double nf, double s_eps) noexcept
Definition DiffusiveKernels.hpp:58