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 64 virtual std::string
valueType()
const = 0;
84 std::set<std::pair<ReporterMode, const MooseObject *>>
_consumers;
91 bool operator<(const std::pair<ReporterMode, const MooseObject *> & a,
92 const std::pair<ReporterMode, const MooseObject *> & b);
109 template <
typename T>
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>(); }
157 void loadInternal(std::istream & stream)
override final;
161 template <
typename T>
167 template <
typename 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));
191 template <
typename T>
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));
207 template <
typename T>
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));
218 template <
typename T>
222 if (this->
get().size() <= 1)
225 this->
set().front() = *std::next(this->
get().begin());
229 template <
typename T>
234 std::size_t size = this->
get().size();
238 for (
auto & val : this->
set())
242 template <
typename T>
247 std::size_t size = 0;
250 auto & values = this->
set();
253 if (values.size() < size)
259 for (
auto & val :
as_range(values.begin(), std::next(values.begin(), size)))
std::string name(const ElemQuality q)
A special version of RestartableData to aid in storing Reporter values.
std::string valueType() const override final
ReporterStateBase(const ReporterName &name)
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...
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
ReporterState(const ReporterName &name)
void dataLoad(std::istream &stream, PenetrationInfo *&pinfo, void *context)
void addConsumer(ReporterMode mode, const MooseObject &moose_object)
Add a consumer for this ReporterState.
void storeInternal(std::ostream &stream) override final
Loads and stores the data from/to a stream for restart.
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
void setIsVectorPostprocessor()
Sets the special Reporter type to a VectorPostprocessor.
const ReporterName & getReporterName() const
Return the ReporterName that this state is associated with.
This is a helper class to aid with parallel communication of compute Reporter values as well as provi...
void setIsPostprocessor()
Sets the special Reporter type to a Postprocessor.
std::set< std::pair< ReporterMode, const MooseObject * > > _consumers
The consumers for this state; we store the MooseObject for detailed error reporting.
Every object that can be built by the factory should be derived from this class.
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
void loadInternal(std::istream &stream) override final
Load the RestartableData from a binary stream.
virtual std::string valueType() const =0
The base class for storing a Reporter's state.
void setIsPostprocessor()
Sets the special type to a Postprocessor.
ReporterName _reporter_name
Name of data that state is associated.
void setIsVectorPostprocessor()
Sets the special type to a VectorPostprocessor.
Concrete definition of a parameter value for a specified type.
bool restoreState()
Restore values to their old values, i.e.
void copyValuesBack()
Copy stored values back in time to old/older etc.
T & value(const std::size_t time_index=0)
Return a reference to the current value or one of the old values.
void dataStore(std::ostream &stream, PenetrationInfo *&pinfo, void *context)
virtual ~ReporterStateBase()=default
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
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 & name() const
The full (unique) name of this particular piece of data.