15#include <Kokkos_Core.hpp>
28 if constexpr (
N_DIM == 2) {
29 return static_cast<uint8_t>((
r + 1) * (
r + 2) / 2 - 1);
31 return static_cast<uint8_t>((
r + 1) * (
r + 2) * (
r + 3) / 6 - 1);
46 return static_cast<uint16_t>(
l * n -
l * (
l - 1) / 2 + (
m -
l));
55 Kokkos::SpaceAccessibility<Kokkos::DefaultExecutionSpace, Kokkos::HostSpace>::accessible ? 0 : 5;
70 Kokkos::View<rtype *>
pinv;
96 template <u
int8_t WIDTH>
107 template <
typename T = rtype>
118using Moments = Kokkos::View<double **, Kokkos::LayoutRight>;
136 template <u
int32_t G>
143 const bool in = e0 +
g < n;
151 if (t[
g] + k < end[
g]) {
165#if defined(KOKKOS_ENABLE_CUDA) || defined(KOKKOS_ENABLE_HIP)
169 const volatile double p =
a * b;
183 while (
l >= first + d + 1) {
184 first =
static_cast<uint8_t>(first + d + 1);
187 a =
static_cast<uint8_t>(d - (
l - first));
188 b =
static_cast<uint8_t>(
l - first);
200 for (
int i = d;
i >= 0;
i--) {
201 for (
int j = d -
i;
j >= 0;
j--) {
256 for (
int i = d;
i >= 0;
i--) {
257 for (
int j = d -
i;
j >= 0;
j--) {
270 if constexpr (
N_DIM == 2) {
288 const rtype * u = W + 1;
289 const rtype a = Kokkos::sqrt(gamma * W[
E] / W[0]);
298 R[0][0] = 1.0; R[0][1] = 1.0; R[0][2] = 1.0;
304 R[1 +
i][0] = u[
i] -
a * n[
i];
306 R[1 +
i][2] = u[
i] +
a * n[
i];
307 L[0][1 +
i] = 0.5
_r * (-
b1 * u[
i] - n[
i] /
a);
308 L[1][1 +
i] =
b1 * u[
i];
309 L[2][1 +
i] = 0.5
_r * (-
b1 * u[
i] + n[
i] /
a);
318 R[1 +
i][
c] = t[k][
i];
319 L[
c][1 +
i] = t[k][
i];
336 const rtype rho = W[0];
351 L[0][
E] = 0.5
_r / (
a *
a);
352 L[2][
E] = 0.5
_r / (
a *
a);
354 L[1][
E] = -1.0
_r / (
a *
a);
356 R[1 +
i][0] = -
a * n[
i] / rho;
357 R[1 +
i][2] =
a * n[
i] / rho;
358 L[0][1 +
i] = -0.5
_r * rho * n[
i] /
a;
359 L[2][1 +
i] = 0.5
_r * rho * n[
i] /
a;
363 R[1 +
i][3 + k] = t[k][
i];
364 L[3 + k][1 +
i] = t[k][
i];
378 return Kokkos::pow(10.0
_r, -Kokkos::floor(
psi));
KOKKOS_INLINE_FUNCTION rtype dot(const rtype *a, const rtype *b)
Compute the dot product of two arrays.
Definition common_math.h:32
KOKKOS_INLINE_FUNCTION void tangent_basis(const rtype *n, rtype *t1, rtype *t2)
Unit tangents completing the unit normal n to an orthonormal, right-handed basis: (n,...
Definition common_math.h:127
float rtype
Definition common_typedef.h:39
#define N_DIM
Definition common_typedef.h:28
#define N_CONSERVATIVE
Definition common_typedef.h:29
#define FOR_I_DIM
Definition common_typedef.h:32
constexpr uint8_t SLICE_SHIFT
log2 of the cells per slice of PackedStencils: 32 on GPUs, so that a warp reads consecutive words,...
Definition teno.h:54
KOKKOS_INLINE_FUNCTION rtype adaptive_CT(const rtype sigma, const rtype sigma_L, const rtype sigma_U)
Adaptive cutoff C_T from the troubled-cell measure sigma (Liang, Shyy & Fu 2025): 1e-10 near sigma_L,...
Definition teno.h:374
constexpr uint8_t MAX_FACES
Definition teno.h:37
constexpr uint8_t NK_SMALL
Definition teno.h:36
KOKKOS_INLINE_FUNCTION void exponents(const uint8_t l, uint8_t &a, uint8_t &b)
Exponents (a, b) of the l-th monomial xi^a eta^b, ordered by total degree: (1,0), (0,...
Definition teno.h:180
constexpr uint8_t MAX_DEGREE
Definition teno.h:21
Kokkos::View< double **, Kokkos::LayoutRight > Moments
(cell, k): central moments of each cell, mean of ((x - x_c) / h_c)^a ... (3D).
Definition teno.h:118
KOKKOS_INLINE_FUNCTION void monomial_gradients(const uint8_t r, const T xi, const T eta, T *d_xi, T *d_eta)
Derivatives with respect to xi and eta of all monomials of degree 1..r at (xi, eta).
Definition teno.h:239
KOKKOS_INLINE_FUNCTION void monomials(const uint8_t r, const T xi, const T eta, T *phi)
Evaluate all monomials of degree 1..r at (xi, eta).
Definition teno.h:225
KOKKOS_INLINE_FUNCTION constexpr uint8_t n_dof(const uint8_t r)
Number of non-constant N_DIM-variate monomials of total degree <= r.
Definition teno.h:27
KOKKOS_INLINE_FUNCTION T ipow(const T x, const uint8_t n)
Definition teno.h:215
KOKKOS_INLINE_FUNCTION void primitive_eigenvectors(const rtype *W, const rtype a, const rtype *n, rtype L[N_CONSERVATIVE][N_CONSERVATIVE], rtype R[N_CONSERVATIVE][N_CONSERVATIVE])
Left (L) and right (R) eigenvectors of the Euler equations in primitive variables W = [rho,...
Definition teno.h:332
constexpr uint8_t MAX_NK
Definition teno.h:35
constexpr uint8_t MAX_FACE_QUAD
Definition teno.h:38
KOKKOS_INLINE_FUNCTION void eigenvectors(const rtype *W, const rtype *n, const rtype gamma, rtype L[N_CONSERVATIVE][N_CONSERVATIVE], rtype R[N_CONSERVATIVE][N_CONSERVATIVE])
Left (L) and right (R) eigenvectors of the Euler flux Jacobian in direction n for conservative variab...
Definition teno.h:284
KOKKOS_INLINE_FUNCTION constexpr uint16_t upper_index(const uint8_t l, const uint8_t m, const uint8_t n)
Index of entry (l, m), l <= m, of a symmetric n x n matrix stored as its upper triangle,...
Definition teno.h:45
One cell's stencil, resolved once per cell, for pseudo-inverse entries of type T.
Definition teno.h:83
const T * pinv_
Definition teno.h:84
const int32_t * faces_
Definition teno.h:86
KOKKOS_INLINE_FUNCTION int32_t cell(const uint32_t s) const
Definition teno.h:90
KOKKOS_INLINE_FUNCTION rtype pinv(const uint32_t s, const uint32_t l) const
Entry l of slot s, for pseudo-inverses of WIDTH entries per slot.
Definition teno.h:98
const int32_t * cells_
Definition teno.h:85
uint8_t shift
Definition teno.h:87
KOKKOS_INLINE_FUNCTION int32_t face(const uint32_t s) const
Definition teno.h:93
Per-cell stencils of different sizes, stored without padding to the largest one in the mesh....
Definition teno.h:66
uint8_t width
Definition teno.h:72
bool single
Definition teno.h:73
Kokkos::View< rtype * > pinv
Definition teno.h:70
Kokkos::View< uint64_t * > slice_start
Definition teno.h:67
Kokkos::View< int32_t * > faces
Definition teno.h:69
uint8_t shift
Definition teno.h:71
Kokkos::View< int32_t * > cells
Definition teno.h:68
static KOKKOS_INLINE_FUNCTION size_t pinv_elements(const size_t n, const bool single)
Elements of pinv that hold n entries.
Definition teno.h:77
KOKKOS_INLINE_FUNCTION RowT< T > row(const uint32_t c) const
Definition teno.h:109
The terms of the smoothness-indicator matrix (3D): entry e (upper_index(l, m)) is sum_t weight(t) mom...
Definition teno.h:126
Kokkos::View< uint32_t * > start
Definition teno.h:127
KOKKOS_INLINE_FUNCTION void entries(const uint32_t e0, const uint32_t n, const double *moments, rtype *out) const
Entries [e0, e0 + G) below n from one cell's moments into out, each summed in term order and rounded ...
Definition teno.h:138
static KOKKOS_INLINE_FUNCTION double add_product_rn(const double s, const double a, const double b)
s + a b, each rounded, never fused.
Definition teno.h:164
Kokkos::View< uint32_t * > term
Definition teno.h:128
SlotArray< double, Space > psi
Definition teno_setup.cpp:478
CellSetup< ExecSpace > c
Definition teno_setup.cpp:1810
TableBatchT< Space > out
Definition teno_setup.cpp:681
uint8_t r
Definition teno_setup.cpp:687
R< double ** > moments
Definition teno_setup.cpp:406
Geometry< Space > g
Definition teno_setup.cpp:678
uint8_t nk
Definition teno_setup.cpp:687