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

#include <VectorPostprocessorData.h>

Inheritance diagram for VectorPostprocessorData:
[legend]

Classes

struct  VectorPostprocessorState
 

Public Member Functions

 VectorPostprocessorData (FEProblemBase &fe_problem)
 Class constructor. More...
 
VectorPostprocessorValuedeclareVector (const std::string &vpp_name, const std::string &vector_name)
 Initialization method, sets the current and old value to 0.0 for this VectorPostprocessor. More...
 
bool hasVectorPostprocessor (const std::string &name)
 Returns a true value if the VectorPostprocessor exists. More...
 
VectorPostprocessorValuegetVectorPostprocessorValue (const VectorPostprocessorName &vpp_name, const std::string &vector_name)
 Return the value for the post processor. More...
 
VectorPostprocessorValuegetVectorPostprocessorValueOld (const VectorPostprocessorName &vpp_name, const std::string &vector_name)
 The the old value of an post-processor. More...
 
bool hasVectors (const std::string &vpp_name) const
 Check to see if a VPP has any vectors at all. More...
 
const std::vector< std::pair< std::string, VectorPostprocessorState > > & vectors (const std::string &vpp_name) const
 Get the map of vectors for a particular VectorPostprocessor. More...
 
void copyValuesBack ()
 Copy the current post-processor 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...
 

Private Member Functions

VectorPostprocessorValuegetVectorPostprocessorHelper (const VectorPostprocessorName &vpp_name, const std::string &vector_name, bool get_current)
 

Private Attributes

std::map< std::string, std::vector< std::pair< std::string, VectorPostprocessorState > > > _values
 Values of the vector post-processor. More...
 
std::set< std::string > _requested_items
 
std::set< std::string > _supplied_items
 

Detailed Description

Definition at line 26 of file VectorPostprocessorData.h.

Constructor & Destructor Documentation

VectorPostprocessorData::VectorPostprocessorData ( FEProblemBase fe_problem)

Class constructor.

Definition at line 18 of file VectorPostprocessorData.C.

19  : Restartable("values", "VectorPostprocessorData", fe_problem, 0)
20 {
21 }
Restartable(const InputParameters &parameters, std::string system_name, SubProblem *subproblem=NULL)
Class constructor Populates the SubProblem and MooseMesh pointers.
Definition: Restartable.C:20

Member Function Documentation

void VectorPostprocessorData::copyValuesBack ( )

Copy the current post-processor values into old (i.e.

shift it "back in time")

Definition at line 107 of file VectorPostprocessorData.C.

108 {
109  for (const auto & it : _values)
110  for (const auto & vec_it : it.second)
111  vec_it.second.old->swap(*vec_it.second.current);
112 }
std::map< std::string, std::vector< std::pair< std::string, VectorPostprocessorState > > > _values
Values of the vector post-processor.
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 224 of file Restartable.h.

225 {
226  return declareRestartableDataWithContext<T>(data_name, NULL);
227 }
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 231 of file Restartable.h.

232 {
233  return declareRestartableDataWithContext<T>(data_name, init_value, NULL);
234 }
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 238 of file Restartable.h.

239 {
241  mooseError("No valid SubProblem found for ", _restartable_system_name, "/", _restartable_name);
242 
243  std::string full_name = _restartable_system_name + "/" + _restartable_name + "/" + data_name;
244  RestartableData<T> * data_ptr = new RestartableData<T>(full_name, context);
245 
247 
248  return data_ptr->get();
249 }
std::string _restartable_system_name
The system name this object is in.
Definition: Restartable.h:202
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
std::string _restartable_name
The name of the object.
Definition: Restartable.h:196
void registerRestartableDataOnSubProblem(std::string name, RestartableDataValue *data, THREAD_ID tid)
Helper function so we don&#39;t have to include SubProblem in the header.
Definition: Restartable.C:49
Concrete definition of a parameter value for a specified type.
SubProblem * _restartable_subproblem
Pointer to the SubProblem class.
Definition: Restartable.h:208
THREAD_ID _restartable_tid
The thread ID for this object.
Definition: Restartable.h:205
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 253 of file Restartable.h.

