13#include "libmesh/parallel.h"
14#include "libmesh/parallel_object.h"
15#include "libmesh/simple_range.h"
56 const std::set<std::pair<ReporterMode, const MooseObject *>> &
getConsumers()
const
84 std::set<std::pair<ReporterMode, const MooseObject *>>
_consumers;
91bool operator<(
const std::pair<ReporterMode, const MooseObject *> & a,
92 const std::pair<ReporterMode, const MooseObject *> & b);
121 T &
value(
const std::size_t time_index = 0);
122 const T &
value(
const std::size_t time_index = 0)
const;
139 std::string
valueType() const override final {
return MooseUtils::prettyCppType<T>(); }
172 if (this->get().empty())
173 this->set().resize(1);
181 if (this->getReporterName().isPostprocessor() && time_index == 0 && this->get().size() <= 1)
182 this->set().push_back(this->get().back());
185 if (this->get().size() <= time_index)
186 this->set().resize(time_index + 1, this->get().back());
188 return *(std::next(this->set().begin(), time_index));
195 if (this->get().size() <= time_index)
198 " does not exists for the '",
200 "' Reporter value, which contains ",
202 " old value(s). The getReporterValue method must be called with the desired time "
203 "index to be able to access data.");
204 return *(std::next(this->get().begin(), time_index));
211 std::list<T> &
values = this->set();
212 for (
typename std::list<T>::reverse_iterator iter =
values.rbegin();
213 std::next(iter) !=
values.rend();
215 (*iter) = (*std::next(iter));
222 if (this->get().size() <= 1)
225 this->set().front() = *std::next(this->get().begin());
234 std::size_t size = this->get().size();
238 for (
auto & val : this->set())
247 std::size_t size = 0;
250 auto &
values = this->set();
259 for (
auto & val : as_range(
values.begin(), std::next(
values.begin(), size)))
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
void dataLoad(std::istream &stream, LineSegment &l, void *context)
void dataStore(std::ostream &stream, LineSegment &l, void *context)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
std::array< Real, 2 > values
bool operator<(const std::pair< ReporterMode, const MooseObject * > &a, const std::pair< ReporterMode, const MooseObject * > &b)
Custom sort for ReporterState::_consumers so that they are sorted by object type, object name,...
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...
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.
void setIsVectorPostprocessor()
Sets the special type to a VectorPostprocessor.
void setIsPostprocessor()
Sets the special type to a Postprocessor.
The base class for storing a Reporter's state.
virtual ~ReporterStateBase()=default
void addConsumer(ReporterMode mode, const MooseObject &moose_object)
Add a consumer for this ReporterState.
void setIsPostprocessor()
Sets the special Reporter type to a Postprocessor.
void setIsVectorPostprocessor()
Sets the special Reporter type to a VectorPostprocessor.
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...
ReporterName _reporter_name
Name of data that state is associated.
std::set< std::pair< ReporterMode, const MooseObject * > > _consumers
The consumers for this state; we store the MooseObject for detailed error reporting.
A special version of RestartableData to aid in storing Reporter values.
bool restoreState()
Restore values to their old values, i.e.
void storeInternal(std::ostream &stream) override final
Loads and stores the data from/to a stream for restart.
std::string valueType() const override final
void copyValuesBack()
Copy stored values back in time to old/older etc.
void loadInternal(std::istream &stream) override final
Load the RestartableData from a binary stream.
T & value(const std::size_t time_index=0)
Return a reference to the current value or one of the old values.
const T & value(const std::size_t time_index=0) const
ReporterState(const ReporterName &name)
const std::string & name() const
The full (unique) name of this particular piece of data.
Concrete definition of a parameter value for a specified type.