Skip to content

Commit

Permalink
Add has_G to check if G is in the EOS type (AMReX-Astro#1303)
Browse files Browse the repository at this point in the history
This fixes invocations of gamma_law with types other than eos_t.
  • Loading branch information
maxpkatz authored Aug 6, 2023
1 parent 2ebca13 commit effba81
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion EOS/gamma_law/actual_eos.H
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>::value) {
state.G = 0.5 * (1.0 + eos_gamma);
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion EOS/primordial_chem/actual_eos.H
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>::value) {
state.G = 0.5 * (1.0 + (1.0 + 1.0/sum_gammasinv));
}
}

Real dedT = sum_gammasinv * sum_Abarinv * gasconstant;
Expand Down
8 changes: 8 additions & 0 deletions interfaces/eos_type.H
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ template <typename T>
struct has_dpdA<T, decltype((void)T::dpdA, void())>
: std::true_type {};

template <typename T, typename Enable = void>
struct has_G
: std::false_type {};

template <typename T>
struct has_G<T, decltype((void)T::G, void())>
: std::true_type {};

template <typename T, typename Enable = void>
struct has_dpdZ
: std::false_type {};
Expand Down

0 comments on commit effba81

Please sign in to comment.