Mallard 0.8.0
Unstructured, GPU accelerated, high-order finite volume CFD solver
Mallard website
Loading...
Searching...
No Matches
common_typedef.h
Go to the documentation of this file.
1
12#ifndef COMMON_TYPEDEF_H
13#define COMMON_TYPEDEF_H
14
15#include <string>
16#include <array>
17#include <vector>
18
19#include <Kokkos_Macros.hpp>
20
21#ifndef Mallard_DIM
22#define Mallard_DIM 2
23#endif
24#if Mallard_DIM != 2 && Mallard_DIM != 3
25#error "Mallard_DIM must be 2 or 3"
26#endif
27
28#define N_DIM Mallard_DIM
29#define N_CONSERVATIVE (N_DIM + 2)
30#define N_PRIMITIVE (N_DIM + 3)
31
32#define FOR_I_DIM for (uint8_t i = 0; i < N_DIM; i++)
33#define FOR_I_CONSERVATIVE for (uint8_t i = 0; i < N_CONSERVATIVE; i++)
34#define FOR_I_PRIMITIVE for (uint8_t i = 0; i < N_PRIMITIVE; i++)
35
36#ifdef Mallard_USE_DOUBLE
37 using rtype = double;
38#else
39 using rtype = float;
40#endif
41
43KOKKOS_INLINE_FUNCTION constexpr rtype operator""_r(long double x) { return static_cast<rtype>(x); }
44KOKKOS_INLINE_FUNCTION constexpr rtype operator""_r(unsigned long long x) { return static_cast<rtype>(x); }
45
52template <typename T = rtype>
54#ifdef Mallard_USE_DOUBLE
55 return static_cast<T>(double_tol);
56#else
57 return static_cast<T>(single_tol);
58#endif
59}
60
61using NVector = std::array<rtype, N_DIM>;
62using NMatrix = std::array<std::array<rtype, N_DIM>, N_DIM>;
63
64#if N_DIM == 2
65const std::array<std::string, N_CONSERVATIVE> CONSERVATIVE_NAMES = {
66 "RHO",
67 "RHOU_X",
68 "RHOU_Y",
69 "RHOE"
70};
71
72const std::array<std::string, N_PRIMITIVE> PRIMITIVE_NAMES = {
73 "U_X",
74 "U_Y",
75 "P",
76 "T",
77 "H"
78};
79#else
80const std::array<std::string, N_CONSERVATIVE> CONSERVATIVE_NAMES = {
81 "RHO",
82 "RHOU_X",
83 "RHOU_Y",
84 "RHOU_Z",
85 "RHOE"
86};
87
88const std::array<std::string, N_PRIMITIVE> PRIMITIVE_NAMES = {
89 "U_X",
90 "U_Y",
91 "U_Z",
92 "P",
93 "T",
94 "H"
95};
96#endif
97
98#endif // COMMON_TYPEDEF_H
KOKKOS_INLINE_FUNCTION rtype dot(const rtype *a, const rtype *b)
Compute the dot product of two arrays.
Definition common_math.h:32
std::array< rtype, N_DIM > NVector
Definition common_typedef.h:61
const std::array< std::string, N_PRIMITIVE > PRIMITIVE_NAMES
Definition common_typedef.h:72
float rtype
Definition common_typedef.h:39
const std::array< std::string, N_CONSERVATIVE > CONSERVATIVE_NAMES
Definition common_typedef.h:65
#define N_DIM
Definition common_typedef.h:28
KOKKOS_INLINE_FUNCTION constexpr T precision_tol(double double_tol, double single_tol)
A tolerance that depends on rtype's precision: double_tol in double builds, single_tol in single....
Definition common_typedef.h:53
std::array< std::array< rtype, N_DIM >, N_DIM > NMatrix
Definition common_typedef.h:62