A special version of RestartableData to aid in storing Reporter values. More...
#include <ReporterState.h>
Public Member Functions | |
ReporterState (const ReporterName &name) | |
void | copyValuesBack () |
Copy stored values back in time to old/older etc. More... | |
bool | restoreState () |
Restore values to their old values, i.e. More... | |
std::string | valueType () const override final |
const ReporterName & | getReporterName () const |
Return the ReporterName that this state is associated with. More... | |
void | addConsumer (ReporterMode mode, const MooseObject &moose_object) |
Add a consumer for this ReporterState. More... | |
const std::set< std::pair< ReporterMode, const MooseObject * > > & | getConsumers () const |
Returns the consumers for this state; a pair that consists of the mode that the state is being consumed by, and the object consuming it. More... | |
void | setIsPostprocessor () |
Sets the special Reporter type to a Postprocessor. More... | |
void | setIsVectorPostprocessor () |
Sets the special Reporter type to a VectorPostprocessor. More... | |
const std::list< T > & | get () const |
std::list< T > & | set () |
void | reset () |
Resets (destructs) the underlying data. More... | |
virtual std::string | type () const override final |
String identifying the type of parameter stored. More... | |
virtual const std::type_info & | typeId () const override final |
The type ID of the underlying data. More... | |
virtual bool | hasStoreJSON () const override final |
const std::string & | name () const |
The full (unique) name of this particular piece of data. More... | |
void * | context () |
A context pointer for helping with load / store. More... | |
bool | hasContext () const |
bool | declared () const |
Whether or not this data has been declared. More... | |
void | setDeclared (const SetDeclaredKey) |
Sets that this restartable value has been declared. More... | |
bool | loaded () const |
Whether or not this data has been loaded. More... | |
void | setNotLoaded (const SetNotLoadedKey) |
Sets that this restartable value has been loaded. More... | |
bool | stored () const |
Whether or not this data has been loaded. More... | |
void | setNotStored (const SetNotStoredKey) |
Sets that this restartable value has been loaded. More... | |
void | store (std::ostream &stream) |
Stores the value into the stream stream and sets it as stored. More... | |
void | store (nlohmann::json &json, const StoreJSONParams ¶ms=StoreJSONParams{}) const |
Stores this restartable data in the JSON entry json , with the options set by params (optional; defaults to just the type and underlying value) More... | |
void | load (std::istream &stream) |
Loads the value from the stream stream and sets it as loaded. More... | |
T & | value (const std::size_t time_index=0) |
Return a reference to the current value or one of the old values. More... | |
const T & | value (const std::size_t time_index=0) const |
void | storeInternal (std::ostream &stream) override final |
Loads and stores the data from/to a stream for restart. More... | |
void | loadInternal (std::istream &stream) override final |
Load the RestartableData from a binary stream. More... | |
Static Public Attributes | |
static constexpr bool | has_store_json |
Whether or not this type has a JSON store method implemented. More... | |
Protected Member Functions | |
virtual void | storeJSONValue (nlohmann::json &json) const override final |
Internal method for storing the underlying JSON value. More... | |
Protected Attributes | |
const std::string | _name |
The full (unique) name of this particular piece of data. More... | |
void *const | _context |
A context pointer for helping with load and store. More... | |
A special version of RestartableData to aid in storing Reporter values.
This object is used by the ReporterData object. The objects provides a convenient method to define Reporter data that has a value as well as some number of old data values. Please refer to ReporterData.h for more information regarding the use of this class.
name | The name of the Reporter value |
This class stores the current/old/older/... data using a std::list to allow values to be inserted into the data structure without corrupting references to the other values. This allows for arbitrary time data to be stored.
NOTE: Access to the data should be through the value() method to ensure the data is allocated correctly
Definition at line 110 of file ReporterState.h.
ReporterState< T >::ReporterState | ( | const ReporterName & | name | ) |
Definition at line 162 of file ReporterState.h.
|
inherited |
Add a consumer for this ReporterState.
mode | The mode that the object will consume the Reporter value |
moose_object | The MooseObject doing the consuming (for error reporting) |
Definition at line 17 of file ReporterState.C.
Referenced by ReporterTransferInterface::addReporterTransferMode().
|
inlineinherited |
A context pointer for helping with load / store.
Definition at line 65 of file RestartableData.h.
void ReporterState< T >::copyValuesBack | ( | ) |
Copy stored values back in time to old/older etc.
Definition at line 209 of file ReporterState.h.
|
inlineinherited |
Whether or not this data has been declared.
Definition at line 85 of file RestartableData.h.
Referenced by RestartableDataValue::store().
|
inlineinherited |
Definition at line 280 of file RestartableData.h.
|
inlineinherited |
Returns the consumers for this state; a pair that consists of the mode that the state is being consumed by, and the object consuming it.
Definition at line 56 of file ReporterState.h.
Referenced by ReporterData::getReporterInfo(), and ReporterContextBase::requiresConsumerModes().
|
inlineinherited |
Return the ReporterName that this state is associated with.
Definition at line 41 of file ReporterState.h.
Referenced by ReporterData::getReporterInfo().
|
inlineinherited |
Definition at line 70 of file RestartableData.h.
Referenced by RestartableDataValue::store().
|
inlinefinaloverridevirtualinherited |
store
Implements RestartableDataValue.
Definition at line 256 of file RestartableData.h.
|
inherited |
Loads the value from the stream stream
and sets it as loaded.
Definition at line 32 of file RestartableData.C.
|
inlineinherited |
Whether or not this data has been loaded.
This is typically reset on a call to RestartableDataReader::restore()
Definition at line 98 of file RestartableData.h.
Referenced by RestartableDataValue::store().
|
finaloverridevirtual |
Load the RestartableData from a binary stream.
Reimplemented from RestartableData< std::list< T > >.
Definition at line 244 of file ReporterState.h.
|
inlineinherited |
The full (unique) name of this particular piece of data.
Definition at line 60 of file RestartableData.h.
Referenced by RestartableDataMap::addData(), RestartableDataMap::findData(), and RestartableDataValue::store().
|
inlineinherited |
Resets (destructs) the underlying data.
Definition at line 296 of file RestartableData.h.
bool ReporterState< T >::restoreState | ( | ) |
Restore values to their old values, i.e.
value(0) = value(1). This only occurs if old values have been declared, which happens automatically for postprocessors.
Definition at line 220 of file ReporterState.h.
|
inlineinherited |
Definition at line 288 of file RestartableData.h.
|
inherited |
Sets that this restartable value has been declared.
Definition at line 18 of file RestartableData.C.
Referenced by MooseApp::registerRestartableData().
|
inlineinherited |
Sets the special Reporter type to a Postprocessor.
See ReporterData::declareReporterValue.
Definition at line 71 of file ReporterState.h.
|
inlineinherited |
Sets the special Reporter type to a VectorPostprocessor.
See ReporterData::declareReporterValue.
Definition at line 77 of file ReporterState.h.
|
inlineinherited |
Sets that this restartable value has been loaded.
Definition at line 113 of file RestartableData.h.
|
inlineinherited |
Sets that this restartable value has been loaded.
Definition at line 136 of file RestartableData.h.
|
inherited |
Stores the value into the stream stream
and sets it as stored.
Definition at line 25 of file RestartableData.C.
|
inherited |
Stores this restartable data in the JSON entry json
, with the options set by params
(optional; defaults to just the type and underlying value)
If the underlying type is not supported for JSON output (if hasStoreJSON() == false), and the parameters have the value output as enabled, this will error.
Definition at line 39 of file RestartableData.C.
|
inlineinherited |
Whether or not this data has been loaded.
This is typically reset on a call to RestartableDataWriter::write()
Definition at line 121 of file RestartableData.h.
Referenced by RestartableDataValue::store().
|
finaloverridevirtual |
Loads and stores the data from/to a stream for restart.
This is a special version that handles the fact that the calls declare/getReporterValue occur within the constructor of objects. As such, the storage list already contains data and the references to this data must remain valid.
The default dataLoad assumes the list being populated is empty and simply uses push_back. Therefore, this function loads the data directly into the container to avoid this problem and unnecessary copies.
The default dataStore is very similar, but to ensure consistency (because we're re-defining the load), we implement it again here.
Reimplemented from RestartableData< std::list< T > >.
Definition at line 231 of file ReporterState.h.
|
inlinefinaloverrideprotectedvirtualinherited |
Internal method for storing the underlying JSON value.
Implements RestartableDataValue.
Definition at line 325 of file RestartableData.h.
|
inlinefinaloverridevirtualinherited |
String identifying the type of parameter stored.
Implements RestartableDataValue.
Definition at line 304 of file RestartableData.h.
|
inlinefinaloverridevirtualinherited |
The type ID of the underlying data.
Implements RestartableDataValue.
Definition at line 254 of file RestartableData.h.
T & ReporterState< T >::value | ( | const std::size_t | time_index = 0 | ) |
Return a reference to the current value or one of the old values.
The time_index of 0 returns the current value, 1 returns old, 2 returns older, etc.
Definition at line 169 of file ReporterState.h.
Referenced by ReporterVectorContext< T >::clear(), ReporterData::getReporterValue(), ReporterVectorContext< T >::resize(), and ReporterVectorContext< T >::vectorSum().
const T & ReporterState< T >::value | ( | const std::size_t | time_index = 0 | ) | const |
Definition at line 193 of file ReporterState.h.
|
inlinefinaloverridevirtual |
Implements ReporterStateBase.
Definition at line 139 of file ReporterState.h.
|
protectedinherited |
A context pointer for helping with load and store.
Definition at line 197 of file RestartableData.h.
Referenced by RestartableDataValue::context(), and RestartableDataValue::hasContext().
|
protectedinherited |
The full (unique) name of this particular piece of data.
Definition at line 194 of file RestartableData.h.
Referenced by RestartableDataValue::name().
|
staticinherited |
Whether or not this type has a JSON store method implemented.
Definition at line 219 of file RestartableData.h.