core
Shared MPI block decomposition + asynchronous ghost-layer exchange (header-only C++20)
Loading...
Searching...
No Matches
advect_recon.hpp
Go to the documentation of this file.
1// core — shared, backend-agnostic high-order advection face reconstruction.
2//
3// The SOU / Koren-TVD reconstruction of the advected face value from the two upwind cells (upup,
4// up) and the downwind cell (down) is the numerically delicate part of the advection scheme —
5// exactly the kind of formula that must not drift between the serial host solver (AmrFlow::hoFace,
6// flow.hpp) and the Kokkos device solver (deferredSou / advectExplicit, flow.hpp). This is that
7// formula, written ONCE as a MORTON_HD function (host- and device-callable; empty MORTON_HD in the
8// pure-C++ build). min/max/abs are expressed with branches rather than std::/Kokkos:: math so the
9// body is identical on both backends (and bit-identical to the previous std::fmin/fmax form for the
10// finite velocity/scalar data the solver produces).
11#ifndef PECLET_CORE_AMR_ADVECT_RECON_HPP
12#define PECLET_CORE_AMR_ADVECT_RECON_HPP
13
14#if defined(PECLET_CORE_HAVE_MORTON)
15#include <morton/morton.hpp>
16#endif
17#ifndef MORTON_HD
18#define MORTON_HD
19#endif
20
21namespace peclet::core::amr {
22
25MORTON_HD inline double hoFaceValue(double upup, double up, double down, int scheme) {
26 if (scheme == 0)
27 return 1.5 * up - 0.5 * upup; // SOU
28 const double den = down - up;
29 const double aden = (den < 0.0) ? -den : den;
30 const double r = (aden < 1e-10) ? 0.0 : (up - upup) / den;
31 // psi = max(0, min(2r, (1+2r)/3, 2)) — the Koren limiter.
32 const double t = (1.0 + 2.0 * r) / 3.0;
33 double m = (2.0 * r < t) ? (2.0 * r) : t;
34 if (m > 2.0)
35 m = 2.0;
36 const double psi = (m > 0.0) ? m : 0.0;
37 return up + 0.5 * psi * den; // Koren TVD
38}
39
40} // namespace peclet::core::amr
41
42#endif // PECLET_CORE_AMR_ADVECT_RECON_HPP
#define MORTON_HD
MORTON_HD double hoFaceValue(double upup, double up, double down, int scheme)
High-order advected face value from the two upwind cells (upup, up) and the downwind cell (down).