diff --git a/src/EOS.hpp b/src/EOS.hpp index 644af4f77..d790cd318 100644 --- a/src/EOS.hpp +++ b/src/EOS.hpp @@ -11,6 +11,7 @@ #include #include +#include "AMReX.H" #include "AMReX_Array.H" #include "AMReX_GpuQualifiers.H" #include "AMReX_REAL.H" @@ -41,25 +42,28 @@ template class EOS public: static constexpr int nmscalars_ = Physics_Traits::numMassScalars; [[nodiscard]] AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE static auto - ComputeTgasFromEint(amrex::Real rho, amrex::Real Eint, std::optional> massScalars = {}) -> amrex::Real; + ComputeTgasFromEint(amrex::Real rho, amrex::Real Eint, std::optional> const &massScalars = {}) -> amrex::Real; [[nodiscard]] AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE static auto - ComputeEintFromTgas(amrex::Real rho, amrex::Real Tgas, std::optional> massScalars = {}) -> amrex::Real; + ComputeEintFromTgas(amrex::Real rho, amrex::Real Tgas, std::optional> const &massScalars = {}) -> amrex::Real; [[nodiscard]] AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE static auto - ComputeEintFromPres(amrex::Real rho, amrex::Real Pressure, std::optional> massScalars = {}) -> amrex::Real; + ComputeEintFromPres(amrex::Real rho, amrex::Real Pressure, std::optional> const &massScalars = {}) + -> amrex::Real; [[nodiscard]] AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE static auto - ComputeEintTempDerivative(amrex::Real rho, amrex::Real Tgas, std::optional> massScalars = {}) -> amrex::Real; + ComputeEintTempDerivative(amrex::Real rho, amrex::Real Tgas, std::optional> const &massScalars = {}) + -> amrex::Real; [[nodiscard]] AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE static auto - ComputeOtherDerivatives(amrex::Real rho, amrex::Real P, std::optional> massScalars = {}); + ComputeOtherDerivatives(amrex::Real rho, amrex::Real P, std::optional> const &massScalars = {}); [[nodiscard]] AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE static auto - ComputePressure(amrex::Real rho, amrex::Real Eint, std::optional> massScalars = {}) -> amrex::Real; + ComputePressure(amrex::Real rho, amrex::Real Eint, std::optional> const &massScalars = {}) -> amrex::Real; [[nodiscard]] AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE static auto - ComputeSoundSpeed(amrex::Real rho, amrex::Real Pressure, std::optional> massScalars = {}) -> amrex::Real; + ComputeSoundSpeed(amrex::Real rho, amrex::Real Pressure, std::optional> const &massScalars = {}) + -> amrex::Real; private: static constexpr amrex::Real gamma_ = EOS_Traits::gamma; @@ -69,7 +73,7 @@ template class EOS template AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto EOS::ComputeTgasFromEint(amrex::Real rho, amrex::Real Eint, - const std::optional> massScalars) + std::optional> const &massScalars) -> amrex::Real { // return temperature for an ideal gas given density and internal energy @@ -94,6 +98,8 @@ AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto EOS::ComputeTgasFromEin eos(eos_input_re, chemstate); Tgas = chemstate.T; #else + amrex::ignore_unused(massScalars); + if constexpr (gamma_ != 1.0) { chem_eos_t estate; estate.rho = rho; @@ -109,7 +115,7 @@ AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto EOS::ComputeTgasFromEin template AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto EOS::ComputeEintFromTgas(amrex::Real rho, amrex::Real Tgas, - const std::optional> massScalars) + std::optional> const &massScalars) -> amrex::Real { // return internal energy density given density and temperature @@ -136,6 +142,8 @@ AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto EOS::ComputeEintFromTga eos(eos_input_rt, chemstate); Eint = chemstate.e * chemstate.rho; #else + amrex::ignore_unused(massScalars); + if constexpr (gamma_ != 1.0) { chem_eos_t estate; estate.rho = rho; @@ -150,7 +158,7 @@ AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto EOS::ComputeEintFromTga template AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto EOS::ComputeEintFromPres(amrex::Real rho, amrex::Real Pressure, - const std::optional> massScalars) + std::optional> const &massScalars) -> amrex::Real { // return internal energy density given density and pressure @@ -175,6 +183,8 @@ AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto EOS::ComputeEintFromPre eos(eos_input_rp, chemstate); Eint = chemstate.e * chemstate.rho; #else + amrex::ignore_unused(massScalars); + if constexpr (gamma_ != 1.0) { chem_eos_t estate; estate.rho = rho; @@ -190,7 +200,7 @@ AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto EOS::ComputeEintFromPre template AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto EOS::ComputeEintTempDerivative(const amrex::Real rho, const amrex::Real Tgas, - const std::optional> massScalars) -> amrex::Real + std::optional> const &massScalars) -> amrex::Real { // compute derivative of internal energy w/r/t temperature, given density and temperature amrex::Real dEint_dT = NAN; @@ -215,6 +225,8 @@ EOS::ComputeEintTempDerivative(const amrex::Real rho, const amrex::Re eos(eos_input_rt, chemstate); dEint_dT = chemstate.dedT * chemstate.rho; #else + amrex::ignore_unused(massScalars); + if constexpr (gamma_ != 1.0) { chem_eos_t estate; estate.rho = rho; @@ -228,8 +240,8 @@ EOS::ComputeEintTempDerivative(const amrex::Real rho, const amrex::Re } template -AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto EOS::ComputeOtherDerivatives(const amrex::Real rho, const amrex::Real P, - const std::optional> massScalars) +AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto +EOS::ComputeOtherDerivatives(const amrex::Real rho, const amrex::Real P, std::optional> const &massScalars) { // compute derivative of specific internal energy w/r/t density, given density and pressure amrex::Real deint_dRho = NAN; @@ -266,6 +278,8 @@ AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto EOS::ComputeOtherDeriva G = chemstate.G; #else + amrex::ignore_unused(massScalars); + if constexpr (gamma_ != 1.0) { chem_eos_t estate; estate.rho = rho; @@ -284,7 +298,7 @@ AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto EOS::ComputeOtherDeriva template AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto EOS::ComputePressure(amrex::Real rho, amrex::Real Eint, - const std::optional> massScalars) + std::optional> const &massScalars) -> amrex::Real { // return pressure for an ideal gas @@ -308,6 +322,8 @@ AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto EOS::ComputePressure(am eos(eos_input_re, chemstate); P = chemstate.p; #else + amrex::ignore_unused(massScalars); + if constexpr (gamma_ != 1.0) { chem_eos_t estate; estate.rho = rho; @@ -327,7 +343,7 @@ AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto EOS::ComputePressure(am template AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto EOS::ComputeSoundSpeed(amrex::Real rho, amrex::Real Pressure, - const std::optional> massScalars) + std::optional> const &massScalars) -> amrex::Real { // return sound speed for an ideal gas @@ -352,6 +368,8 @@ AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto EOS::ComputeSoundSpeed( eos(eos_input_rp, chemstate); cs = chemstate.cs; #else + amrex::ignore_unused(massScalars); + if constexpr (gamma_ != 1.0) { chem_eos_t estate; estate.rho = rho; diff --git a/src/RadMarshak/test_radiation_marshak.cpp b/src/RadMarshak/test_radiation_marshak.cpp index b1996d4d3..b9218d26c 100644 --- a/src/RadMarshak/test_radiation_marshak.cpp +++ b/src/RadMarshak/test_radiation_marshak.cpp @@ -74,22 +74,24 @@ AMREX_GPU_HOST_DEVICE auto RadSystem::ComputeFluxMeanOpacity(con static constexpr int nmscalars_ = Physics_Traits::numMassScalars; template <> AMREX_GPU_HOST_DEVICE auto quokka::EOS::ComputeTgasFromEint(const double /*rho*/, const double Egas, - std::optional> /*massScalars*/) -> double + std::optional> const & /*massScalars*/) + -> double { return std::pow(4.0 * Egas / alpha_SuOlson, 1. / 4.); } template <> AMREX_GPU_HOST_DEVICE auto quokka::EOS::ComputeEintFromTgas(const double /*rho*/, const double Tgas, - std::optional> /*massScalars*/) -> double + std::optional> const & /*massScalars*/) + -> double { return (alpha_SuOlson / 4.0) * std::pow(Tgas, 4); } template <> -AMREX_GPU_HOST_DEVICE auto quokka::EOS::ComputeEintTempDerivative(const double /*rho*/, const double Tgas, - std::optional> /*massScalars*/) - -> double +AMREX_GPU_HOST_DEVICE auto +quokka::EOS::ComputeEintTempDerivative(const double /*rho*/, const double Tgas, + std::optional> const & /*massScalars*/) -> double { // This is also known as the heat capacity, i.e. // \del E_g / \del T = \rho c_v, diff --git a/src/RadMarshakCGS/test_radiation_marshak_cgs.cpp b/src/RadMarshakCGS/test_radiation_marshak_cgs.cpp index 44a4a6849..6522a8c50 100644 --- a/src/RadMarshakCGS/test_radiation_marshak_cgs.cpp +++ b/src/RadMarshakCGS/test_radiation_marshak_cgs.cpp @@ -77,7 +77,7 @@ AMREX_GPU_HOST_DEVICE auto RadSystem::ComputeFluxMeanOpacity( static constexpr int nmscalars_ = Physics_Traits::numMassScalars; template <> AMREX_GPU_HOST_DEVICE auto quokka::EOS::ComputeTgasFromEint(const double /*rho*/, const double Egas, - std::optional> /*massScalars*/) + std::optional> const & /*massScalars*/) -> double { return std::pow(4.0 * Egas / alpha_SuOlson, 1. / 4.); @@ -85,16 +85,16 @@ AMREX_GPU_HOST_DEVICE auto quokka::EOS::ComputeTgasFromEint(c template <> AMREX_GPU_HOST_DEVICE auto quokka::EOS::ComputeEintFromTgas(const double /*rho*/, const double Tgas, - std::optional> /*massScalars*/) + std::optional> const & /*massScalars*/) -> double { return (alpha_SuOlson / 4.0) * std::pow(Tgas, 4); } template <> -AMREX_GPU_HOST_DEVICE auto quokka::EOS::ComputeEintTempDerivative(const double /*rho*/, const double Tgas, - std::optional> /*massScalars*/) - -> double +AMREX_GPU_HOST_DEVICE auto +quokka::EOS::ComputeEintTempDerivative(const double /*rho*/, const double Tgas, + std::optional> const & /*massScalars*/) -> double { // This is also known as the heat capacity, i.e. // \del E_g / \del T = \rho c_v, diff --git a/src/RadMatterCoupling/test_radiation_matter_coupling.cpp b/src/RadMatterCoupling/test_radiation_matter_coupling.cpp index 2ff2040c2..95208dba2 100644 --- a/src/RadMatterCoupling/test_radiation_matter_coupling.cpp +++ b/src/RadMatterCoupling/test_radiation_matter_coupling.cpp @@ -74,22 +74,24 @@ AMREX_GPU_HOST_DEVICE auto RadSystem::ComputeFluxMeanOpacity(co static constexpr int nmscalars_ = Physics_Traits::numMassScalars; template <> AMREX_GPU_HOST_DEVICE auto quokka::EOS::ComputeTgasFromEint(const double /*rho*/, const double Egas, - std::optional> /*massScalars*/) -> double + std::optional> const & /*massScalars*/) + -> double { return std::pow(4.0 * Egas / alpha_SuOlson, 1. / 4.); } template <> AMREX_GPU_HOST_DEVICE auto quokka::EOS::ComputeEintFromTgas(const double /*rho*/, const double Tgas, - std::optional> /*massScalars*/) -> double + std::optional> const & /*massScalars*/) + -> double { return (alpha_SuOlson / 4.0) * std::pow(Tgas, 4); } template <> -AMREX_GPU_HOST_DEVICE auto quokka::EOS::ComputeEintTempDerivative(const double /*rho*/, const double Tgas, - std::optional> /*massScalars*/) - -> double +AMREX_GPU_HOST_DEVICE auto +quokka::EOS::ComputeEintTempDerivative(const double /*rho*/, const double Tgas, + std::optional> const & /*massScalars*/) -> double { // This is also known as the heat capacity, i.e. // \del E_g / \del T = \rho c_v, diff --git a/src/RadMatterCouplingRSLA/test_radiation_matter_coupling_rsla.cpp b/src/RadMatterCouplingRSLA/test_radiation_matter_coupling_rsla.cpp index fb0dfb169..c628534a1 100644 --- a/src/RadMatterCouplingRSLA/test_radiation_matter_coupling_rsla.cpp +++ b/src/RadMatterCouplingRSLA/test_radiation_matter_coupling_rsla.cpp @@ -76,22 +76,24 @@ AMREX_GPU_HOST_DEVICE auto RadSystem::ComputeFluxMeanOpacity(co static constexpr int nmscalars_ = Physics_Traits::numMassScalars; template <> AMREX_GPU_HOST_DEVICE auto quokka::EOS::ComputeTgasFromEint(const double /*rho*/, const double Egas, - std::optional> /*massScalars*/) -> double + std::optional> const & /*massScalars*/) + -> double { return std::pow(4.0 * Egas / alpha_SuOlson, 1. / 4.); } template <> AMREX_GPU_HOST_DEVICE auto quokka::EOS::ComputeEintFromTgas(const double /*rho*/, const double Tgas, - std::optional> /*massScalars*/) -> double + std::optional> const & /*massScalars*/) + -> double { return (alpha_SuOlson / 4.0) * std::pow(Tgas, 4); } template <> -AMREX_GPU_HOST_DEVICE auto quokka::EOS::ComputeEintTempDerivative(const double /*rho*/, const double Tgas, - std::optional> /*massScalars*/) - -> double +AMREX_GPU_HOST_DEVICE auto +quokka::EOS::ComputeEintTempDerivative(const double /*rho*/, const double Tgas, + std::optional> const & /*massScalars*/) -> double { // This is also known as the heat capacity, i.e. // \del E_g / \del T = \rho c_v, diff --git a/src/RadSuOlson/test_radiation_SuOlson.cpp b/src/RadSuOlson/test_radiation_SuOlson.cpp index 221e14789..c788a258e 100644 --- a/src/RadSuOlson/test_radiation_SuOlson.cpp +++ b/src/RadSuOlson/test_radiation_SuOlson.cpp @@ -83,22 +83,24 @@ AMREX_GPU_HOST_DEVICE auto RadSystem::ComputeFluxMeanOpacity(con static constexpr int nmscalars_ = Physics_Traits::numMassScalars; template <> AMREX_GPU_HOST_DEVICE auto quokka::EOS::ComputeTgasFromEint(const double /*rho*/, const double Egas, - std::optional> /*massScalars*/) -> double + std::optional> const & /*massScalars*/) + -> double { return std::pow(4.0 * Egas / alpha_SuOlson, 1. / 4.); } template <> AMREX_GPU_HOST_DEVICE auto quokka::EOS::ComputeEintFromTgas(const double /*rho*/, const double Tgas, - std::optional> /*massScalars*/) -> double + std::optional> const & /*massScalars*/) + -> double { return (alpha_SuOlson / 4.0) * (Tgas * Tgas * Tgas * Tgas); } template <> -AMREX_GPU_HOST_DEVICE auto quokka::EOS::ComputeEintTempDerivative(const double /*rho*/, const double Tgas, - std::optional> /*massScalars*/) - -> double +AMREX_GPU_HOST_DEVICE auto +quokka::EOS::ComputeEintTempDerivative(const double /*rho*/, const double Tgas, + std::optional> const & /*massScalars*/) -> double { // This is also known as the heat capacity, i.e. // \del E_g / \del T = \rho c_v, diff --git a/src/RadTophat/test_radiation_tophat.cpp b/src/RadTophat/test_radiation_tophat.cpp index 773c3896f..79bd8ddb1 100644 --- a/src/RadTophat/test_radiation_tophat.cpp +++ b/src/RadTophat/test_radiation_tophat.cpp @@ -86,16 +86,16 @@ AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto RadSystem::ComputeF static constexpr int nmscalars_ = Physics_Traits::numMassScalars; template <> AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto -quokka::EOS::ComputeTgasFromEint(const double rho, const double Egas, std::optional> /*massScalars*/) - -> double +quokka::EOS::ComputeTgasFromEint(const double rho, const double Egas, + std::optional> const & /*massScalars*/) -> double { return Egas / (rho * c_v); } template <> AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto -quokka::EOS::ComputeEintFromTgas(const double rho, const double Tgas, std::optional> /*massScalars*/) - -> double +quokka::EOS::ComputeEintFromTgas(const double rho, const double Tgas, + std::optional> const & /*massScalars*/) -> double { return rho * c_v * Tgas; } @@ -103,7 +103,7 @@ quokka::EOS::ComputeEintFromTgas(const double rho, const double T template <> AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE auto quokka::EOS::ComputeEintTempDerivative(const double rho, const double /*Tgas*/, - std::optional> /*massScalars*/) -> double + std::optional> const & /*massScalars*/) -> double { // This is also known as the heat capacity, i.e. // \del E_g / \del T = \rho c_v,