From effba81d241424a4497ef8ea882eb5836f894773 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Sun, 6 Aug 2023 18:41:21 -0400 Subject: [PATCH] Add has_G to check if G is in the EOS type (#1303) This fixes invocations of gamma_law with types other than eos_t. --- EOS/gamma_law/actual_eos.H | 4 +++- EOS/primordial_chem/actual_eos.H | 4 +++- interfaces/eos_type.H | 8 ++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/EOS/gamma_law/actual_eos.H b/EOS/gamma_law/actual_eos.H index e375694403..1ca36e5b70 100644 --- a/EOS/gamma_law/actual_eos.H +++ b/EOS/gamma_law/actual_eos.H @@ -265,7 +265,9 @@ void actual_eos (I input, T& state) // sound speed state.cs = std::sqrt(eos_gamma * state.p * rhoinv); - state.G = 0.5 * (1.0 + eos_gamma); + if constexpr (has_G::value) { + state.G = 0.5 * (1.0 + eos_gamma); + } } } diff --git a/EOS/primordial_chem/actual_eos.H b/EOS/primordial_chem/actual_eos.H index e268d4b69d..b5cbf1e400 100644 --- a/EOS/primordial_chem/actual_eos.H +++ b/EOS/primordial_chem/actual_eos.H @@ -278,7 +278,9 @@ void actual_eos (I input, T& state) state.dpdT = pressure / temp; state.dpdr = pressure / dens; state.cs = std::sqrt((1.0 + 1.0/sum_gammasinv) * state.p /state.rho); - state.G = 0.5 * (1.0 + (1.0 + 1.0/sum_gammasinv)); + if constexpr (has_G::value) { + state.G = 0.5 * (1.0 + (1.0 + 1.0/sum_gammasinv)); + } } Real dedT = sum_gammasinv * sum_Abarinv * gasconstant; diff --git a/interfaces/eos_type.H b/interfaces/eos_type.H index cd4f494cfd..cdfe210a13 100644 --- a/interfaces/eos_type.H +++ b/interfaces/eos_type.H @@ -198,6 +198,14 @@ template struct has_dpdA : std::true_type {}; +template +struct has_G + : std::false_type {}; + +template +struct has_G + : std::true_type {}; + template struct has_dpdZ : std::false_type {};