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

A class for creating restricted objects. More...

#include <Restartable.h>

Inheritance diagram for Restartable:
[legend]

Public Member Functions

 Restartable (const MooseObject *moose_object, const std::string &system_name)
 Class constructor. More...
 
 Restartable (const MooseObject *moose_object, const std::string &system_name, THREAD_ID tid)
 Class constructor. More...
 
 Restartable (MooseApp &moose_app, const std::string &name, const std::string &system_name, THREAD_ID tid)
 This class constructor is used for non-Moose-based objects like interfaces. More...
 
virtual ~Restartable ()=default
 Emtpy destructor. 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...
 

Private Member Functions

void registerRestartableDataOnApp (std::string name, std::unique_ptr< RestartableDataValue > data, THREAD_ID tid)
 Helper function for actually registering the restartable data. More...
 
void registerRecoverableDataOnApp (std::string name)
 Helper function for actually registering the restartable data. More...
 

Private Attributes

MooseApp_restartable_app
 Reference to the application. More...
 
std::string _restartable_name
 The name of the object. More...
 
std::string _restartable_system_name
 The system name this object is in. More...
 
THREAD_ID _restartable_tid
 The thread ID for this object. More...
 

Detailed Description

A class for creating restricted objects.

See also
BlockRestartable BoundaryRestartable

Definition at line 28 of file Restartable.h.

Constructor & Destructor Documentation

◆ Restartable() [1/3]

Restartable::Restartable ( const MooseObject moose_object,
const std::string &  system_name 
)

Class constructor.

Parameters
moose_objectThe MooseObject that this interface is being implemented on.
system_nameThe name of the MOOSE system. ie "Kernel", "BCs", etc. Should roughly correspond to the section in the input file so errors are easy to understand.

This method will forward the thread id if it exists in the moose_object parameters. Delegates to the "MooseApp &" constructor.

Definition at line 17 of file Restartable.C.

18  : Restartable(moose_object->getMooseApp(),
19  moose_object->name(),
20  system_name,
21  moose_object->parameters().isParamValid("_tid")
22  ? moose_object->parameters().get<THREAD_ID>("_tid")
23  : 0)
24 {
25 }
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseObject.h:57
Restartable(const MooseObject *moose_object, const std::string &system_name)
Class constructor.
Definition: Restartable.C:17
const std::string & name() const
Get the name of the object.
Definition: MooseObject.h:51
MooseApp & getMooseApp() const
Get the MooseApp this object is associated with.
Definition: MooseObject.h:86
unsigned int THREAD_ID
Definition: MooseTypes.h:97
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.

◆ Restartable() [2/3]

Restartable::Restartable ( const MooseObject moose_object,
const std::string &  system_name,
THREAD_ID  tid 
)

Class constructor.

Similar to the other class constructor but also accepts an individual thread ID. If this method is used, no thread ID in the parameters object is used. Delegates to the "MooseApp &" constructor.

Definition at line 27 of file Restartable.C.

30  : Restartable(moose_object->getMooseApp(), moose_object->name(), system_name, tid)
31 {
32 }
Restartable(const MooseObject *moose_object, const std::string &system_name)
Class constructor.
Definition: Restartable.C:17
const std::string & name() const
Get the name of the object.
Definition: MooseObject.h:51
MooseApp & getMooseApp() const
Get the MooseApp this object is associated with.
Definition: MooseObject.h:86

◆ Restartable() [3/3]

Restartable::Restartable ( MooseApp moose_app,
const std::string &  name,
const std::string &  system_name,
THREAD_ID  tid 
)

This class constructor is used for non-Moose-based objects like interfaces.

A name for the storage as well as a system name must be passed in along with the thread ID explicitly.

Definition at line 34 of file Restartable.C.

38  : _restartable_app(moose_app),
39  _restartable_name(name),
40  _restartable_system_name(system_name),
41  _restartable_tid(tid)
42 {
43 }
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
MooseApp & _restartable_app
Reference to the application.
Definition: Restartable.h:188

◆ ~Restartable()

virtual Restartable::~Restartable ( )
virtualdefault

Emtpy destructor.

Member Function Documentation

◆ declareRecoverableData() [1/2]

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

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 
)
protected

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)
protected

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 
)
protected

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 
)
protected

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 
)
protected

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 
)
protected

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 
)
protected

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

◆ registerRecoverableDataOnApp()

void Restartable::registerRecoverableDataOnApp ( std::string  name)
private

Helper function for actually registering the restartable data.

Definition at line 54 of file Restartable.C.

Referenced by declareRecoverableData().

55 {
57 }
void registerRecoverableData(std::string name)
NOTE: This is an internal function meant for MOOSE use only!
Definition: MooseApp.C:882
MooseApp & _restartable_app
Reference to the application.
Definition: Restartable.h:188

◆ registerRestartableDataOnApp()

void Restartable::registerRestartableDataOnApp ( std::string  name,
std::unique_ptr< RestartableDataValue data,
THREAD_ID  tid 
)
private

Helper function for actually registering the restartable data.

Definition at line 46 of file Restartable.C.

Referenced by declareRestartableDataWithContext().

49 {
50  _restartable_app.registerRestartableData(name, std::move(data), tid);
51 }
void registerRestartableData(std::string name, std::unique_ptr< RestartableDataValue > data, THREAD_ID tid)
Definition: MooseApp.C:1090
MooseApp & _restartable_app
Reference to the application.
Definition: Restartable.h:188

Member Data Documentation

◆ _restartable_app

MooseApp& Restartable::_restartable_app
private

Reference to the application.

Definition at line 188 of file Restartable.h.

Referenced by registerRecoverableDataOnApp(), and registerRestartableDataOnApp().

◆ _restartable_name

std::string Restartable::_restartable_name
private

◆ _restartable_system_name

std::string Restartable::_restartable_system_name
private

The system name this object is in.

Definition at line 194 of file Restartable.h.

Referenced by declareRecoverableData(), and declareRestartableDataWithContext().

◆ _restartable_tid

THREAD_ID Restartable::_restartable_tid
private

The thread ID for this object.

Definition at line 197 of file Restartable.h.

Referenced by declareRestartableDataWithContext().


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