Skip to content

Commit

Permalink
add generic evaluator
Browse files Browse the repository at this point in the history
  • Loading branch information
jdolence committed Oct 9, 2023
1 parent 790cba7 commit 73a6561
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions singularity-eos/eos/eos_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ class EosBase {
struct is_raw_pointer
: std::is_same<std::remove_reference_t<std::remove_cv_t<T>>, R *> {};

// Generic evaluator
template <typename Functor_t>
PORTABLE_INLINE_FUNCTION
void Evaluate(const Functor_t &f) const {
CRTP copy = *(static_cast<CRTP const *>(this));
f(copy);
}

// Vector member functions
template <typename RealIndexer, typename ConstRealIndexer, typename LambdaIndexer>
inline void
Expand Down
10 changes: 10 additions & 0 deletions singularity-eos/eos/eos_variant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ class Variant {
}

// Place member functions here
template <typename Functor_t>
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 {
Expand Down

0 comments on commit 73a6561

Please sign in to comment.