256 {
258  mooseError("No valid SubProblem found for ", _restartable_system_name, "/", _restartable_name);
259 
260  std::string full_name = _restartable_system_name + "/" + _restartable_name + "/" + data_name;
261  RestartableData<T> * data_ptr = new RestartableData<T>(full_name, context);
262 
263  data_ptr->set() = init_value;
264 
266 
267  return data_ptr->get();
268 }
std::string _restartable_system_name
The system name this object is in.
Definition: Restartable.h:202
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
std::string _restartable_name
The name of the object.
Definition: Restartable.h:196
void registerRestartableDataOnSubProblem(std::string name, RestartableDataValue *data, THREAD_ID tid)
Helper function so we don&#39;t have to include SubProblem in the header.
Definition: Restartable.C:49
Concrete definition of a parameter value for a specified type.
SubProblem * _restartable_subproblem
Pointer to the SubProblem class.
Definition: Restartable.h:208
THREAD_ID _restartable_tid
The thread ID for this object.
Definition: Restartable.h:205
VectorPostprocessorValue & VectorPostprocessorData::declareVector ( const std::string &  vpp_name,
const std::string &  vector_name 
)

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

Parameters
vpp_nameThe name of the VectorPostprocessor
vector_nameThe name of the vector

Definition at line 48 of file VectorPostprocessorData.C.

Referenced by FEProblemBase::declareVectorPostprocessorVector().

50 {
51  _supplied_items.emplace(vpp_name + "::" + vector_name);
52 
53  return getVectorPostprocessorHelper(vpp_name, vector_name, true);
54 }
VectorPostprocessorValue & getVectorPostprocessorHelper(const VectorPostprocessorName &vpp_name, const std::string &vector_name, bool get_current)
std::set< std::string > _supplied_items
VectorPostprocessorValue & VectorPostprocessorData::getVectorPostprocessorHelper ( const VectorPostprocessorName &  vpp_name,
const std::string &  vector_name,
bool  get_current 
)
private

Definition at line 57 of file VectorPostprocessorData.C.

Referenced by declareVector(), getVectorPostprocessorValue(), and getVectorPostprocessorValueOld().

60 {
61  // Intentional use of RHS brackets on a std::map to do a retrieve or insert
62  auto & vec_storage = _values[vpp_name];
63 
64  // lambda for doing compairison on name (i.e., first item in pair)
65  auto comp = [&vector_name](std::pair<std::string, VectorPostprocessorState> & pair) {
66  return pair.first == vector_name;
67  };
68 
69  // Search for the vector, if it is not located create the entry in the storage
70  auto iter = std::find_if(vec_storage.rbegin(), vec_storage.rend(), comp);
71  if (iter == vec_storage.rend())
72  {
73  vec_storage.emplace_back(
74  std::pair<std::string, VectorPostprocessorState>(vector_name, VectorPostprocessorState()));
75  iter = vec_storage.rbegin();
76  }
77 
78  auto & vec_struct = iter->second;
79  if (!vec_struct.current)
80  {
81  mooseAssert(!vec_struct.old, "Uninitialized pointers in VectorPostprocessor Data");
82  vec_struct.current = &declareRestartableDataWithObjectName<VectorPostprocessorValue>(
83  vpp_name + "_" + vector_name, "values");
84  vec_struct.old = &declareRestartableDataWithObjectName<VectorPostprocessorValue>(
85  vpp_name + "_" + vector_name, "values_old");
86  }
87 
88  return get_current ? *vec_struct.current : *vec_struct.old;
89 }
std::map< std::string, std::vector< std::pair< std::string, VectorPostprocessorState > > > _values
Values of the vector post-processor.
VectorPostprocessorValue & VectorPostprocessorData::getVectorPostprocessorValue ( const VectorPostprocessorName &  vpp_name,
const std::string &  vector_name 
)

