https://mooseframework.inl.gov
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
ChainControlData< T > Class Template Reference

Concrete definition of a parameter value for a specified type. More...

#include <ChainControlData.h>

Inheritance diagram for ChainControlData< T >:
[legend]

Public Member Functions

 ChainControlData (MooseApp &moose_app, std::string name)
 Constructor. More...
 
const T & get () const
 
const T & getOld () const
 
T & set ()
 
virtual std::string type () override
 String identifying the type of parameter stored. More...
 
virtual void copyValuesBack () override
 Copy the current value into the old value. More...
 
const std::string & name () const
 The full (unique) name of this particular piece of data. More...
 
const ChainControlgetChainControl () const
 Get the pointer to the control object that declared this control data. More...
 
void setChainControl (ChainControl &ctrl)
 Set the pointer to the control object that declared this control data. More...
 
void setDeclared ()
 Mark the data as declared. More...
 
bool getDeclared ()
 Get the declared state. More...
 

Protected Member Functions

template<typename T , typename... Args>
T & declareRestartableData (const std::string &data_name, Args &&... args)
 Declare a piece of data as "restartable" and initialize it. More...
 
template<typename T , typename... Args>
ManagedValue< T > declareManagedRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 Declares a piece of "managed" restartable data and initialize it. More...
 
template<typename T , typename... Args>
const T & getRestartableData (const std::string &data_name) const
 Declare a piece of data as "restartable" and initialize it Similar to declareRestartableData but returns a const reference to the object. More...
 
template<typename T , typename... Args>
T & declareRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 Declare a piece of data as "restartable" and initialize it. More...
 
template<typename T , typename... Args>
T & declareRecoverableData (const std::string &data_name, Args &&... args)
 Declare a piece of data as "recoverable" and initialize it. More...
 
template<typename T , typename... Args>
T & declareRestartableDataWithObjectName (const std::string &data_name, const std::string &object_name, Args &&... args)
 Declare a piece of data as "restartable". More...
 
template<typename T , typename... Args>
T & declareRestartableDataWithObjectNameWithContext (const std::string &data_name, const std::string &object_name, void *context, Args &&... args)
 Declare a piece of data as "restartable". More...
 
std::string restartableName (const std::string &data_name) const
 Gets the name of a piece of restartable data given a data name, adding the system name and object name prefix. More...
 

Protected Attributes

const std::string _name
 The full (unique) name of this particular piece of data. More...
 
bool _declared
 true if the data was declared by calling declareControlData. All data must be declared up front. More...
 
ChainControl_chain_control
 The control object that declared this control data. More...
 
MooseApp_restartable_app
 Reference to the application. More...
 
const std::string _restartable_system_name
 The system name this object is in. More...
 
const THREAD_ID _restartable_tid
 The thread ID for this object. More...
 
const bool _restartable_read_only
 Flag for toggling read only status (see ReporterData) More...
 

Private Attributes

T & _value
 Current value. More...
 
T & _value_old
 Old value. More...
 

Detailed Description

template<typename T>
class ChainControlData< T >

Concrete definition of a parameter value for a specified type.

Definition at line 88 of file ChainControlData.h.

Constructor & Destructor Documentation

◆ ChainControlData()

template<typename T>
ChainControlData< T >::ChainControlData ( MooseApp moose_app,
std::string  name 
)
inline

Constructor.

Parameters
nameThe full (unique) name for this piece of data.

Definition at line 95 of file ChainControlData.h.

96  : ChainControlDataBase(moose_app, name),
97  _value(declareRestartableData<T>(name)),
98  _value_old(declareRestartableData<T>(name + "_old"))
99  {
100  }
ChainControlDataBase(MooseApp &moose_app, const std::string &name)
Constructor.
T & _value
Current value.
T & _value_old
Old value.
const std::string & name() const
The full (unique) name of this particular piece of data.

Member Function Documentation

◆ copyValuesBack()

template<typename T >
void ChainControlData< T >::copyValuesBack ( )
inlineoverridevirtual

Copy the current value into the old value.

Implements ChainControlDataBase.

Definition at line 140 of file ChainControlData.h.

141 {
142  _value_old = _value;
143 }
T & _value
Current value.
T & _value_old
Old value.

◆ declareManagedRestartableDataWithContext()

template<typename T , typename... Args>
Restartable::ManagedValue< T > Restartable::declareManagedRestartableDataWithContext ( const std::string &  data_name,
void context,
Args &&...  args 
)
protectedinherited

Declares a piece of "managed" restartable data and initialize it.

Here, "managed" restartable data means that the caller can destruct this data upon destruction of the return value of this method. Therefore, this ManagedValue<T> wrapper should survive after the final calls to dataStore() for it. That is... at the very end.

