www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PostprocessorData Class Reference

#include <PostprocessorData.h>

Inheritance diagram for PostprocessorData:
[legend]

Public Member Functions

 PostprocessorData (FEProblemBase &fe_problem)
 Class constructor. More...
 
void init (const std::string &name)
 Initialization method, sets the current and old value to 0.0 for this postprocessor. More...
 
bool hasPostprocessor (const std::string &name)
 Returns a true value if the Postprocessor exists. More...
 
PostprocessorValuegetPostprocessorValue (const PostprocessorName &name)
 Return the value for the Postprocessor. More...
 
PostprocessorValuegetPostprocessorValueOld (const PostprocessorName &name)
 The the old value of an Postprocessor. More...
 
PostprocessorValuegetPostprocessorValueOlder (const PostprocessorName &name)
 The the older value of an Postprocessor. More...
 
void storeValue (const std::string &name, PostprocessorValue value)
 
const std::map< std::string, PostprocessorValue * > & values () const
 Get the map of names -> Postprocessor values. More...
 
void copyValuesBack ()
 Copy the current Postprocessor values into old (i.e. More...
 

Protected Member Functions

template<typename T >
T & declareRestartableData (std::string data_name)
 Declare a piece of data as "restartable". More...
 
template<typename T >
T & declareRestartableData (std::string data_name, const T &init_value)
 Declare a piece of data as "restartable" and initialize it. More...
 
template<typename T >
T & declareRestartableDataWithContext (std::string data_name, void *context)
 Declare a piece of data as "restartable". More...
 
template<typename T >
T & declareRestartableDataWithContext (std::string data_name, const T &init_value, void *context)
 Declare a piece of data as "restartable" and initialize it. More...
 
template<typename T >
T & declareRecoverableData (std::string data_name)
 Declare a piece of data as "recoverable". More...
 
template<typename T >
T & declareRecoverableData (std::string data_name, const T &init_value)
 Declare a piece of data as "restartable" and initialize it. More...
 
template<typename T >
T & declareRestartableDataWithObjectName (std::string data_name, std::string object_name)
 Declare a piece of data as "restartable". More...
 
template<typename T >
T & declareRestartableDataWithObjectNameWithContext (std::string data_name, std::string object_name, void *context)
 Declare a piece of data as "restartable". More...
 

Protected Attributes

std::map< std::string, PostprocessorValue * > _values
 Values of the Postprocessor at the current time. More...
 
std::map< std::string, PostprocessorValue * > _values_old
 Values of the Postprocessors at the time t-1. More...
 
std::map< std::string, PostprocessorValue * > _values_older
 Values of the Postprocessors at the time t-2. More...
 

Detailed Description

Definition at line 21 of file PostprocessorData.h.

Constructor & Destructor Documentation

◆ PostprocessorData()

PostprocessorData::PostprocessorData ( FEProblemBase fe_problem)

Class constructor.

Definition at line 13 of file PostprocessorData.C.

14  : Restartable(fe_problem.getMooseApp(), "values", "PostprocessorData", 0)
15 {
16 }
Restartable(const MooseObject *moose_object, const std::string &system_name)
Class constructor.
Definition: Restartable.C:17
MooseApp & getMooseApp() const
Get the MooseApp this object is associated with.
Definition: MooseObject.h:86

Member Function Documentation

◆ copyValuesBack()

void PostprocessorData::copyValuesBack ( )

Copy the current Postprocessor values into old (i.e.

shift it "back in time")

Definition at line 81 of file PostprocessorData.C.

Referenced by FEProblemBase::advanceState().

82 {
83  for (const auto & it : _values)
84  {
86  getPostprocessorValueOld(it.first) = getPostprocessorValue(it.first);
87  }
88 }
std::map< std::string, PostprocessorValue * > _values
Values of the Postprocessor at the current time.
PostprocessorValue & getPostprocessorValueOld(const PostprocessorName &name)
The the old value of an Postprocessor.
PostprocessorValue & getPostprocessorValueOlder(const PostprocessorName &name)
The the older value of an Postprocessor.
PostprocessorValue & getPostprocessorValue(const PostprocessorName &name)
Return the value for the Postprocessor.

◆ declareRecoverableData() [1/2]

template<typename T >
T & Restartable::declareRecoverableData ( std::string  data_name)
protectedinherited

Declare a piece of data as "recoverable".

This means that in the event of a recovery this piece of data will be restored back to its previous value.

Note - this data will NOT be restored on Restart!

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)

