15#include <Kokkos_Core.hpp>
32 if constexpr (
N_DIM == 2) {
33 M[0] += w *
dx[0] *
dx[0];
34 M[1] += w *
dx[0] *
dx[1];
35 M[2] += w *
dx[1] *
dx[1];
58 if constexpr (
N_DIM == 2) {
95 Kokkos::View<rtype *[N_CONSERVATIVE]>
W;
96 Kokkos::View<rtype *[N_CONSERVATIVE][N_DIM]>
gradients;
178template <u
int8_t N,
typename T>
187 }
else if (
s > T(1.0e-10) *
A[p][p]) {
188 L[p][p] = Kokkos::sqrt(
s);
200template <u
int8_t N,
typename T>
204 for (
uint8_t k = 0; k < p; k++) x[p] -=
L[p][k] * x[k];
207 for (
int p =
N - 1; p >= 0; p--) {
208 for (
int k = p + 1; k <
N; k++) x[p] -=
L[k][p] * x[k];
250 template <
typename F>
282 if constexpr (
N_DIM == 2) {
293 const double len = Kokkos::sqrt(n[0] * n[0] + n[1] * n[1]);
296 const double R[2][2] = {{1.0 - 2.0 * n[0] * n[0], -2.0 * n[0] * n[1]},
297 {-2.0 * n[0] * n[1], 1.0 - 2.0 * n[1] * n[1]}};
300 const uint8_t a = (
m == 2) ? 1 : 0, b = (
m == 0) ? 0 : 1;
302 for (
uint8_t p = 0; p < 2; p++) {
333 if (n_points++ == 0)
scale = Kokkos::sqrt(w);
397 boundaries, W, gradients};
406 bool quadratic =
true) {
408 {Kokkos::View<rtype *[N_DIM]>(
"vertex_gradient_weights_cells", mesh.
cells_of_cell.extent(0)),
409 Kokkos::View<rtype *[N_DIM]>(
"vertex_gradient_weights_faces", faces.
faces_of_cell.extent(0))},
410 quadratic, quadratic ? mesh.
cell_covariance : Kokkos::View<rtype *[3]>()};
411 Kokkos::parallel_for(
"vertex_gradient_weights", mesh.
n_cells,
BoundaryType
Definition boundary.h:25
Kokkos::View< uint8_t * > cells_of_cell_shift
Definition mesh.h:469
Kokkos::View< uint32_t * > offsets_cells_of_cell
Definition mesh.h:463
Kokkos::View< rtype *[N_DIM]> cell_coords
Definition mesh.h:450
Kokkos::View< uint8_t * > face_shift
Definition mesh.h:468
Kokkos::View< rtype *[N_DIM]> face_normals
Definition mesh.h:453
Kokkos::View< uint32_t * > cells_of_cell
Definition mesh.h:462
Kokkos::View< uint32_t * > offsets_faces_of_cell
Definition mesh.h:458
uint32_t n_cells
Definition mesh.h:418
Kokkos::View< uint32_t * > faces_of_cell
Definition mesh.h:457
Kokkos::View< rtype *[3]> cell_covariance
Definition mesh.h:447
Kokkos::View< int32_t *[2]> cells_of_face
Definition mesh.h:461
Kokkos::View< rtype *[N_DIM]> shifts
Definition mesh.h:467
Kokkos::View< rtype *[N_DIM]> face_coords
Definition mesh.h:454
KOKKOS_INLINE_FUNCTION void gemv< 3 >(const rtype *A, const rtype *x, rtype *y)
Definition common_math.h:245
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 invert_matrix< 3 >(const rtype *A, rtype *A_inv)
Definition common_math.h:191
float rtype
Definition common_typedef.h:39
#define N_DIM
Definition common_typedef.h:28
#define FOR_I_CONSERVATIVE
Definition common_typedef.h:33
#define N_CONSERVATIVE
Definition common_typedef.h:29
#define FOR_I_DIM
Definition common_typedef.h:32
KOKKOS_INLINE_FUNCTION bool cholesky(const T A[N][N], T L[N][N])
Cholesky factorization A = L L^T of a symmetric positive definite matrix given by its upper triangle....
Definition gradient.h:180
LSQVertexGradientFunctor make_vertex_gradient(const LSQGradientFunctor &faces, const Mesh &mesh, bool quadratic=true)
LSQVertexGradientFunctor over the given gradient functor's mesh, boundaries, states and gradients,...
Definition gradient.h:405
KOKKOS_INLINE_FUNCTION void cholesky_solve(const T L[N][N], T *x)
Solve L L^T x = b in place.
Definition gradient.h:202
LSQGradientFunctor make_gradient(const Mesh &mesh, const BoundaryData &boundaries, Kokkos::View< rtype *[N_CONSERVATIVE]> W, Kokkos::View< rtype *[N_CONSERVATIVE][N_DIM]> gradients)
LSQGradientFunctor of the states W into gradients over a mesh.
Definition gradient.h:392
Device-copyable boundary condition.
Definition boundary.h:97
Device-side lookup from faces to boundary conditions.
Definition boundary.h:229
Kokkos::View< int32_t * > face_bc
Definition boundary.h:230
bool viscous
Definition boundary.h:252
KOKKOS_INLINE_FUNCTION void ghost_W(const uint32_t i_face, const rtype *W_i, const rtype *n, rtype *W_g) const
Ghost state for boundary face i_face.
Definition boundary.h:471
KOKKOS_INLINE_FUNCTION void ghost_W_at(const uint32_t i_face, const rtype *W_i, const rtype *n, const rtype dist, rtype *W_g) const
Ghost state for a point a distance dist outside boundary face i_face (the mirror image of an interior...
Definition boundary.h:458
Kokkos::View< BoundaryCondition * > bcs
Definition boundary.h:249
Euler gas
Definition boundary.h:253
rtype R
Definition boundary.h:251
KOKKOS_INLINE_FUNCTION rtype conductivity(const rtype mu) const
Thermal conductivity for dynamic viscosity mu.
Definition physics.h:108
KOKKOS_INLINE_FUNCTION rtype viscosity(const rtype T) const
Dynamic viscosity at temperature T.
Definition physics.h:91
Weighted least-squares gradient of W = [rho, u, p] over face neighbors, with boundary ghost states pl...
Definition gradient.h:85
KOKKOS_INLINE_FUNCTION void neighbor(const uint32_t i_cell, const uint32_t i_face, const rtype *W_i, rtype *dx, rtype *W_j) const
Offset to and state of the neighbor across face i_face.
Definition gradient.h:114
Kokkos::View< uint32_t * > offsets_faces_of_cell
Definition gradient.h:86
Kokkos::View< uint32_t * > faces_of_cell
Definition gradient.h:87
BoundaryData boundaries
Definition gradient.h:94
Kokkos::View< int32_t *[2]> cells_of_face
Definition gradient.h:88
Kokkos::View< rtype *[N_DIM]> face_coords
Definition gradient.h:90
Kokkos::View< rtype *[N_DIM]> face_normals
Definition gradient.h:91
Kokkos::View< rtype *[N_CONSERVATIVE][N_DIM]> gradients
Definition gradient.h:96
Kokkos::View< rtype *[N_DIM]> cell_coords
Definition gradient.h:89
Kokkos::View< rtype *[N_CONSERVATIVE]> W
Definition gradient.h:95
KOKKOS_INLINE_FUNCTION void operator()(const uint32_t i_cell) const
Definition gradient.h:158
Kokkos::View< uint8_t * > face_shift
Definition gradient.h:93
KOKKOS_INLINE_FUNCTION bool one_sided(const uint32_t i_face) const
Whether vertex-neighbor gradients leave out the ghost of face i_face: the zero-gradient ghost of a ch...
Definition gradient.h:106
Kokkos::View< rtype *[N_DIM]> shifts
Definition gradient.h:92
Inverse-distance-squared weighted least-squares normal equations M g = b, with M stored as its upper ...
Definition gradient.h:25
KOKKOS_INLINE_FUNCTION void add(const rtype *dx, const rtype *W_i, const rtype *W_j)
Definition gradient.h:30
rtype M[N_DIM *(N_DIM+1)/2]
Definition gradient.h:26
KOKKOS_INLINE_FUNCTION void solve(rtype g[N_CONSERVATIVE][N_DIM]) const
Solve for the gradient of every variable: g[i][d] = d W_i / d x_d.
Definition gradient.h:57
rtype b[N_CONSERVATIVE][N_DIM]
Definition gradient.h:27
Gradient over all vertex neighbors plus the boundary ghost states of the cell's own boundary faces,...
Definition gradient.h:233
Kokkos::View< uint32_t * > offsets_cells_of_cell
Definition gradient.h:235
static constexpr uint8_t NB
Definition gradient.h:244
bool quadratic
Definition gradient.h:239
KOKKOS_INLINE_FUNCTION void for_each_point(const uint32_t i_cell, F &&f) const
Offset of every stencil point of cell i_cell, passed to f(offset, is_face, index into cells_of_cell o...
Definition gradient.h:252
Kokkos::View< uint32_t * > cells_of_cell
Definition gradient.h:236
KOKKOS_INLINE_FUNCTION void operator()(const uint32_t i_cell) const
Definition gradient.h:364
LSQGradientFunctor faces
Definition gradient.h:234
KOKKOS_INLINE_FUNCTION void compute_weights(const uint32_t i_cell) const
Compute the weights of cell i_cell, in double: the normal equations of the quadratic fit are too ill ...
Definition gradient.h:276
VertexGradientWeights weights
Definition gradient.h:238
Kokkos::View< rtype *[3]> covariance
Definition gradient.h:242
Kokkos::View< uint8_t * > cells_of_cell_shift
Definition gradient.h:237
Weights of LSQVertexGradientFunctor, aligned with cells_of_cell and faces_of_cell (zero for interior ...
Definition gradient.h:217
Kokkos::View< rtype *[N_DIM]> cells
Definition gradient.h:218
Kokkos::View< rtype *[N_DIM]> faces
Definition gradient.h:219
CellSetup< ExecSpace > c
Definition teno_setup.cpp:1810
uint8_t r
Definition teno_setup.cpp:687
Geometry< Space > g
Definition teno_setup.cpp:678
SlotArray< double, Space > A
Definition teno_setup.cpp:478
Lane< rtype > scale
Definition teno_setup.cpp:531