20 name_context_pair.second->copyValuesBack();
31 const bool restored = context->restoreState();
35 rname.getCombinedName(), rname.specialTypeToName(), restored ?
"YES" :
"NO");
40 std::stringstream oss;
41 oss <<
"Reporter Restoration Summary:\n";
42 summary_table.print(oss);
51 if (name_context_pair.first.getObjectName() == object_name)
52 name_context_pair.second->finalize();
64 std::set<ReporterName> output;
66 output.insert(name_context_pair.second->name());
73 std::set<std::string> output;
75 if (name_context_pair.first.isPostprocessor())
76 output.insert(name_context_pair.first.getObjectName());
83 DenseVector<Real> all_values;
85 std::vector<Real> & output = all_values.get_values();
91 if (hasReporterValue<Real>(rname))
96 const auto & vec = getReporterValue<std::vector<Real>>(rname.
getCombinedName());
97 for (
const auto & v : vec)
105std::vector<std::string>
108 std::vector<std::string> output;
114 if (hasReporterValue<Real>(rname))
120 const auto & vec = getReporterValue<std::vector<Real>>(pname);
121 for (
unsigned int i = 0; i < vec.size(); ++i)
122 output.push_back(pname +
"/" + std::to_string(i));
133 mooseError(
"Unable to locate Reporter context with name: ", reporter_name);
141 mooseError(
"Unable to locate Reporter context with name: ", reporter_name);
149 mooseError(
"Unable to locate Reporter state with name: ", reporter_name);
150 return *
_states.at(reporter_name);
157 mooseError(
"Unable to locate Reporter state with name: ", reporter_name);
158 return *
_states.at(reporter_name);
165 for (
const auto & name_state_pair :
_states)
170 mooseError(
"The following Reporter(s) were not declared:\n\n", missing);
190 if (name_context_pair.first.getObjectName() == obj_name &&
191 name_context_pair.second->getProducerModeEnum() == mode)
205 return _states.count(reporter_name);
211 std::stringstream oss;
215 if (name.isPostprocessor())
216 oss <<
"Postprocessor \"" << name.getObjectName() <<
"\":\n";
219 oss << name.specialTypeToName() <<
" \"" << name.getCombinedName() <<
"\":\n Type:\n "
222 oss <<
" Producer:\n ";
226 oss <<
"\n Context type:\n " << context->
contextType();
230 oss <<
"\n Consumer(s):\n";
234 for (
const auto & mode_object_pair : state.
getConsumers())
237 const MooseObject *
object = mode_object_pair.second;
238 oss <<
" " <<
object->
typeAndName() <<
" (mode: " << mode <<
")\n";
255 std::string out =
_states.empty() ?
"No reporters were requested or declared." :
"";
void mooseInfo(Args &&... args)
Emit an informational message with the given stringified, concatenated args.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Base class for MOOSE-based applications.
bool restoreDataIfAvailable(RestartableDataValue &value, const THREAD_ID tid, Moose::PassKey< ReporterData >)
Restores value in place from the checkpoint reader if it is present in the checkpoint and has not yet...
RestartableDataValue & registerRestartableData(std::unique_ptr< RestartableDataValue > data, THREAD_ID tid, bool read_only, const RestartableDataMapName &metaname="")
const std::string & type() const
Get the type of this class.
std::string typeAndName() const
Get the class's combined type and name; useful in error handling.
const std::string & name() const
Get the name of the class.
Every object that can be built by the factory should be derived from this class.
This is a helper class to aid with parallel communication of compute Reporter values as well as provi...
const MooseObject & getProducer() const
Return the MooseObject that produces this Reporter.
virtual std::string contextType() const =0
const ReporterProducerEnum & getProducerModeEnum() const
Return the Reporter value produced mode.
std::set< ReporterName > getReporterNames() const
Return a list of all reporter names.
bool hasReporterState(const ReporterName &reporter_name) const
std::vector< std::string > getAllRealReporterFullNames() const
Get full names of all real reporter values Note: For a postprocessor, the full name is the postproces...
const ReporterStateBase & getReporterStateBase(const ReporterName &reporter_name) const
@Returns The ReporterStateBase associated with the Reporter with name reporter_name.
ReporterData(MooseApp &moose_app)
MooseApp & _app
For accessing the restart/recover system, which is where Reporter values are stored.
DenseVector< Real > getAllRealReporterValues() const
Get all real reporter values including postprocessor and vector postprocessor values into a dense vec...
void check() const
Perform integrity check for get/declare calls.
void copyValuesBack()
At the end of a timestep this method is called to copy the values back in time in preparation for the...
const ReporterContextBase & getReporterContextBase(const ReporterName &reporter_name) const
bool hasReporterValue(const ReporterName &reporter_name) const
Return True if a Reporter value with the given type and name have been created.
std::map< ReporterName, std::unique_ptr< ReporterContextBase > > _context_ptrs
The ReporterContext objects are created when a value is declared.
void restoreState(bool verbose=false)
When a time step fails, this method is called to revert the current reporter values to their old stat...
std::map< ReporterName, ReporterStateBase * > _states
Map from ReporterName -> Reporter state.
std::string getReporterInfo() const
Gets information about all declared/requested Reporters.
void restoreReporterStateIfAvailable(RestartableDataValue &state) const
Helper for restoring state from the checkpoint reader if available.
RestartableDataValue & getRestartableDataHelper(std::unique_ptr< RestartableDataValue > data_ptr, bool declare) const
Helper for registering data with the MooseApp to avoid cyclic includes.
bool hasReporterWithMode(const std::string &obj_name, const ReporterMode &mode) const
Return true if the supplied mode exists in the produced Reporter values.
std::set< std::string > getPostprocessorNames() const
Return a list of all postprocessor names.
const ReporterProducerEnum & getReporterMode(const ReporterName &reporter_name) const
Return the ReporterProducerEnum for an existing ReporterValue.
void finalize(const std::string &object_name)
Helper function for performing post calculation actions via the ReporterContext objects.
MooseEnumItem that automatically creates the ID and doesn't allow the ID to be assigned.
The Reporter system is comprised of objects that can contain any number of data values.
const std::string getCombinedName() const
Return the name of the object and data as object_name/data_name.
MooseEnum designed for the ReporterContext objects to define how a ReporterValue can and is being pro...
The base class for storing a Reporter's state.
const ReporterName & getReporterName() const
Return the ReporterName that this state is associated with.
virtual std::string valueType() const =0
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 consum...
Abstract definition of a RestartableData value.
A class for "pretty printing" a table of data.
void addRow(Ts... entries)
Add a row of data.