Reporter objects allow for the declaration of arbitrary data types that are aggregate values for a simulation.
These aggregate values are then available to other objects for use. They operate with the typical producer/consumer relationship. The Reporter object produces values that other objects consume.
Originally, MOOSE included a Postprocessor system that allowed for an object to produce a single scalar value for consumption by other objects. Then a companion system was created, the VectorPostprocessor system, that allowed for an object to produce many std::vector<Real> values. The Reporter system is the generalization of these two ideas and follows closely the original design of the VectorPostprocessor system.
In practice, the Reporter system provided the following features over the two previous systems.
- It can create arbitrary data types rather than only Real and std::vector<Real>
- It can create many values per object. This was possible for VectorPostprocessor objects but not for Postprocessors. Therefore, this allows a single Reporter to provide multiple values and consolidate similar items. For example, a "counter" object replaced several individual Postprocessor objects.
- The ReporterContext system allows for each data value to have special operation within a single object. Previously the VectorPostprocessor system had capability to perform broadcasting, but it was applied to all vectors in the object.
Definition at line 47 of file Reporter.h.
virtual void Reporter::declareLateValues |
( |
| ) |
|
|
inlinevirtual |
Method that can be overriden to declare "late" Reporter values.
Values are considered "late" when they need to be declared after all other Reporters have been instantiated. This is called by the "declare_late_reporters" task, which should be called right after the "add_reporters" task.
Reimplemented in AccumulateReporter.
Definition at line 71 of file Reporter.h.
template<typename T , typename... Args>
T & Reporter::declareUnusedValue |
( |
Args &&... |
args | ) |
|
|
protected |
Declare a unused value with type T.
This is useful when you have a reporter that has optional values. In this case, you want to create references to all reporter values. However, because some values are optional, you need something to fill into the reference. This helper will create a unused value. It also allows for the passing of arguments in the case that your value is not trivially default constructable (constructable by default without arguments).
Definition at line 270 of file Reporter.h.
272 _unused_values.emplace_back(std::make_unique<UnusedWrapper<T>>(std::forward(args)...));
273 UnusedWrapper<T> * wrapper =
dynamic_cast<UnusedWrapper<T> *
>(
_unused_values.back().get());
274 return wrapper->value;
std::vector< std::unique_ptr< UnusedWrapperBase > > _unused_values
Storage for unused values declared with declareUnusedValue().
template<typename T , typename S , typename... Args>
T & Reporter::declareValue |
( |
const std::string & |
param_name, |
|
|
Args &&... |
args |
|
) |
| |
|
protected |
Method to define a value that the Reporter object is to produced.
- Template Parameters
-
T | The C++ type of the value to be produced |
S | (optional) Context type for performing special operations. For example using the ReporterBroadcastContext will automatically broadcast the produced value from the root processor. |
- Parameters
-
name | A unique name for the value to be produced. |
mode | (optional) The mode that indicates how the value produced is represented in parallel, there is more information about this below |
args | (optional) Any number of optional arguments passed into the ReporterContext given by the S template parameter. If S = ReporterContext then the first argument can be used as the default value (see ReporterContext.h). |
The 'mode' indicates how the value that is produced is represented in parallel. It is the responsibility of the Reporter object to get it to that state. The ReporterContext objects are designed to help with this. The mode can be one of the following:
ReporterMode::ROOT Indicates that the value produced is complete/correct on the
root processor for the object.
ReporterMode::REPLICATED Indicates that the value produced is complete/correct on
all processors AND that the value is the same on all
processors
ReporterMode::DISTRIBUTED Indicates that the value produced is complete/correct on
all processors AND that the value is NOT the same on all
processors
WARNING! Using the "default value" in ReporterContext: The Reporter system, like the systems before it, allow for objects that consume values to be constructed prior to the produce objects. When a value is requested either by a producer (Reporter) or consumer (ReporterInterface) the data is allocated. As such the assigned default value from the producer should not be relied upon on the consumer side during object construction.
NOTE: The ReporterContext is just a mechanism to allow for handling of values in special ways. In practice it might be better to have specific methods for these special cases. For example, a declareBroadcastValue, etc. Please refer to the ReporterData object for more information on how the data system operates for Reporter values.
Definition at line 198 of file Reporter.h.
const ReporterMode REPORTER_MODE_UNSET