Go to the documentation of this file.
16 InputParameters params = validParams<Function>();
18 params.addClassDescription(
"The function uses a cache to potentially reduce the computational "
19 "burden of reusing a complex or costly function");
21 params.addParam<
bool>(
"enable_cache",
23 "Enables cached function evaluations. Recommended only if this function is "
24 "used directly in a BC or Kernel. This will be enabled automatically if "
25 "any of the FX-based BCs are used.");
27 params.addParam<
bool>(
"respect_time",
false,
"Enable to clear the cache at each new time step.");
33 : Function(parameters),
34 _enable_cache(getParam<bool>(
"enable_cache")),
35 _respect_time(getParam<bool>(
"respect_time"))
68 return result.first->second;
bool _respect_time
Flag for whether changes in time invalidate the cache.
Implementation of Function that memoizes (caches) former evaluations in an unordered map using a hash...
void hashCombine(HashValue &)
Final iteration of the variadic template with no additional arguments.
bool _enable_cache
Flag for whether to cache values.
InputParameters validParams< MemoizedFunctionInterface >()
virtual void meshChanged() override
void invalidateCache()
Called by derived classes to invalidate the cache, perhaps due to a state change.
void useCache(bool use)
Enable/disable the cache.
Real _current_time
Stores the time evaluation of the cache.
virtual Real evaluateValue(Real time, const Point &point)=0
Used in derived classes, equivalent to Function::value()
MemoizedFunctionInterface(const InputParameters ¶meters)
virtual Real value(Real time, const Point &point) const final
std::unordered_map< hashing::HashValue, Real > _cache
Cached evaluations for each point.