include/pops/numerics/fv/reconstruction.hpp Source FileΒΆ

adc_cpp: include/pops/numerics/fv/reconstruction.hpp Source File
adc_cpp 0.3.0
Model-free C++23 core for coupled hyperbolic-elliptic systems on adaptive (AMR) meshes, with MPI and GPU (Kokkos) backends
reconstruction.hpp
Go to the documentation of this file.
1
12
13#pragma once
14
16
17#include <cmath>
18
19namespace pops {
20
26struct NoSlope {
27 static constexpr int n_ghost = 1;
28 POPS_HD Real operator()(Real, Real) const { return Real(0); }
29};
30
36struct Minmod {
37 static constexpr int n_ghost = 2;
39 if (a * b <= Real(0))
40 return Real(0);
41 const Real fa = a < 0 ? -a : a, fb = b < 0 ? -b : b; // |.| device-safe
42 return (fa < fb) ? a : b;
43 }
44};
45
51struct VanLeer {
52 static constexpr int n_ghost = 2;
54 const Real ab = a * b;
55 if (ab <= Real(0))
56 return Real(0);
57 return Real(2) * ab / (a + b);
58 }
59};
60
70POPS_HD inline Real weno5z(Real vm2, Real vm1, Real v0, Real vp1, Real vp2) {
71 const Real eps = Real(1e-40);
72 // three third-order reconstructions of the +x face of v0
73 const Real q0 = (Real(2) * vm2 - Real(7) * vm1 + Real(11) * v0) / Real(6);
74 const Real q1 = (-vm1 + Real(5) * v0 + Real(2) * vp1) / Real(6);
75 const Real q2 = (Real(2) * v0 + Real(5) * vp1 - vp2) / Real(6);
76 // smoothness indicators (Jiang-Shu)
77 const Real b0 = Real(13) / Real(12) * (vm2 - 2 * vm1 + v0) * (vm2 - 2 * vm1 + v0) +
78 Real(0.25) * (vm2 - 4 * vm1 + 3 * v0) * (vm2 - 4 * vm1 + 3 * v0);
79 const Real b1 = Real(13) / Real(12) * (vm1 - 2 * v0 + vp1) * (vm1 - 2 * v0 + vp1) +
80 Real(0.25) * (vm1 - vp1) * (vm1 - vp1);
81 const Real b2 = Real(13) / Real(12) * (v0 - 2 * vp1 + vp2) * (v0 - 2 * vp1 + vp2) +
82 Real(0.25) * (3 * v0 - 4 * vp1 + vp2) * (3 * v0 - 4 * vp1 + vp2);
83 // WENO-Z weights: alpha_k = d_k (1 + (tau5/(eps+beta_k))^2), tau5 = |beta0 - beta2|
84 const Real tau5 = (b0 - b2 < 0 ? b2 - b0 : b0 - b2);
85 const Real a0 = (Real(1) / Real(10)) * (Real(1) + (tau5 / (eps + b0)) * (tau5 / (eps + b0)));
86 const Real a1 = (Real(6) / Real(10)) * (Real(1) + (tau5 / (eps + b1)) * (tau5 / (eps + b1)));
87 const Real a2 = (Real(3) / Real(10)) * (Real(1) + (tau5 / (eps + b2)) * (tau5 / (eps + b2)));
88 const Real inv = Real(1) / (a0 + a1 + a2);
89 return (a0 * q0 + a1 * q1 + a2 * q2) * inv;
90}
91
98struct Weno5 {
99 static constexpr int n_ghost = 3;
100 POPS_HD Real operator()(Real, Real) const { return Real(0); }
101};
102
103} // namespace pops
Definition amr_hierarchy.hpp:29
double Real
Definition types.hpp:30
POPS_HD Real weno5z(Real vm2, Real vm1, Real v0, Real vp1, Real vp2)
weno5z: WENO5-Z reconstruction (Borges 2008) at one interface, on a 5-point stencil.
Definition reconstruction.hpp:70
minmod limiter: TVD (Total Variation Diminishing), 2 ghosts, order 2 in smooth regions.
Definition reconstruction.hpp:36
static constexpr int n_ghost
Definition reconstruction.hpp:37
POPS_HD Real operator()(Real a, Real b) const
Definition reconstruction.hpp:38
First-order reconstruction (piecewise constant): zero slope, 1 ghost.
Definition reconstruction.hpp:26
POPS_HD Real operator()(Real, Real) const
Definition reconstruction.hpp:28
static constexpr int n_ghost
Definition reconstruction.hpp:27
van Leer limiter: smooth, 2 ghosts, better order at extrema than Minmod.
Definition reconstruction.hpp:51
POPS_HD Real operator()(Real a, Real b) const
Definition reconstruction.hpp:53
static constexpr int n_ghost
Definition reconstruction.hpp:52
WENO5 tag policy: marks the stencil at 3 ghosts, delegates to weno5z.
Definition reconstruction.hpp:98
static constexpr int n_ghost
Definition reconstruction.hpp:99
POPS_HD Real operator()(Real, Real) const
Definition reconstruction.hpp:100
Base scalar types and the POPS_HD macro (host+device portability).
#define POPS_HD
Definition types.hpp:25