Skip to content

Commit

Permalink
static casts for everybody
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahm-LANL committed Apr 23, 2024
1 parent e822af2 commit 88f616b
Show file tree
Hide file tree
Showing 13 changed files with 470 additions and 281 deletions.
102 changes: 64 additions & 38 deletions singularity-eos/eos/eos_davis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class DavisReactants : public EosBase<DavisReactants> {
DavisReactants GetOnDevice() { return *this; }
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real TemperatureFromDensityInternalEnergy(
const Real rho, const Real sie, Indexer_t &&lambda = nullptr) const {
const Real rho, const Real sie,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
const Real es = Es(rho);
const Real tmp = std::pow((1.0 + _alpha) / (Ts(rho) * _Cv0) * (sie - es) + 1.0,
1.0 / (1.0 + _alpha));
Expand All @@ -48,81 +49,93 @@ class DavisReactants : public EosBase<DavisReactants> {
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real InternalEnergyFromDensityTemperature(
const Real rho, const Real temp, Indexer_t &&lambda = nullptr) const {
const Real rho, const Real temp,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
const Real t_s = Ts(rho);
return Es(rho) +
_Cv0 * t_s / (1.0 + _alpha) * (std::pow(temp / t_s, 1.0 + _alpha) - 1.0);
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real PressureFromDensityTemperature(
const Real rho, const Real temp, Indexer_t &&lambda = nullptr) const {
const Real rho, const Real temp,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
return PressureFromDensityInternalEnergy(
rho, InternalEnergyFromDensityTemperature(rho, temp));
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real PressureFromDensityInternalEnergy(
const Real rho, const Real sie, Indexer_t &&lambda = nullptr) const {
const Real rho, const Real sie,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
return Ps(rho) + Gamma(rho) * rho * (sie - Es(rho));
}

template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real
MinInternalEnergyFromDensity(const Real rho, Indexer_t &&lambda = nullptr) const {
PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(
const Real rho, Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
MinInternalEnergyIsNotEnabled("DavisReactants");
return 0.0;
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature(
const Real rho, const Real temperature, Indexer_t &&lambda = nullptr) const {
PORTABLE_INLINE_FUNCTION Real
EntropyFromDensityTemperature(const Real rho, const Real temperature,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
EntropyIsNotEnabled("DavisReactants");
return 1.0;
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real EntropyFromDensityInternalEnergy(
const Real rho, const Real sie, Indexer_t &&lambda = nullptr) const {
const Real rho, const Real sie,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
EntropyIsNotEnabled("DavisReactants");
return 1.0;
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real SpecificHeatFromDensityTemperature(
const Real rho, const Real temp, Indexer_t &&lambda = nullptr) const {
const Real rho, const Real temp,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
return SpecificHeatFromDensityInternalEnergy(
rho, InternalEnergyFromDensityTemperature(rho, temp));
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real SpecificHeatFromDensityInternalEnergy(
const Real rho, const Real sie, Indexer_t &&lambda = nullptr) const {
const Real rho, const Real sie,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
return _Cv0 / std::pow((1 + _alpha) / (Ts(rho) * _Cv0) * (sie - Es(rho)) + 1,
-_alpha / (1 + _alpha));
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real BulkModulusFromDensityTemperature(
const Real rho, const Real temp, Indexer_t &&lambda = nullptr) const {
const Real rho, const Real temp,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
return BulkModulusFromDensityInternalEnergy(
rho, InternalEnergyFromDensityTemperature(rho, temp));
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real BulkModulusFromDensityInternalEnergy(
const Real rho, const Real sie, Indexer_t &&lambda = nullptr) const;
const Real rho, const Real sie,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real GruneisenParamFromDensityTemperature(
const Real rho, const Real temperature, Indexer_t &&lambda = nullptr) const {
const Real rho, const Real temperature,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
return Gamma(rho);
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real GruneisenParamFromDensityInternalEnergy(
const Real rho, const Real sie, Indexer_t &&lambda = nullptr) const {
const Real rho, const Real sie,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
return Gamma(rho);
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION void FillEos(Real &rho, Real &temp, Real &energy, Real &press,
Real &cv, Real &bmod, const unsigned long output,
Indexer_t &&lambda = nullptr) const;
PORTABLE_INLINE_FUNCTION void
FillEos(Real &rho, Real &temp, Real &energy, Real &press, Real &cv, Real &bmod,
const unsigned long output,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION void
ValuesAtReferenceState(Real &rho, Real &temp, Real &sie, Real &press, Real &cv,
Real &bmod, Real &dpde, Real &dvdt,
Indexer_t &&lambda = nullptr) const;
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION void
DensityEnergyFromPressureTemperature(const Real press, const Real temp,
Expand Down Expand Up @@ -169,85 +182,98 @@ class DavisProducts : public EosBase<DavisProducts> {
DavisProducts GetOnDevice() { return *this; }
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real TemperatureFromDensityInternalEnergy(
const Real rho, const Real sie, Indexer_t &&lambda = nullptr) const {
const Real rho, const Real sie,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
return Ts(rho) + (sie - Es(rho)) / _Cv;
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real InternalEnergyFromDensityTemperature(
const Real rho, const Real temp, Indexer_t &&lambda = nullptr) const {
const Real rho, const Real temp,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
return _Cv * (temp - Ts(rho)) + Es(rho);
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real PressureFromDensityTemperature(
const Real rho, const Real temp, Indexer_t &&lambda = nullptr) const {
const Real rho, const Real temp,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
return PressureFromDensityInternalEnergy(
rho, InternalEnergyFromDensityTemperature(rho, temp));
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real PressureFromDensityInternalEnergy(
const Real rho, const Real sie, Indexer_t &&lambda = nullptr) const {
const Real rho, const Real sie,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
return Ps(rho) + rho * Gamma(rho) * (sie - Es(rho));
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real
MinInternalEnergyFromDensity(const Real rho, Indexer_t &&lambda = nullptr) const {
PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(
const Real rho, Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
MinInternalEnergyIsNotEnabled("DavisProducts");
return 0.0;
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature(
const Real rho, const Real temperature, Indexer_t &&lambda = nullptr) const {
PORTABLE_INLINE_FUNCTION Real
EntropyFromDensityTemperature(const Real rho, const Real temperature,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
EntropyIsNotEnabled("DavisProducts");
return 1.0;
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real EntropyFromDensityInternalEnergy(
const Real rho, const Real sie, Indexer_t &&lambda = nullptr) const {
const Real rho, const Real sie,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
EntropyIsNotEnabled("DavisProducts");
return 1.0;
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real SpecificHeatFromDensityTemperature(
const Real rho, const Real temperature, Indexer_t &&lambda = nullptr) const {
const Real rho, const Real temperature,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
return _Cv;
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real SpecificHeatFromDensityInternalEnergy(
const Real rho, const Real sie, Indexer_t &&lambda = nullptr) const {
const Real rho, const Real sie,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
return _Cv;
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real BulkModulusFromDensityTemperature(
const Real rho, const Real temp, Indexer_t &&lambda = nullptr) const {
const Real rho, const Real temp,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
return BulkModulusFromDensityInternalEnergy(
rho, InternalEnergyFromDensityTemperature(rho, temp));
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real BulkModulusFromDensityInternalEnergy(
const Real rho, const Real sie, Indexer_t &&lambda = nullptr) const;
const Real rho, const Real sie,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real GruneisenParamFromDensityTemperature(
const Real rho, const Real temperature, Indexer_t &&lambda = nullptr) const {
const Real rho, const Real temperature,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
return Gamma(rho);
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real GruneisenParamFromDensityInternalEnergy(
const Real rho, const Real sie, Indexer_t &&lambda = nullptr) const {
const Real rho, const Real sie,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const {
return Gamma(rho);
}
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION void
DensityEnergyFromPressureTemperature(const Real press, const Real temp,
Indexer_t &&lambda, Real &rho, Real &sie) const;
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION void FillEos(Real &rho, Real &temp, Real &energy, Real &press,
Real &cv, Real &bmod, const unsigned long output,
Indexer_t &&lambda = nullptr) const;
PORTABLE_INLINE_FUNCTION void
FillEos(Real &rho, Real &temp, Real &energy, Real &press, Real &cv, Real &bmod,
const unsigned long output,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION void
ValuesAtReferenceState(Real &rho, Real &temp, Real &sie, Real &press, Real &cv,
Real &bmod, Real &dpde, Real &dvdt,
Indexer_t &&lambda = nullptr) const;
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
// Generic functions provided by the base class. These contain e.g. the vector
// overloads that use the scalar versions declared here
SG_ADD_BASE_CLASS_USINGS(DavisProducts)
Expand Down
53 changes: 33 additions & 20 deletions singularity-eos/eos/eos_eospac.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,60 +144,73 @@ class EOSPAC : public EosBase<EOSPAC> {
SG_PIF_NOWARN
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real TemperatureFromDensityInternalEnergy(
const Real rho, const Real sie, Indexer_t &&lambda = nullptr) const;
const Real rho, const Real sie,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
SG_PIF_NOWARN
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real InternalEnergyFromDensityTemperature(
const Real rho, const Real temperature, Indexer_t &&lambda = nullptr) const;
const Real rho, const Real temperature,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
SG_PIF_NOWARN
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real PressureFromDensityTemperature(
const Real rho, const Real temperature, Indexer_t &&lambda = nullptr) const;
PORTABLE_INLINE_FUNCTION Real
PressureFromDensityTemperature(const Real rho, const Real temperature,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
SG_PIF_NOWARN
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real PressureFromDensityInternalEnergy(
const Real rho, const Real sie, Indexer_t &&lambda = nullptr) const;
const Real rho, const Real sie,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
SG_PIF_NOWARN
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real
MinInternalEnergyFromDensity(const Real rho, Indexer_t &&lambda = nullptr) const;
PORTABLE_INLINE_FUNCTION Real MinInternalEnergyFromDensity(
const Real rho, Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
SG_PIF_NOWARN
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real EntropyFromDensityTemperature(
const Real rho, const Real temperature, Indexer_t &&lambda = nullptr) const;
PORTABLE_INLINE_FUNCTION Real
EntropyFromDensityTemperature(const Real rho, const Real temperature,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
SG_PIF_NOWARN
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real EntropyFromDensityInternalEnergy(
const Real rho, const Real sie, Indexer_t &&lambda = nullptr) const;
const Real rho, const Real sie,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
SG_PIF_NOWARN
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real SpecificHeatFromDensityTemperature(
const Real rho, const Real temperature, Indexer_t &&lambda = nullptr) const;
const Real rho, const Real temperature,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
SG_PIF_NOWARN
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real SpecificHeatFromDensityInternalEnergy(
const Real rho, const Real sie, Indexer_t &&lambda = nullptr) const;
const Real rho, const Real sie,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
SG_PIF_NOWARN
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real BulkModulusFromDensityTemperature(
const Real rho, const Real temperature, Indexer_t &&lambda = nullptr) const;
const Real rho, const Real temperature,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
SG_PIF_NOWARN
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real BulkModulusFromDensityInternalEnergy(
const Real rho, const Real sie, Indexer_t &&lambda = nullptr) const;
const Real rho, const Real sie,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
SG_PIF_NOWARN
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real GruneisenParamFromDensityTemperature(
const Real rho, const Real temperature, Indexer_t &&lambda = nullptr) const;
const Real rho, const Real temperature,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
SG_PIF_NOWARN
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION Real GruneisenParamFromDensityInternalEnergy(
const Real rho, const Real sie, Indexer_t &&lambda = nullptr) const;
const Real rho, const Real sie,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
SG_PIF_NOWARN
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION void FillEos(Real &rho, Real &temp, Real &energy, Real &press,
Real &cv, Real &bmod, const unsigned long output,
Indexer_t &&lambda = nullptr) const;
PORTABLE_INLINE_FUNCTION void
FillEos(Real &rho, Real &temp, Real &energy, Real &press, Real &cv, Real &bmod,
const unsigned long output,
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;
SG_PIF_NOWARN
template <typename Indexer_t = Real *>
PORTABLE_INLINE_FUNCTION void
Expand All @@ -208,7 +221,7 @@ class EOSPAC : public EosBase<EOSPAC> {
PORTABLE_INLINE_FUNCTION void
ValuesAtReferenceState(Real &rho, Real &temp, Real &sie, Real &press, Real &cv,
Real &bmod, Real &dpde, Real &dvdt,
Indexer_t &&lambda = nullptr) const;
Indexer_t &&lambda = static_cast<Real *>(nullptr)) const;

// Generic (Scalar)
using EosBase<EOSPAC>::is_raw_pointer;
Expand Down
Loading

0 comments on commit 88f616b

Please sign in to comment.