Skip to content

Commit

Permalink
static asserts in templates
Browse files Browse the repository at this point in the history
  • Loading branch information
baperry2 committed Oct 9, 2024
1 parent 3872f13 commit bc637b0
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions Source/Eos/Fuego.H
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,27 @@ struct Fuego

static std::string identifier() { return "Fuego"; }

template <typename T, int first=0>
AMREX_GPU_HOST_DEVICE
AMREX_FORCE_INLINE
static void RY2R(const T RY, amrex::Real& R)
template <typename T, int first = 0>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE static void
RY2R(const T RY, amrex::Real& R)
{
static_assert(
std::is_same_v<decltype(RY[0]), amrex::Real&> ||
std::is_same_v<decltype(RY[0]), const amrex::Real&>);
R = 0.0;
for (int i = 0; i < NUM_SPECIES; i++) {
R += RY[first + i];
}
}

AMREX_GPU_HOST_DEVICE
AMREX_FORCE_INLINE
static void RY2RRinvY(
const amrex::Real RY[], amrex::Real& R, amrex::Real& Rinv, amrex::Real Y[])
template <typename T, typename T2>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE static void
RY2RRinvY(const T RY, amrex::Real& R, amrex::Real& Rinv, T2 Y)
{
static_assert(
std::is_same_v<decltype(RY[0]), amrex::Real&> ||
std::is_same_v<decltype(RY[0]), const amrex::Real&>);
static_assert(std::is_same_v<decltype(Y[0]), amrex::Real&>);
RY2R(RY, R);
Rinv = 1.0 / R;
for (int i = 0; i < NUM_SPECIES; i++) {
Expand Down

0 comments on commit bc637b0

Please sign in to comment.