This is needed for objects whose destruction ordering is important, and enables natural c++ destruction in reverse construction order of the object that declares it.

See delcareRestartableData and declareRestartableDataWithContext for more information.

Definition at line 276 of file Restartable.h.

279 {
280  auto & data_ptr =
281  declareRestartableDataHelper<T>(data_name, context, std::forward<Args>(args)...);
282  return Restartable::ManagedValue<T>(data_ptr);
283 }
Wrapper class for restartable data that is "managed.
Definition: Restartable.h:42

◆ declareRecoverableData()

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

Declare a piece of data as "recoverable" 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)
argsArguments to forward to the constructor of the data

Definition at line 351 of file Restartable.h.

352 {
353  const auto full_name = restartableName(data_name);
354 
356 
357  return declareRestartableDataWithContext<T>(data_name, nullptr, std::forward<Args>(args)...);
358 }
std::string restartableName(const std::string &data_name) const
Gets the name of a piece of restartable data given a data name, adding the system name and object nam...
Definition: Restartable.C:66
void registerRestartableNameWithFilterOnApp(const std::string &name, Moose::RESTARTABLE_FILTER filter)
Helper function for actually registering the restartable data.
Definition: Restartable.C:59

◆ declareRestartableData()

template<typename T , typename... Args>
T & Restartable::declareRestartableData ( const std::string &  data_name,
Args &&...  args 
)
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)
argsArguments to forward to the constructor of the data

Definition at line 269 of file Restartable.h.

270 {
271  return declareRestartableDataWithContext<T>(data_name, nullptr, std::forward<Args>(args)...);
272 }

◆ declareRestartableDataWithContext()

template<typename T , typename... Args>
T & Restartable::declareRestartableDataWithContext ( const std::string &  data_name,
void context,
Args &&...  args 
)
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)
contextContext pointer that will be passed to the load and store functions
argsArguments to forward to the constructor of the data

Definition at line 294 of file Restartable.h.

297 {
298  return declareRestartableDataHelper<T>(data_name, context, std::forward<Args>(args)...).set();
299 }

◆ declareRestartableDataWithObjectName()

template<typename T , typename... Args>
T & Restartable::declareRestartableDataWithObjectName ( const std::string &  data_name,
const std::string &  object_name,
Args &&...  args 
)
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.
argsArguments to forward to the constructor of the data

Definition at line 323 of file Restartable.h.

326 {
327  return declareRestartableDataWithObjectNameWithContext<T>(
328  data_name, object_name, nullptr, std::forward<Args>(args)...);
329 }

◆ declareRestartableDataWithObjectNameWithContext()

template<typename T , typename... Args>
T & Restartable::declareRestartableDataWithObjectNameWithContext ( const std::string &  data_name,
const std::string &  object_name,
void context,
Args &&...  args 
)
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
argsArguments to forward to the constructor of the data

Definition at line 333 of file Restartable.h.

337 {
338  std::string old_name = _restartable_name;
339 
340  _restartable_name = object_name;
341 
342  T & value = declareRestartableDataWithContext<T>(data_name, context, std::forward<Args>(args)...);
343 
344  _restartable_name = old_name;
345 
346  return value;
347 }
std::string _restartable_name
The name of the object.
Definition: Restartable.h:243
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)

◆ get()

template<typename T>
const T& ChainControlData< T >::get ( ) const
inline
Returns
a read-only reference to the parameter value.

Definition at line 105 of file ChainControlData.h.

Referenced by ChainControlDataPostprocessor::getValue().

105 { return _value; }
T & _value
Current value.

◆ getChainControl()

const ChainControl & ChainControlDataBase::getChainControl ( ) const
inherited

Get the pointer to the control object that declared this control data.

Definition at line 13 of file ChainControlData.C.

