This is a helper class for managing the storage of declared Reporter object values. More...
#include <ReporterData.h>
Classes | |
class | WriteKey |
Public Member Functions | |
ReporterData (MooseApp &moose_app) | |
template<typename T > | |
bool | hasReporterValue (const ReporterName &reporter_name) const |
Return True if a Reporter value with the given type and name have been created. More... | |
bool | hasReporterValue (const ReporterName &reporter_name) const |
Return True if a Reporter value with any type exists with the given name. More... | |
template<typename T > | |
bool | hasReporterState (const ReporterName &reporter_name) const |
bool | hasReporterState (const ReporterName &reporter_name) const |
std::set< ReporterName > | getReporterNames () const |
Return a list of all reporter names. More... | |
std::set< std::string > | getPostprocessorNames () const |
Return a list of all postprocessor names. More... | |
DenseVector< Real > | getAllRealReporterValues () const |
Get all real reporter values including postprocessor and vector postprocessor values into a dense vector. More... | |
std::vector< std::string > | getAllRealReporterFullNames () const |
Get full names of all real reporter values Note: For a postprocessor, the full name is the postprocessor name plus '/value'. More... | |
template<typename T > | |
const T & | getReporterValue (const ReporterName &reporter_name, const MooseObject &consumer, const ReporterMode &mode, const std::size_t time_index=0) const |
Method for returning read only references to Reporter values. More... | |
template<typename T > | |
const T & | getReporterValue (const ReporterName &reporter_name, const std::size_t time_index=0) const |
Method for returning a read-only reference to Reporter values that already exist. More... | |
template<typename T > | |
void | setReporterValue (const ReporterName &reporter_name, const T &value, const std::size_t time_index=0) |
Method for setting Reporter values that already exist. More... | |
template<typename T > | |
void | needReporterTimeIndex (const ReporterName &reporter_name, const std::size_t time_index) |
Method for setting that a specific time index is requested for a Reporter value. More... | |
const ReporterProducerEnum & | getReporterMode (const ReporterName &reporter_name) const |
Return the ReporterProducerEnum for an existing ReporterValue. More... | |
std::string | getReporterInfo (const ReporterName &reporter_name) const |
Gets information pertaining to the Reporter with name reporter_name . More... | |
std::string | getReporterInfo () const |
Gets information about all declared/requested Reporters. More... | |
template<typename T , typename S , typename... Args> | |
T & | declareReporterValue (const ReporterName &reporter_name, const ReporterMode &mode, const MooseObject &producer, Args &&... args) |
Method for returning a writable reference to the current Reporter value. More... | |
void | finalize (const std::string &object_name) |
Helper function for performing post calculation actions via the ReporterContext objects. More... | |
void | copyValuesBack () |
At the end of a timestep this method is called to copy the values back in time in preparation for the next timestep. More... | |
void | restoreState (bool verbose=false) |
When a time step fails, this method is called to revert the current reporter values to their old state. More... | |
void | check () const |
Perform integrity check for get/declare calls. More... | |
bool | hasReporterWithMode (const std::string &obj_name, const ReporterMode &mode) const |
Return true if the supplied mode exists in the produced Reporter values. More... | |
const ReporterContextBase & | getReporterContextBase (const ReporterName &reporter_name) const |
ReporterContextBase & | getReporterContextBase (const ReporterName &reporter_name) |
const ReporterStateBase & | getReporterStateBase (const ReporterName &reporter_name) const |
The ReporterStateBase associated with the Reporter with name reporter_name . More... | |
ReporterStateBase & | getReporterStateBase (const ReporterName &reporter_name) |
Static Public Member Functions | |
static std::string | getReporterInfo (const ReporterStateBase &state, const ReporterContextBase *context) |
Gets information pertaining to the Reporter with state state and possibly context context . More... | |
Private Member Functions | |
template<typename T > | |
ReporterState< T > & | getReporterStateHelper (const ReporterName &reporter_name, bool declare, const MooseObject *moose_object=nullptr) const |
Helper method for creating the necessary RestartableData for Reporter values. More... | |
RestartableDataValue & | getRestartableDataHelper (std::unique_ptr< RestartableDataValue > data_ptr, bool declare) const |
Helper for registering data with the MooseApp to avoid cyclic includes. More... | |
Private Attributes | |
MooseApp & | _app |
For accessing the restart/recover system, which is where Reporter values are stored. More... | |
std::map< ReporterName, ReporterStateBase * > | _states |
Map from ReporterName -> Reporter state. More... | |
std::map< ReporterName, std::unique_ptr< ReporterContextBase > > | _context_ptrs |
The ReporterContext objects are created when a value is declared. More... | |
This is a helper class for managing the storage of declared Reporter object values.
This design of the system is a generalization of the VectorPostprocessor system that the Reporter objects replaced.
Foremost, this object doesn't store the data. It simply acts as helper for using the restart system of the MooseApp. This object automatically handles the old, older, ... data. All declarations create std::pair<T, std::vector<T>> restartable data on the MooseApp, where the first value is the current value and the data in the vector are the older data.
The ReporterState object is a RestartableData object that serves as a helper for managing the time history. A "context" object also exists that uses the ReporterState for performing special operations. Refer to ReporterState.h/C for more information.
It is important to note that the Reporter values are not threaded. However, the Reporter objects are UserObject based, so the calculation of the values can be threaded.
This object also relies on ReporterName objects, which are simply a combination of the Reporter object name and the data name. If you recall the VectorPostprocessor system on which this is based required an object name and a vector name. The ReporterName class simply provides a convenient way to provide that information in a single object. Special Parser syntax was also defined so that application developers do not have to have input parameters for both the object and data names (see Parser.C/h).
Definition at line 48 of file ReporterData.h.
ReporterData::ReporterData | ( | MooseApp & | moose_app | ) |
Definition at line 14 of file ReporterData.C.
void ReporterData::check | ( | ) | const |
Perform integrity check for get/declare calls.
Definition at line 162 of file ReporterData.C.
Referenced by FEProblemBase::initialSetup().
void ReporterData::copyValuesBack | ( | ) |
At the end of a timestep this method is called to copy the values back in time in preparation for the next timestep.
See FEProblemBase::advanceState
Definition at line 17 of file ReporterData.C.
Referenced by FEProblemBase::advanceState().
T & ReporterData::declareReporterValue | ( | const ReporterName & | reporter_name, |
const ReporterMode & | mode, | ||
const MooseObject & | producer, | ||
Args &&... | args | ||
) |
Method for returning a writable reference to the current Reporter value.
This method is used by the Reporter class to produce values.
T | The Reporter value C++ type. |
S | (optional) The ReporterContext for performing specialized actions after the values have been computed. For example, ReporterBroadcastContext automatically broadcasts the computed value. See ReporterState.C/h for more information. |
reporter_name | The name of the reporter value, which includes the object name and the data name. |
mode | The mode that the produced value will be computed by the Reporter object |
producer | The MooseObject that produces this value |
args | (optional) Any number of optional arguments passed into the Context type given by the S template parameter. If S = ReporterContext then the first argument can be used as the default value (see ReporterContext.h). |
The ReporterContext objects allow for custom handling of data (e.g., broadcasting the value). The get/declare methods can be called in any order thus an the underlying RestartableData object is often created by the get method before it is declared. Therefore the custom functionality cannot be handled by specializing the RestartableData/ReporterState object directly because the state is often created prior to the declaration that dictates how the produced value shall be computed. Thus, the reason for the separate ReporterContext objects.
Definition at line 400 of file ReporterData.h.
Referenced by ReporterTransferInterface::declareClone(), ReporterGeneralContext< T >::declareClone(), VectorPostprocessor::declareVector(), ReporterTransferInterface::declareVectorClone(), and ReporterGeneralContext< T >::declareVectorClone().
void ReporterData::finalize | ( | const std::string & | object_name | ) |
Helper function for performing post calculation actions via the ReporterContext objects.
If you recall, the original VectorPostprocessor system included the ability to perform some scatter and broadcast actions via the special call on the storage helper object. This is a replacement for that method that leverages the ReporterContext objects to perform value specific actions, including some automatic operations depending how the data is produced and consumed.
See FEProblemBase::joinAndFinalize
Definition at line 48 of file ReporterData.C.
Referenced by FEProblemBase::joinAndFinalize().
std::vector< std::string > ReporterData::getAllRealReporterFullNames | ( | ) | const |
Get full names of all real reporter values Note: For a postprocessor, the full name is the postprocessor name plus '/value'.
For a vector postprocessor, the full name is the vector postprocessor name plus the vector name followed by '/#' where '#' is the index of the vector.
Definition at line 106 of file ReporterData.C.
Referenced by FEProblemBase::execute().
DenseVector< Real > ReporterData::getAllRealReporterValues | ( | ) | const |
Get all real reporter values including postprocessor and vector postprocessor values into a dense vector.
Definition at line 81 of file ReporterData.C.
Referenced by FEProblemBase::execute().
std::set< std::string > ReporterData::getPostprocessorNames | ( | ) | const |
Return a list of all postprocessor names.
Definition at line 71 of file ReporterData.C.
Referenced by FEProblemBase::checkDuplicatePostprocessorVariableNames().
const ReporterContextBase & ReporterData::getReporterContextBase | ( | const ReporterName & | reporter_name | ) | const |
reporter_name
. Definition at line 130 of file ReporterData.C.
Referenced by ReporterTransferInterface::clearVectorReporter(), ReporterTransferInterface::declareClone(), AccumulateReporter::declareLateValues(), ReporterTransferInterface::declareVectorClone(), getReporterInfo(), getReporterMode(), VectorPostprocessorInterface::getVectorPostprocessorContextByNameHelper(), hasReporterValue(), JSONOutput::outputReporters(), ReporterTransferInterface::resizeReporter(), ReporterTransferInterface::sumVectorReporter(), ReporterTransferInterface::transferFromVectorReporter(), ReporterTransferInterface::transferReporter(), and ReporterTransferInterface::transferToVectorReporter().
ReporterContextBase & ReporterData::getReporterContextBase | ( | const ReporterName & | reporter_name | ) |
Definition at line 138 of file ReporterData.C.
|
static |
Gets information pertaining to the Reporter with state state
and possibly context context
.
Definition at line 203 of file ReporterData.C.
Referenced by ReporterDebugOutput::output().
std::string ReporterData::getReporterInfo | ( | const ReporterName & | reporter_name | ) | const |
Gets information pertaining to the Reporter with name reporter_name
.
Definition at line 239 of file ReporterData.C.
std::string ReporterData::getReporterInfo | ( | ) | const |
Gets information about all declared/requested Reporters.
Definition at line 247 of file ReporterData.C.
Referenced by check(), getReporterInfo(), getReporterStateHelper(), and ReporterContextBase::requiresConsumerModes().
const ReporterProducerEnum & ReporterData::getReporterMode | ( | const ReporterName & | reporter_name | ) | const |
Return the ReporterProducerEnum for an existing ReporterValue.
reporter_name | The name of the reporter value, which includes the object name and the data name. |
Definition at line 191 of file ReporterData.C.
Referenced by AccumulateReporter::declareAccumulateHelper().
std::set< ReporterName > ReporterData::getReporterNames | ( | ) | const |
Return a list of all reporter names.
Definition at line 62 of file ReporterData.C.
Referenced by getReporterInfo(), AdvancedOutput::initAvailableLists(), XMLOutput::outputVectorPostprocessors(), and TableOutput::outputVectorPostprocessors().
const ReporterStateBase & ReporterData::getReporterStateBase | ( | const ReporterName & | reporter_name | ) | const |
The ReporterStateBase associated with the Reporter with name reporter_name
.
Definition at line 146 of file ReporterData.C.
Referenced by ReporterTransferInterface::addReporterTransferMode(), getReporterInfo(), and hasReporterState().
ReporterStateBase & ReporterData::getReporterStateBase | ( | const ReporterName & | reporter_name | ) |
Definition at line 154 of file ReporterData.C.
|
private |
Helper method for creating the necessary RestartableData for Reporter values.
T | The desired C++ type for the Reporter value |
reporter_name | Object/data name for the Reporter value |
declare | Flag indicating if the ReporterValue is being declared or read. This flag is passed to the existing MooseApp restart/recover system that errors if a value is declared multiple times. |
moose_object | The object requesting/declaring the state, used in error handling. |
Definition at line 330 of file ReporterData.h.
const T & ReporterData::getReporterValue | ( | const ReporterName & | reporter_name, |
const MooseObject & | consumer, | ||
const ReporterMode & | mode, | ||
const std::size_t | time_index = 0 |
||
) | const |
Method for returning read only references to Reporter values.
T | The Reporter value C++ type. |
reporter_name | The name of the reporter value, which includes the object name and the data name. |
consumer | The MooseObject consuming the Reporter value (for error reporting) |
mode | The mode that the value will be consumed by the by the ReporterInterface object |
time_index | (optional) When not provided or zero is provided the current value is returned. If an index greater than zero is provided then the corresponding old data is returned (1 = old, 2 = older, etc.). |
Definition at line 388 of file ReporterData.h.
Referenced by FEProblemBase::getPostprocessorValueByName(), PostprocessorInterface::getPostprocessorValueByNameInternal(), ReporterInterface::getReporterValueByName(), VectorPostprocessorInterface::getVectorPostprocessorByNameHelper(), VectorPostprocessorInterface::getVectorPostprocessorContextByNameHelper(), FEProblemBase::getVectorPostprocessorValueByName(), TableOutput::outputReporter(), Exodus::outputReporters(), XMLOutput::outputVectorPostprocessors(), TableOutput::outputVectorPostprocessors(), and ReporterContext< std::vector< T > >::transferToVector().
const T & ReporterData::getReporterValue | ( | const ReporterName & | reporter_name, |
const std::size_t | time_index = 0 |
||
) | const |
Method for returning a read-only reference to Reporter values that already exist.
T | The Reporter value C++ type. |
reporter_name | The name of the reporter value, which includes the object name and the data name. |
time_index | (optional) When not provided or zero is provided the current value is returned. If an index greater than zero is provided then the corresponding old data is returned (1 = old, 2 = older, etc.). |
Definition at line 463 of file ReporterData.h.
|
private |
Helper for registering data with the MooseApp to avoid cyclic includes.
Definition at line 174 of file ReporterData.C.
Referenced by getReporterStateHelper().
bool ReporterData::hasReporterState | ( | const ReporterName & | reporter_name | ) | const |
reporter_name
and the given type. Definition at line 454 of file ReporterData.h.
Referenced by getReporterStateBase(), and getReporterStateHelper().
bool ReporterData::hasReporterState | ( | const ReporterName & | reporter_name | ) | const |
reporter_name
. Definition at line 197 of file ReporterData.C.
bool ReporterData::hasReporterValue | ( | const ReporterName & | reporter_name | ) | const |
Return True if a Reporter value with the given type and name have been created.
Definition at line 445 of file ReporterData.h.
Referenced by check(), ReporterTransferInterface::checkHasReporterValue(), AccumulateReporter::declareAccumulateHelper(), AccumulateReporter::declareLateValues(), getAllRealReporterFullNames(), getAllRealReporterValues(), getReporterContextBase(), getReporterInfo(), getReporterStateHelper(), PostprocessorInterface::hasPostprocessorByName(), FEProblemBase::hasPostprocessorValueByName(), ReporterInterface::hasReporterValueByName(), VectorPostprocessorInterface::hasVectorPostprocessorByName(), MooseParsedFunctionWrapper::initialize(), ParsedConvergence::initializeSymbols(), JSONOutput::initialSetup(), PostprocessorInterface::isDefaultPostprocessorValueByName(), TableOutput::outputReporter(), Exodus::outputReporters(), XMLOutput::outputVectorPostprocessors(), and TableOutput::outputVectorPostprocessors().
bool ReporterData::hasReporterValue | ( | const ReporterName & | reporter_name | ) | const |
Return True if a Reporter value with any type exists with the given name.
Definition at line 56 of file ReporterData.C.
bool ReporterData::hasReporterWithMode | ( | const std::string & | obj_name, |
const ReporterMode & | mode | ||
) | const |
Return true if the supplied mode exists in the produced Reporter values.
Definition at line 181 of file ReporterData.C.
Referenced by CSV::output(), and JSONOutput::outputReporters().
void ReporterData::needReporterTimeIndex | ( | const ReporterName & | reporter_name, |
const std::size_t | time_index | ||
) |
Method for setting that a specific time index is requested for a Reporter value.
T | The Reporter value C++ type. |
reporter_name | The name of the reporter value, which includes the object name and the data name. |
time_index | The time index that is needed |
Definition at line 492 of file ReporterData.h.
Referenced by Receiver::Receiver().
void ReporterData::restoreState | ( | bool | verbose = false | ) |
When a time step fails, this method is called to revert the current reporter values to their old state.
verbose | Set true to print whether the reporters were restored or not. |
Definition at line 24 of file ReporterData.C.
Referenced by FEProblemBase::restoreSolutions().
void ReporterData::setReporterValue | ( | const ReporterName & | reporter_name, |
const T & | value, | ||
const std::size_t | time_index = 0 |
||
) |
Method for setting Reporter values that already exist.
T | The Reporter value C++ type. |
reporter_name | The name of the reporter value, which includes the object name and the data name. |
value | The value to which the Reporter will be changed to. |
time_index | (optional) When not provided or zero is provided the current value is returned. If an index greater than zero is provided then the corresponding old data is returned (1 = old, 2 = older, etc.). WARNING! This method is designed for setting values outside of the traditional interfaces such as is necessary for Transfers. This is an advanced capability that should be used with caution. |
Definition at line 481 of file ReporterData.h.
Referenced by ConstantPostprocessor::ConstantPostprocessor(), FEProblemBase::setPostprocessorValueByName(), FEProblemBase::setVectorPostprocessorValueByName(), ReporterContext< std::vector< T > >::transfer(), and ReporterContext< std::vector< T > >::transferFromVector().
|
private |
For accessing the restart/recover system, which is where Reporter values are stored.
Definition at line 293 of file ReporterData.h.
Referenced by declareReporterValue(), and getRestartableDataHelper().
|
private |
The ReporterContext objects are created when a value is declared.
The context objects include a reference to the associated ReporterState values. This container stores the context object for each Reporter value.
Definition at line 325 of file ReporterData.h.
Referenced by copyValuesBack(), declareReporterValue(), finalize(), getAllRealReporterFullNames(), getAllRealReporterValues(), getPostprocessorNames(), getReporterContextBase(), getReporterNames(), hasReporterValue(), hasReporterWithMode(), and restoreState().
|
mutableprivate |
Map from ReporterName -> Reporter state.
We need to keep track of all of the states that are created so that we can check them after Reporter declaration to make sure all states have a producer (are delcared). We cannot check _context_ptrs, because a context is only defined for Reporters that have been declared. This is mutable so that it can be inserted into when requesting Reporter values.
Definition at line 320 of file ReporterData.h.
Referenced by check(), declareReporterValue(), getReporterInfo(), getReporterStateBase(), getReporterStateHelper(), and hasReporterState().