Definition at line 269 of file Restartable.h.

270 {
271  std::string full_name = _restartable_system_name + "/" + _restartable_name + "/" + data_name;
272 
273  registerRecoverableDataOnApp(full_name);
274 
275  return declareRestartableDataWithContext<T>(data_name, nullptr);
276 }
std::string _restartable_system_name
The system name this object is in.
Definition: Restartable.h:194
std::string _restartable_name
The name of the object.
Definition: Restartable.h:191
void registerRecoverableDataOnApp(std::string name)
Helper function for actually registering the restartable data.
Definition: Restartable.C:54

◆ declareRecoverableData() [2/2]

template<typename T >
T & Restartable::declareRecoverableData ( std::string  data_name,
const T &  init_value 
)
protectedinherited

Declare a piece of data as "restartable" and initialize it.

This means that in the event of a restart this piece of data will be restored back to its previous value.

Note - this data will NOT be restored on Restart!

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)
init_valueThe initial value of the data

Definition at line 280 of file Restartable.h.

281 {
282  std::string full_name = _restartable_system_name + "/" + _restartable_name + "/" + data_name;
283 
284  registerRecoverableDataOnApp(full_name);
285 
286  return declareRestartableDataWithContext<T>(data_name, init_value, nullptr);
287 }
std::string _restartable_system_name
The system name this object is in.
Definition: Restartable.h:194
std::string _restartable_name
The name of the object.
Definition: Restartable.h:191
void registerRecoverableDataOnApp(std::string name)
Helper function for actually registering the restartable data.
Definition: Restartable.C:54

◆ declareRestartableData() [1/2]

template<typename T >
T & Restartable::declareRestartableData ( std::string  data_name)
protectedinherited

Declare a piece of data as "restartable".

This means that in the event of a restart this piece of data will be restored back to its previous value.

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)

Definition at line 202 of file Restartable.h.

203 {
204  return declareRestartableDataWithContext<T>(data_name, nullptr);
205 }

◆ declareRestartableData() [2/2]

template<typename T >
T & Restartable::declareRestartableData ( std::string  data_name,
const T &  init_value 
)
protectedinherited

Declare a piece of data as "restartable" and initialize it.

This means that in the event of a restart this piece of data will be restored back to its previous value.

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)
init_valueThe initial value of the data

Definition at line 209 of file Restartable.h.

210 {
211  return declareRestartableDataWithContext<T>(data_name, init_value, nullptr);
212 }

◆ declareRestartableDataWithContext() [1/2]

template<typename T >
T & Restartable::declareRestartableDataWithContext ( std::string  data_name,
void *  context 
)
protectedinherited

Declare a piece of data as "restartable".

This means that in the event of a restart this piece of data will be restored back to its previous value.

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)
contextContext pointer that will be passed to the load and store functions

Definition at line 216 of file Restartable.h.

217 {
218  std::string full_name = _restartable_system_name + "/" + _restartable_name + "/" + data_name;
219  auto data_ptr = libmesh_make_unique<RestartableData<T>>(full_name, context);
220  T & restartable_data_ref = data_ptr->get();
221 
222  registerRestartableDataOnApp(full_name, std::move(data_ptr), _restartable_tid);
223 
224  return restartable_data_ref;
225 }
std::string _restartable_system_name
The system name this object is in.
Definition: Restartable.h:194
std::string _restartable_name
The name of the object.
Definition: Restartable.h:191
THREAD_ID _restartable_tid
The thread ID for this object.
Definition: Restartable.h:197
void registerRestartableDataOnApp(std::string name, std::unique_ptr< RestartableDataValue > data, THREAD_ID tid)
Helper function for actually registering the restartable data.
Definition: Restartable.C:46

◆ declareRestartableDataWithContext() [2/2]

template<typename T >
T & Restartable::declareRestartableDataWithContext ( std::string  data_name,
const T &  init_value,
void *  context 
)
protectedinherited

Declare a piece of data as "restartable" and initialize it.