Return the value for the post processor.

Parameters
vpp_nameThe name of the VectorPostprocessor
vector_nameThe name of the vector
Returns
The reference to the current value

Definition at line 30 of file VectorPostprocessorData.C.

Referenced by FEProblemBase::getVectorPostprocessorValue().

32 {
33  _requested_items.emplace(vpp_name + "::" + vector_name);
34 
35  return getVectorPostprocessorHelper(vpp_name, vector_name, true);
36 }
std::set< std::string > _requested_items
VectorPostprocessorValue & getVectorPostprocessorHelper(const VectorPostprocessorName &vpp_name, const std::string &vector_name, bool get_current)
VectorPostprocessorValue & VectorPostprocessorData::getVectorPostprocessorValueOld ( const VectorPostprocessorName &  vpp_name,
const std::string &  vector_name 
)

The the old value of an post-processor.

Parameters
vpp_nameThe name of the VectorPostprocessor
vector_nameThe name of the vector
Returns
The reference to the old value

Definition at line 39 of file VectorPostprocessorData.C.

Referenced by FEProblemBase::getVectorPostprocessorValueOld().

41 {
42  _requested_items.emplace(vpp_name + "::" + vector_name);
43 
44  return getVectorPostprocessorHelper(vpp_name, vector_name, false);
45 }
std::set< std::string > _requested_items
VectorPostprocessorValue & getVectorPostprocessorHelper(const VectorPostprocessorName &vpp_name, const std::string &vector_name, bool get_current)
bool VectorPostprocessorData::hasVectorPostprocessor ( const std::string &  name)

Returns a true value if the VectorPostprocessor exists.

Definition at line 24 of file VectorPostprocessorData.C.

Referenced by FEProblemBase::hasVectorPostprocessor().

25 {
26  return (_values.find(name) != _values.end());
27 }
std::map< std::string, std::vector< std::pair< std::string, VectorPostprocessorState > > > _values
Values of the vector post-processor.
bool VectorPostprocessorData::hasVectors ( const std::string &  vpp_name) const

Check to see if a VPP has any vectors at all.

Definition at line 92 of file VectorPostprocessorData.C.

93 {
94  return _values.find(vpp_name) != _values.end();
95 }
std::map< std::string, std::vector< std::pair< std::string, VectorPostprocessorState > > > _values
Values of the vector post-processor.
const std::vector< std::pair< std::string, VectorPostprocessorData::VectorPostprocessorState > > & VectorPostprocessorData::vectors ( const std::string &  vpp_name) const

Get the map of vectors for a particular VectorPostprocessor.

Parameters
vpp_nameThe name of the VectorPostprocessor

Definition at line 98 of file VectorPostprocessorData.C.

Referenced by FEProblemBase::getVectorPostprocessorVectors().

99 {
100  auto vec_pair = _values.find(vpp_name);
101  mooseAssert(vec_pair != _values.end(), "No vectors found for vpp_name: " << vpp_name);
102 
103  return vec_pair->second;
104 }
std::map< std::string, std::vector< std::pair< std::string, VectorPostprocessorState > > > _values
Values of the vector post-processor.

Member Data Documentation

std::set<std::string> VectorPostprocessorData::_requested_items
private
std::set<std::string> VectorPostprocessorData::_supplied_items
private

Definition at line 100 of file VectorPostprocessorData.h.

Referenced by declareVector().

std::map<std::string, std::vector<std::pair<std::string, VectorPostprocessorState> > > VectorPostprocessorData::_values
private

Values of the vector post-processor.

Definition at line 97 of file VectorPostprocessorData.h.

Referenced by copyValuesBack(), getVectorPostprocessorHelper(), hasVectorPostprocessor(), hasVectors(), and vectors().


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