peclet-amr 0.2.0
Block-local-Morton AMR octree + collocated cut-cell Navier–Stokes solver (header-only C++20, Kokkos + MPI)
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_AMR_ADVECT_RECON_HPP
12#define PECLET_AMR_ADVECT_RECON_HPP
13
14#include <morton/morton.hpp>
15
16#include "peclet/amr/common.hpp"
17#ifndef MORTON_HD
18#define MORTON_HD
19#endif
20
21namespace peclet::amr {
22
25MORTON_HD inline double korenPsi(double r) {
26 const double t = (1.0 + 2.0 * r) / 3.0;
27 double m = (2.0 * r < t) ? (2.0 * r) : t;
28 if (m > 2.0)
29 m = 2.0;
30 return (m > 0.0) ? m : 0.0;
31}
32
41MORTON_HD inline double hoFaceValue(double upup, double up, double down, int scheme) {
42 if (scheme == 0)
43 return 1.5 * up - 0.5 * upup; // SOU
44 const double den = down - up;
45 const double aden = (den < 0.0) ? -den : den;
46 const double r = (aden < 1e-10) ? 0.0 : (up - upup) / den;
47 return up + 0.5 * korenPsi(r) * den; // Koren TVD
48}
49
64MORTON_HD inline double hoFaceValueSeam(double upup, double up, double upStar, double downStar,
65 double d1, double dUU, double dD, int scheme) {
66 const double gUp = (up - upup) / dUU;
67 if (scheme == 0)
68 return upStar + d1 * gUp; // SOU
69 const double den = downStar - upStar;
70 const double aden = (den < 0.0) ? -den : den;
71 const double r = (aden < 1e-10) ? 0.0 : gUp * dD / den;
72 return upStar + (d1 / dD) * korenPsi(r) * den; // Koren TVD
73}
74
75} // namespace peclet::amr
76
77#endif // PECLET_AMR_ADVECT_RECON_HPP
double korenPsi(double r)
psi = max(0, min(2r, (1+2r)/3, 2)) — the Koren limiter, written once for the two reconstructions belo...
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).
double hoFaceValueSeam(double upup, double up, double upStar, double downStar, double d1, double dUU, double dD, int scheme)
The same reconstruction with every distance and every sample made explicit — the rule of docs/amr_cf_...
std::vector< std::array< double, Dim > > transferFieldGradients(const BlockOctree< Dim, Bits > &oldT, const std::vector< double > &oldF)
Per-old-leaf minmod prolongation gradients (per fine-coordinate unit) — transferField's stencil,...
Definition adapt.hpp:51