Implementation of Function that memoizes (caches) former evaluations in an unordered map using a hash of the evaluation locations as the key. More...
#include <MemoizedFunctionInterface.h>
Public Member Functions | |
MemoizedFunctionInterface (const InputParameters ¶meters) | |
virtual void | meshChanged () override |
void | useCache (bool use) |
Enable/disable the cache. More... | |
virtual Real | value (Real time, const Point &point) const final |
Protected Member Functions | |
virtual Real | evaluateValue (Real time, const Point &point)=0 |
Used in derived classes, equivalent to Function::value() More... | |
void | invalidateCache () |
Called by derived classes to invalidate the cache, perhaps due to a state change. More... | |
Private Attributes | |
std::unordered_map< hashing::HashValue, Real > | _cache |
Cached evaluations for each point. More... | |
Real | _current_time |
Stores the time evaluation of the cache. More... | |
bool | _enable_cache |
Flag for whether to cache values. More... | |
bool | _respect_time |
Flag for whether changes in time invalidate the cache. More... | |
Implementation of Function that memoizes (caches) former evaluations in an unordered map using a hash of the evaluation locations as the key.
The purpose is to allow for quick evaluation of a complex function that may be reevaluated multiple times without changing the actual outputs.
Definition at line 28 of file MemoizedFunctionInterface.h.
MemoizedFunctionInterface::MemoizedFunctionInterface | ( | const InputParameters & | parameters | ) |
Definition at line 32 of file MemoizedFunctionInterface.C.
|
protectedpure virtual |
Used in derived classes, equivalent to Function::value()
Implemented in FunctionSeries.
Referenced by value().
|
protected |
Called by derived classes to invalidate the cache, perhaps due to a state change.
Definition at line 84 of file MemoizedFunctionInterface.C.
Referenced by MutableCoefficientsFunctionInterface::coefficientsChanged(), meshChanged(), useCache(), and value().
|
overridevirtual |
Definition at line 40 of file MemoizedFunctionInterface.C.
void MemoizedFunctionInterface::useCache | ( | bool | use | ) |
Enable/disable the cache.
Definition at line 75 of file MemoizedFunctionInterface.C.
Referenced by FXFluxBC::FXFluxBC(), FXValueBC::FXValueBC(), and FXValuePenaltyBC::FXValuePenaltyBC().
|
finalvirtual |
Definition at line 47 of file MemoizedFunctionInterface.C.
|
mutableprivate |
Cached evaluations for each point.
Definition at line 59 of file MemoizedFunctionInterface.h.
Referenced by invalidateCache(), and value().
|
mutableprivate |
Stores the time evaluation of the cache.
Definition at line 62 of file MemoizedFunctionInterface.h.
Referenced by value().
|
private |
Flag for whether to cache values.
Definition at line 65 of file MemoizedFunctionInterface.h.
Referenced by useCache(), and value().
|
private |
Flag for whether changes in time invalidate the cache.
Definition at line 68 of file MemoizedFunctionInterface.h.
Referenced by value().