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();
61 std::set<ReporterName>
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)
105 std::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);
184 if (name_context_pair.first.getObjectName() == obj_name &&
185 name_context_pair.second->getProducerModeEnum() == mode)
199 return _states.count(reporter_name);
205 std::stringstream oss;
209 if (
name.isPostprocessor())
210 oss <<
"Postprocessor \"" <<
name.getObjectName() <<
"\":\n";
213 oss <<
name.specialTypeToName() <<
" \"" <<
name.getCombinedName() <<
"\":\n Type:\n " 216 oss <<
" Producer:\n ";
220 oss <<
"\n Context type:\n " << context->
contextType();
224 oss <<
"\n Consumer(s):\n";
228 for (
const auto & mode_object_pair : state.
getConsumers())
231 const MooseObject *
object = mode_object_pair.second;
232 oss <<
" " <<
object->
typeAndName() <<
" (mode: " << mode <<
")\n";
249 std::string
out =
_states.empty() ?
"No reporters were requested or declared." :
"";
std::string name(const ElemQuality q)
ReporterData(MooseApp &moose_app)
std::map< ReporterName, std::unique_ptr< ReporterContextBase > > _context_ptrs
The ReporterContext objects are created when a value is declared.
std::map< ReporterName, ReporterStateBase * > _states
Map from ReporterName -> Reporter state.
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...
const ReporterStateBase & getReporterStateBase(const ReporterName &reporter_name) const
The ReporterStateBase associated with the Reporter with name reporter_name.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
MooseEnum designed for the ReporterContext objects to define how a ReporterValue can and is being pro...
A class for "pretty printing" a table of data.
Base class for MOOSE-based applications.
virtual const std::string & name() const
Get the name of the class.
const std::string getCombinedName() const
Return the name of the object and data as object_name/data_name.
RestartableDataValue & getRestartableDataHelper(std::unique_ptr< RestartableDataValue > data_ptr, bool declare) const
Helper for registering data with the MooseApp to avoid cyclic includes.
void mooseInfo(Args &&... args)
Emit an informational message with the given stringified, concatenated args.
const ReporterName & getReporterName() const
Return the ReporterName that this state is associated with.
virtual std::string contextType() const =0
This is a helper class to aid with parallel communication of compute Reporter values as well as provi...
DenseVector< Real > getAllRealReporterValues() const
Get all real reporter values including postprocessor and vector postprocessor values into a dense vec...
const ReporterProducerEnum & getProducerModeEnum() const
Return the Reporter value produced mode.
Every object that can be built by the factory should be derived from this class.
std::vector< std::string > getAllRealReporterFullNames() const
Get full names of all real reporter values Note: For a postprocessor, the full name is the postproces...
RestartableDataValue & registerRestartableData(std::unique_ptr< RestartableDataValue > data, THREAD_ID tid, bool read_only, const RestartableDataMapName &metaname="")
bool hasReporterState(const ReporterName &reporter_name) const
const std::string & type() const
Get the type of this class.
void finalize(const std::string &object_name)
Helper function for performing post calculation actions via the ReporterContext objects.
virtual std::string valueType() const =0
The base class for storing a Reporter's state.
std::string typeAndName() const
Get the class's combined type and name; useful in error handling.
void addRow(Ts... entries)
Add a row of data.
std::set< ReporterName > getReporterNames() const
Return a list of all reporter names.
void copyValuesBack()
At the end of a timestep this method is called to copy the values back in time in preparation for the...
const ReporterProducerEnum & getReporterMode(const ReporterName &reporter_name) const
Return the ReporterProducerEnum for an existing ReporterValue.
MooseApp & _app
For accessing the restart/recover system, which is where Reporter values are stored.
std::string getReporterInfo() const
Gets information about all declared/requested Reporters.
bool hasReporterValue(const ReporterName &reporter_name) const
Return True if a Reporter value with the given type and name have been created.
bool hasReporterWithMode(const std::string &obj_name, const ReporterMode &mode) const
Return true if the supplied mode exists in the produced Reporter values.
void check() const
Perform integrity check for get/declare calls.
std::set< std::string > getPostprocessorNames() const
Return a list of all postprocessor names.
const MooseObject & getProducer() const
Return the MooseObject that produces this Reporter.
MooseEnumItem that automatically creates the ID and doesn't allow the ID to be assigned.
Abstract definition of a RestartableData value.
The Reporter system is comprised of objects that can contain any number of data values.
void restoreState(bool verbose=false)
When a time step fails, this method is called to revert the current reporter values to their old stat...
const ReporterContextBase & getReporterContextBase(const ReporterName &reporter_name) const