14 {
15  if (!_chain_control)
16  mooseError("No chain control has been set for chain control data '", name(), "'.");
17 
18  return *_chain_control;
19 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
const std::string & name() const
The full (unique) name of this particular piece of data.
ChainControl * _chain_control
The control object that declared this control data.

◆ getDeclared()

bool ChainControlDataBase::getDeclared ( )
inlineinherited

Get the declared state.

Definition at line 67 of file ChainControlData.h.

67 { return _declared; }
bool _declared
true if the data was declared by calling declareControlData. All data must be declared up front...

◆ getOld()

template<typename T>
const T& ChainControlData< T >::getOld ( ) const
inline
Returns
a read-only reference to the old value.

Definition at line 110 of file ChainControlData.h.

110 { return _value_old; }
T & _value_old
Old value.

◆ getRestartableData()

template<typename T , typename... Args>
const T & Restartable::getRestartableData ( const std::string &  data_name) const
protectedinherited

Declare a piece of data as "restartable" and initialize it Similar to declareRestartableData but returns a const reference to the object.

Forwarded arguments are not allowed in this case because we assume that the object is restarted and we won't need different constructors to initialize it.

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

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

Definition at line 287 of file Restartable.h.

288 {
289  return declareRestartableDataHelper<T>(data_name, nullptr).get();
290 }

◆ name()

const std::string& ChainControlDataBase::name ( ) const
inlineinherited

The full (unique) name of this particular piece of data.

Definition at line 47 of file ChainControlData.h.

Referenced by ChainControlDataBase::getChainControl().

47 { return _name; }
const std::string _name
The full (unique) name of this particular piece of data.

◆ restartableName()

std::string Restartable::restartableName ( const std::string &  data_name) const
protectedinherited

Gets the name of a piece of restartable data given a data name, adding the system name and object name prefix.

This should only be used in this interface and in testing.

Definition at line 66 of file Restartable.C.

Referenced by Restartable::declareRecoverableData(), and Restartable::declareRestartableDataHelper().

67 {
68  return _restartable_system_name + "/" + _restartable_name + "/" + data_name;
69 }
std::string _restartable_name
The name of the object.
Definition: Restartable.h:243
const std::string _restartable_system_name
The system name this object is in.
Definition: Restartable.h:230

◆ set()

template<typename T>
T& ChainControlData< T >::set ( )
inline
Returns
a writable reference to the current value.

Definition at line 115 of file ChainControlData.h.

115 { return _value; }
T & _value
Current value.

◆ setChainControl()

void ChainControlDataBase::setChainControl ( ChainControl ctrl)
inlineinherited

Set the pointer to the control object that declared this control data.

Definition at line 57 of file ChainControlData.h.

57 { _chain_control = &ctrl; }
ChainControl * _chain_control
The control object that declared this control data.

◆ setDeclared()

void ChainControlDataBase::setDeclared ( )
inlineinherited

Mark the data as declared.

Definition at line 62 of file ChainControlData.h.

62 { _declared = true; }
bool _declared
true if the data was declared by calling declareControlData. All data must be declared up front...

◆ type()

template<typename T >
std::string ChainControlData< T >::type ( )
inlineoverridevirtual

String identifying the type of parameter stored.

Implements ChainControlDataBase.

Definition at line 133 of file ChainControlData.h.

134 {
135  return MooseUtils::prettyCppType<T>();
136 }

Member Data Documentation

◆ _chain_control

ChainControl* ChainControlDataBase::_chain_control
protectedinherited

The control object that declared this control data.

Definition at line 80 of file ChainControlData.h.

Referenced by ChainControlDataBase::getChainControl(), and ChainControlDataBase::setChainControl().

◆ _declared

bool ChainControlDataBase::_declared
protectedinherited

true if the data was declared by calling declareControlData. All data must be declared up front.

Definition at line 78 of file ChainControlData.h.

Referenced by ChainControlDataBase::getDeclared(), and ChainControlDataBase::setDeclared().

◆ _name

const std::string ChainControlDataBase::_name
protectedinherited

The full (unique) name of this particular piece of data.

Definition at line 76 of file ChainControlData.h.

Referenced by ChainControlDataBase::name().

◆ _restartable_app

MooseApp& Restartable::_restartable_app
protectedinherited

Reference to the application.

Definition at line 227 of file Restartable.h.

Referenced by Restartable::registerRestartableDataOnApp(), and Restartable::registerRestartableNameWithFilterOnApp().

◆ _restartable_read_only

const bool Restartable::_restartable_read_only
protectedinherited

Flag for toggling read only status (see ReporterData)

Definition at line 236 of file Restartable.h.

Referenced by Restartable::registerRestartableDataOnApp().

◆ _restartable_system_name

const std::string Restartable::_restartable_system_name
protectedinherited

The system name this object is in.

Definition at line 230 of file Restartable.h.

Referenced by Restartable::restartableName().

◆ _restartable_tid

const THREAD_ID Restartable::_restartable_tid
protectedinherited

The thread ID for this object.

Definition at line 233 of file Restartable.h.

Referenced by Restartable::declareRestartableDataHelper().

◆ _value

template<typename T>
T& ChainControlData< T >::_value
private

Current value.

Definition at line 126 of file ChainControlData.h.

Referenced by ChainControlData< Real >::get(), and ChainControlData< Real >::set().

◆ _value_old

template<typename T>
T& ChainControlData< T >::_value_old
private

Old value.

Definition at line 128 of file ChainControlData.h.

Referenced by ChainControlData< Real >::getOld().


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