Mallard 0.8.0
Unstructured, GPU accelerated, high-order finite volume CFD solver
Mallard website
Loading...
Searching...
No Matches
state.h
Go to the documentation of this file.
1
12#ifndef STATE_H
13#define STATE_H
14
15#include <cstdint>
16#include <string>
17
18#include <Kokkos_Core.hpp>
19
20#include "common_typedef.h"
21
23using StateView = Kokkos::View<rtype *[N_CONSERVATIVE]>;
24
30#ifdef Mallard_SPECIES_LAYOUT_LEFT
31using SpeciesLayout = Kokkos::LayoutLeft;
32#else
33using SpeciesLayout = Kokkos::LayoutRight;
34#endif
35
37using SpeciesView = Kokkos::View<rtype **, SpeciesLayout>;
38
41 const rtype * first;
42 size_t stride;
44};
45
48 return CellSpecies{&rhoY(c, 0), rhoY.stride(1)};
49}
50
56struct State {
59
60 State() = default;
62 State(const std::string & label, uint32_t n_cells, uint32_t n_species)
63 : flow(label, n_cells), species(label + "_species", n_cells, n_species) {}
64
65 uint32_t n_species() const { return static_cast<uint32_t>(species.extent(1)); }
66};
67
69inline void deep_copy(const State & dst, const State & src) {
70 Kokkos::deep_copy(dst.flow, src.flow);
71 if (src.species.span() > 0) Kokkos::deep_copy(dst.species, src.species);
72}
73
75template <typename ExecSpace>
76inline void deep_copy(const ExecSpace & exec, const State & dst, const State & src) {
77 Kokkos::deep_copy(exec, dst.flow, src.flow);
78 if (src.species.span() > 0) Kokkos::deep_copy(exec, dst.species, src.species);
79}
80
81#endif // STATE_H
KOKKOS_INLINE_FUNCTION rtype dot(const rtype *a, const rtype *b)
Compute the dot product of two arrays.
Definition common_math.h:32
Typedefs for common types.
float rtype
Definition common_typedef.h:39
void deep_copy(const State &dst, const State &src)
Copy both blocks of src into dst.
Definition state.h:69
Kokkos::View< rtype *[N_CONSERVATIVE]> StateView
Flow block [rho, rho u, rho E] per cell.
Definition state.h:23
KOKKOS_INLINE_FUNCTION CellSpecies cell_species(const SpeciesView &rhoY, const uint32_t c)
Definition state.h:47
Kokkos::LayoutRight SpeciesLayout
Layout of the species block: LayoutRight keeps a cell's species contiguous (the default); LayoutLeft ...
Definition state.h:33
Kokkos::View< rtype **, SpeciesLayout > SpeciesView
Partial densities rho Y_k per (cell, species).
Definition state.h:37
The partial densities of one cell, in any layout.
Definition state.h:40
size_t stride
Definition state.h:42
KOKKOS_INLINE_FUNCTION rtype operator[](const uint32_t k) const
Definition state.h:43
const rtype * first
Definition state.h:41
Conservative state of every cell: the flow block and the partial densities of a mixture's species....
Definition state.h:56
uint32_t n_species() const
Definition state.h:65
State()=default
State(StateView flow_, SpeciesView species_)
Definition state.h:61
State(const std::string &label, uint32_t n_cells, uint32_t n_species)
Definition state.h:62
StateView flow
Definition state.h:57
SpeciesView species
Definition state.h:58
CellSetup< ExecSpace > c
Definition teno_setup.cpp:1810