Mallard 0.8.0
Unstructured, GPU accelerated, high-order finite volume CFD solver
Mallard website
Loading...
Searching...
No Matches
scalar_reconstruction.h
Go to the documentation of this file.
1
12#ifndef SCALAR_RECONSTRUCTION_H
13#define SCALAR_RECONSTRUCTION_H
14
15#include <memory>
16
17#include <Kokkos_Core.hpp>
18
19#include "boundary.h"
20#include "common.h"
21#include "face_reconstruction.h"
22#include "mesh.h"
23#include "teno.h"
24
26using ScalarView = Kokkos::View<rtype **, Kokkos::LayoutRight>;
27
30
45 Kokkos::View<uint32_t *> offsets_faces_of_cell;
46 Kokkos::View<uint32_t *> faces_of_cell;
47 Kokkos::View<int32_t *[2]> cells_of_face;
48 Kokkos::View<rtype *[N_DIM]> cell_coords;
49 Kokkos::View<rtype *[N_DIM]> face_coords;
50 Kokkos::View<rtype *[N_DIM]> shifts;
51 Kokkos::View<uint8_t *> face_shift;
53 Kokkos::View<rtype ***, Kokkos::LayoutRight> gradients; // (cell, j, d); empty for first order
54 Kokkos::View<rtype *> limiter; // (cell)
55
58 void offset(const uint32_t c, const uint32_t f, const uint8_t side, rtype * r) const {
59 const uint8_t s = side ? face_shift(f) : 0;
60 FOR_I_DIM r[i] = (face_coords(f, i) - shifts(s, i)) - cell_coords(c, i);
61 }
62
65 rtype value(const uint32_t c, const uint32_t j, const rtype * r) const {
66 if (gradients.extent(0) == 0) return scalars(c, j);
67 rtype d = 0.0_r;
68 FOR_I_DIM d += gradients(c, j, i) * r[i];
69 return scalars(c, j) + limiter(c) * d;
70 }
71
73 void face_values(const uint32_t c, const uint32_t j, const uint8_t k, rtype * out) const {
75 const uint8_t side = (cells_of_face(f, 0) == static_cast<int32_t>(c)) ? 0 : 1;
76 rtype r[N_DIM];
77 offset(c, f, side, r);
78 out[0] = value(c, j, r);
79 }
80
82 void cell_values(const uint32_t c, const uint32_t j, FacePointValues * out) const {
83 const uint8_t n = static_cast<uint8_t>(offsets_faces_of_cell(c + 1) - offsets_faces_of_cell(c));
84 for (uint8_t k = 0; k < n; k++) face_values(c, j, k, out[k]);
85 }
86};
87
104 public:
109 void init(std::shared_ptr<Mesh> mesh, const BoundaryData & boundaries, uint32_t n_species,
110 const FaceReconstruction & flow);
111
119 void calc(ScalarView scalars, Kokkos::View<rtype *[N_CONSERVATIVE]> W,
120 Kokkos::View<rtype **[2][2]> face_thermo);
121
128 void species_slots(ScalarView scalars, Kokkos::View<rtype **> face_mdot, Kokkos::View<rtype *> quad_weights,
129 Kokkos::View<rtype **> face_weights, Kokkos::View<rtype ***, Kokkos::LayoutRight> slots);
130
133
134 void set_boundaries(const BoundaryData & b) { boundaries = b; }
135
136 // Public because nvcc rejects device lambdas in non-public member functions
137 template <typename Eval>
138 void launch_slots(const Eval & values, Kokkos::View<rtype **> face_mdot, Kokkos::View<rtype *> quad_weights,
139 Kokkos::View<rtype **> face_weights, Kokkos::View<rtype ***, Kokkos::LayoutRight> slots);
140 template <uint8_t DEG>
141 void calc_teno(ScalarView scalars, Kokkos::View<rtype **[2][2]> face_thermo);
142
143 private:
144 std::shared_ptr<Mesh> mesh;
145 BoundaryData boundaries;
146 const TENO * teno = nullptr;
147 uint32_t n_species = 0;
148 bool linear = false;
149 LimiterType limiter_type = LimiterType::NONE;
150 rtype venkat_K = 5.0;
151 Kokkos::View<rtype ***, Kokkos::LayoutRight> gradients;
152 Kokkos::View<rtype *> limiter;
153 Kokkos::View<rtype *> theta; // TENO
154};
155
156#endif // SCALAR_RECONSTRUCTION_H
Boundary conditions.
Definition face_reconstruction.h:53
Reconstructs a mixture's cell scalars (mass fractions and the thermodynamic surrogates gamma,...
Definition scalar_reconstruction.h:103
void calc_teno(ScalarView scalars, Kokkos::View< rtype **[2][2]> face_thermo)
Definition scalar_reconstruction.cpp:309
ScalarFaceValues face_values(ScalarView scalars) const
Device evaluator of first-order and MUSCL face values, valid after calc().
Definition scalar_reconstruction.cpp:303
void init(std::shared_ptr< Mesh > mesh, const BoundaryData &boundaries, uint32_t n_species, const FaceReconstruction &flow)
Definition scalar_reconstruction.cpp:275
void set_boundaries(const BoundaryData &b)
Definition scalar_reconstruction.h:134
void calc(ScalarView scalars, Kokkos::View< rtype *[N_CONSERVATIVE]> W, Kokkos::View< rtype **[2][2]> face_thermo)
After the flow block's reconstruction: what the scalars need beyond it (MUSCL gradients and limiters,...
Definition scalar_reconstruction.cpp:316
void launch_slots(const Eval &values, Kokkos::View< rtype ** > face_mdot, Kokkos::View< rtype * > quad_weights, Kokkos::View< rtype ** > face_weights, Kokkos::View< rtype ***, Kokkos::LayoutRight > slots)
Definition scalar_reconstruction.cpp:339
void species_slots(ScalarView scalars, Kokkos::View< rtype ** > face_mdot, Kokkos::View< rtype * > quad_weights, Kokkos::View< rtype ** > face_weights, Kokkos::View< rtype ***, Kokkos::LayoutRight > slots)
Species fluxes per face side (SpeciesSlotFunctor) of every cell, from the mass flux at each face poin...
Definition scalar_reconstruction.cpp:348
High-order TENO-E reconstruction on unstructured meshes (Liang, Shyy & Fu, J. Sci....
Definition face_reconstruction.h:282
Common header file.
KOKKOS_INLINE_FUNCTION rtype dot(const rtype *a, const rtype *b)
Compute the dot product of two arrays.
Definition common_math.h:32
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
Face reconstruction class declaration.
LimiterType
Definition face_reconstruction.h:226
Mesh class declaration.
Definition teno.h:19
constexpr uint8_t MAX_FACE_QUAD
Definition teno.h:38
Kokkos::View< rtype **, Kokkos::LayoutRight > ScalarView
Cell scalars of a mixture: (cell, j) = Y_1 .. Y_Ns, gamma, e0.
Definition scalar_reconstruction.h:26
rtype[teno::MAX_FACE_QUAD] FacePointValues
Per-face storage of scalar values at a face's quadrature points.
Definition scalar_reconstruction.h:29
Device-side lookup from faces to boundary conditions.
Definition boundary.h:229
Face values of the cell scalars: the cell value (first order) or the linear reconstruction S_c + phi_...
Definition scalar_reconstruction.h:44
KOKKOS_INLINE_FUNCTION void face_values(const uint32_t c, const uint32_t j, const uint8_t k, rtype *out) const
Definition scalar_reconstruction.h:73
Kokkos::View< rtype * > limiter
Definition scalar_reconstruction.h:54
Kokkos::View< uint8_t * > face_shift
Definition scalar_reconstruction.h:51
KOKKOS_INLINE_FUNCTION void cell_values(const uint32_t c, const uint32_t j, FacePointValues *out) const
Definition scalar_reconstruction.h:82
Kokkos::View< uint32_t * > faces_of_cell
Definition scalar_reconstruction.h:46
Kokkos::View< rtype *[N_DIM]> face_coords
Definition scalar_reconstruction.h:49
Kokkos::View< rtype *[N_DIM]> cell_coords
Definition scalar_reconstruction.h:48
Kokkos::View< uint32_t * > offsets_faces_of_cell
Definition scalar_reconstruction.h:45
ScalarView scalars
Definition scalar_reconstruction.h:52
Kokkos::View< rtype *[N_DIM]> shifts
Definition scalar_reconstruction.h:50
Kokkos::View< int32_t *[2]> cells_of_face
Definition scalar_reconstruction.h:47
KOKKOS_INLINE_FUNCTION void offset(const uint32_t c, const uint32_t f, const uint8_t side, rtype *r) const
Offset from the centroid of cell c, on side side of face f, to the face centroid.
Definition scalar_reconstruction.h:58
KOKKOS_INLINE_FUNCTION rtype value(const uint32_t c, const uint32_t j, const rtype *r) const
Scalar j of cell c at offset r from its centroid.
Definition scalar_reconstruction.h:65
Kokkos::View< rtype ***, Kokkos::LayoutRight > gradients
Definition scalar_reconstruction.h:53
Device helpers for the TENO-E reconstruction.
CellSetup< ExecSpace > c
Definition teno_setup.cpp:1810
TableBatchT< Space > out
Definition teno_setup.cpp:681
uint8_t r
Definition teno_setup.cpp:687
uint32_t slots
Definition teno_setup.cpp:480
V< rtype ** > quad_weights
Definition teno_setup.cpp:409