This means that in the event of a restart this piece of data will be restored back to its previous value.

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)
init_valueThe initial value of the data
contextContext pointer that will be passed to the load and store functions

Definition at line 229 of file Restartable.h.

232 {
233  std::string full_name = _restartable_system_name + "/" + _restartable_name + "/" + data_name;
234  auto data_ptr = libmesh_make_unique<RestartableData<T>>(full_name, context);
235  data_ptr->set() = init_value;
236 
237  T & restartable_data_ref = data_ptr->get();
238  registerRestartableDataOnApp(full_name, std::move(data_ptr), _restartable_tid);
239 
240  return restartable_data_ref;
241 }
std::string _restartable_system_name
The system name this object is in.
Definition: Restartable.h:194
std::string _restartable_name
The name of the object.
Definition: Restartable.h:191
THREAD_ID _restartable_tid
The thread ID for this object.
Definition: Restartable.h:197
void registerRestartableDataOnApp(std::string name, std::unique_ptr< RestartableDataValue > data, THREAD_ID tid)
Helper function for actually registering the restartable data.
Definition: Restartable.C:46

◆ declareRestartableDataWithObjectName()

template<typename T >
T & Restartable::declareRestartableDataWithObjectName ( std::string  data_name,
std::string  object_name 
)
protectedinherited

Declare a piece of data as "restartable".

This means that in the event of a restart this piece of data will be restored back to its previous value.

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)
object_nameA supplied name for the object that is declaring this data.

Definition at line 245 of file Restartable.h.

246 {
247  return declareRestartableDataWithObjectNameWithContext<T>(data_name, object_name, nullptr);
248 }

◆ declareRestartableDataWithObjectNameWithContext()

template<typename T >
T & Restartable::declareRestartableDataWithObjectNameWithContext ( std::string  data_name,
std::string  object_name,
void *  context 
)
protectedinherited

Declare a piece of data as "restartable".

This means that in the event of a restart this piece of data will be restored back to its previous value.

NOTE: This returns a reference! Make sure you store it in a reference!

Parameters
data_nameThe name of the data (usually just use the same name as the member variable)
object_nameA supplied name for the object that is declaring this data.
contextContext pointer that will be passed to the load and store functions

Definition at line 252 of file Restartable.h.

255 {
256  std::string old_name = _restartable_name;
257 
258  _restartable_name = object_name;
259 
260  T & value = declareRestartableDataWithContext<T>(data_name, context);
261 
262  _restartable_name = old_name;
263 
264  return value;
265 }
std::string _restartable_name
The name of the object.
Definition: Restartable.h:191

◆ getPostprocessorValue()

PostprocessorValue & PostprocessorData::getPostprocessorValue ( const PostprocessorName &  name)

Return the value for the Postprocessor.

Definition at line 25 of file PostprocessorData.C.

Referenced by copyValuesBack(), FEProblemBase::getPostprocessorValue(), init(), and storeValue().

26 {
27  auto insert_pair = _values.emplace(name, nullptr);
28  auto inserted = insert_pair.second;
29  auto iterator = insert_pair.first;
30 
31  PostprocessorValue *& pp_val = iterator->second;
32  if (inserted)
33  pp_val = &declareRestartableDataWithObjectName<PostprocessorValue>(name, "values");
34 
35  return *pp_val;
36 }
std::map< std::string, PostprocessorValue * > _values
Values of the Postprocessor at the current time.
Real PostprocessorValue
MOOSE typedefs.
Definition: MooseTypes.h:105

◆ getPostprocessorValueOld()

PostprocessorValue & PostprocessorData::getPostprocessorValueOld ( const PostprocessorName &  name)

The the old value of an Postprocessor.

Parameters
nameThe name of the Postprocessor
Returns
The reference to the old value

Definition at line 39 of file PostprocessorData.C.

Referenced by copyValuesBack(), FEProblemBase::getPostprocessorValueOld(), and init().

