diff --git a/singularity-eos/eos/eos_base.hpp b/singularity-eos/eos/eos_base.hpp index f206a01a58..8bf3b207dd 100644 --- a/singularity-eos/eos/eos_base.hpp +++ b/singularity-eos/eos/eos_base.hpp @@ -128,6 +128,14 @@ class EosBase { struct is_raw_pointer : std::is_same>, R *> {}; + // Generic evaluator + template + PORTABLE_INLINE_FUNCTION + void Evaluate(const Functor_t &f) const { + CRTP copy = *(static_cast(this)); + f(copy); + } + // Vector member functions template inline void diff --git a/singularity-eos/eos/eos_variant.hpp b/singularity-eos/eos/eos_variant.hpp index 04dc51a9bf..09632d1634 100644 --- a/singularity-eos/eos/eos_variant.hpp +++ b/singularity-eos/eos/eos_variant.hpp @@ -72,6 +72,16 @@ class Variant { } // Place member functions here + template + PORTABLE_INLINE_FUNCTION + void Evaluate(const Functor_t &f) const { + return mpark::visit( + [&f](const auto &eos) { + return eos.Evaluate(f); + }, + eos_); + } + PORTABLE_INLINE_FUNCTION Real TemperatureFromDensityInternalEnergy(const Real rho, const Real sie, Real *lambda = nullptr) const {