40 {
41  auto insert_pair = _values_old.emplace(name, nullptr);
42  auto inserted = insert_pair.second;
43  auto iterator = insert_pair.first;
44 
45  PostprocessorValue *& pp_val = iterator->second;
46  if (inserted)
47  pp_val = &declareRestartableDataWithObjectName<PostprocessorValue>(name, "values_old");
48 
49  return *pp_val;
50 }
Real PostprocessorValue
MOOSE typedefs.
Definition: MooseTypes.h:105
std::map< std::string, PostprocessorValue * > _values_old
Values of the Postprocessors at the time t-1.

◆ getPostprocessorValueOlder()

PostprocessorValue & PostprocessorData::getPostprocessorValueOlder ( const PostprocessorName &  name)

The the older value of an Postprocessor.

Parameters
nameThe name of the Postprocessor
Returns
The reference to the older value

Definition at line 53 of file PostprocessorData.C.

Referenced by copyValuesBack(), FEProblemBase::getPostprocessorValueOlder(), and init().

54 {
55  auto insert_pair = _values_older.emplace(name, nullptr);
56  auto inserted = insert_pair.second;
57  auto iterator = insert_pair.first;
58 
59  PostprocessorValue *& pp_val = iterator->second;
60  if (inserted)
61  pp_val = &declareRestartableDataWithObjectName<PostprocessorValue>(name, "values_older");
62 
63  return *pp_val;
64 }
std::map< std::string, PostprocessorValue * > _values_older
Values of the Postprocessors at the time t-2.
Real PostprocessorValue
MOOSE typedefs.
Definition: MooseTypes.h:105

◆ hasPostprocessor()

bool PostprocessorData::hasPostprocessor ( const std::string &  name)

Returns a true value if the Postprocessor exists.

Definition at line 19 of file PostprocessorData.C.

Referenced by FEProblemBase::hasPostprocessor().

20 {
21  return (_values.find(name) != _values.end());
22 }
std::map< std::string, PostprocessorValue * > _values
Values of the Postprocessor at the current time.

◆ init()

void PostprocessorData::init ( const std::string &  name)

Initialization method, sets the current and old value to 0.0 for this postprocessor.

Definition at line 67 of file PostprocessorData.C.

Referenced by FEProblemBase::initPostprocessorData().

68 {
69  getPostprocessorValue(name) = 0.0;
70  getPostprocessorValueOld(name) = 0.0;
71  getPostprocessorValueOlder(name) = 0.0;
72 }
PostprocessorValue & getPostprocessorValueOld(const PostprocessorName &name)
The the old value of an Postprocessor.
PostprocessorValue & getPostprocessorValueOlder(const PostprocessorName &name)
The the older value of an Postprocessor.
PostprocessorValue & getPostprocessorValue(const PostprocessorName &name)
Return the value for the Postprocessor.

◆ storeValue()

void PostprocessorData::storeValue ( const std::string &  name,
PostprocessorValue  value 
)

Definition at line 75 of file PostprocessorData.C.

Referenced by FEProblemBase::joinAndFinalize().

76 {
77  getPostprocessorValue(name) = value;
78 }
PostprocessorValue & getPostprocessorValue(const PostprocessorName &name)
Return the value for the Postprocessor.

◆ values()

const std::map<std::string, PostprocessorValue *>& PostprocessorData::values ( ) const
inline

Get the map of names -> Postprocessor values.

Exposed for error checking.

Definition at line 63 of file PostprocessorData.h.

Referenced by FEProblemBase::checkUserObjects().

63 { return _values; }
std::map< std::string, PostprocessorValue * > _values
Values of the Postprocessor at the current time.

Member Data Documentation

◆ _values

std::map<std::string, PostprocessorValue *> PostprocessorData::_values
protected

Values of the Postprocessor at the current time.

Definition at line 72 of file PostprocessorData.h.

Referenced by copyValuesBack(), getPostprocessorValue(), hasPostprocessor(), and values().

◆ _values_old

std::map<std::string, PostprocessorValue *> PostprocessorData::_values_old
protected

Values of the Postprocessors at the time t-1.

Definition at line 75 of file PostprocessorData.h.

Referenced by getPostprocessorValueOld().

◆ _values_older

std::map<std::string, PostprocessorValue *> PostprocessorData::_values_older
protected

Values of the Postprocessors at the time t-2.

Definition at line 78 of file PostprocessorData.h.

Referenced by getPostprocessorValueOlder().


The documentation for this class was generated from the following files: