https://mooseframework.inl.gov
Public Member Functions | Private Attributes | List of all members
ChainControlDataSystem Class Reference

System that manages ChainControls. More...

#include <ChainControlDataSystem.h>

Public Member Functions

 ChainControlDataSystem (MooseApp &app)
 
bool hasChainControlData (const std::string &data_name) const
 Queries if the chain control data of the given name exists. More...
 
template<typename T >
bool hasChainControlDataOfType (const std::string &data_name) const
 Queries if the chain control data of the given name and type exists. More...
 
template<typename T >
ChainControlData< T > & getChainControlData (const std::string &data_name)
 Gets the chain control data of the given name and type and creates if it does not exist. More...
 
template<typename T >
ChainControlData< T > & declareChainControlData (const std::string &data_name, ChainControl &chain_control)
 Declares chain control data of of the given name and type and creates if it does not exist. More...
 
void copyValuesBack ()
 Copies current chain control data values into old values. More...
 
const std::map< std::string, std::unique_ptr< ChainControlDataBase > > & getChainControlDataMap () const
 Gets the map of ChainControlData names to the relevant ChainControlDataBase. More...
 

Private Attributes

MooseApp_app
 The MooseApp that owns this system. More...
 
std::map< std::string, std::unique_ptr< ChainControlDataBase > > _chain_control_data_map
 Map of chain control data name to its value. More...
 

Detailed Description

System that manages ChainControls.

To be owned by the MooseApp.

Definition at line 23 of file ChainControlDataSystem.h.

Constructor & Destructor Documentation

◆ ChainControlDataSystem()

ChainControlDataSystem::ChainControlDataSystem ( MooseApp app)

Definition at line 12 of file ChainControlDataSystem.C.

12 : _app(app) {}
MooseApp & _app
The MooseApp that owns this system.

Member Function Documentation

◆ copyValuesBack()

void ChainControlDataSystem::copyValuesBack ( )

Copies current chain control data values into old values.

Definition at line 21 of file ChainControlDataSystem.C.

Referenced by ChainControlSetupAction::act(), and FEProblemBase::advanceState().

22 {
23  for (const auto & item : _chain_control_data_map)
24  item.second->copyValuesBack();
25 }
std::map< std::string, std::unique_ptr< ChainControlDataBase > > _chain_control_data_map
Map of chain control data name to its value.

◆ declareChainControlData()

template<typename T >
ChainControlData< T > & ChainControlDataSystem::declareChainControlData ( const std::string &  data_name,
ChainControl chain_control 
)

Declares chain control data of of the given name and type and creates if it does not exist.

If the data has already been declared, an error is thrown; otherwise the data is now set to be declared, and the declaring ChainControl is captured.

Template Parameters
TType of the data
Parameters
[in]data_nameChain control data name
[in]chain_controlChain control that is declaring the data
Returns
Reference to the declared chain control data

Definition at line 126 of file ChainControlDataSystem.h.

Referenced by ChainControl::declareChainControlData().

128 {
129  auto & data = getChainControlData<T>(data_name);
130  if (!data.getDeclared())
131  {
132  data.setDeclared();
133  data.setChainControl(chain_control);
134  }
135  else
136  mooseError("The chain control data '", data_name, "' has already been declared.");
137 
138  return data;
139 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302

◆ getChainControlData()

template<typename T >
ChainControlData< T > & ChainControlDataSystem::getChainControlData ( const std::string &  data_name)

Gets the chain control data of the given name and type and creates if it does not exist.

If the data exists but of another type, then an error is thrown.

Template Parameters
TType of the data
Parameters
[in]data_nameChain control data name
Returns
Reference to the requested chain control data

Definition at line 105 of file ChainControlDataSystem.h.

Referenced by ChainControl::getChainControlDataOldByName(), and ChainControlParsedFunctionWrapper::initializeFunctionInputs().

106 {
107  if (hasChainControlData(data_name))
108  {
109  if (!hasChainControlDataOfType<T>(data_name))
110  mooseError("The chain control data '",
111  data_name,
112  "' was requested with the type '",
113  MooseUtils::prettyCppType<T>(),
114  "' but has the type '",
115  _chain_control_data_map[data_name]->type(),
116  "'.");
117  }
118  else
119  _chain_control_data_map[data_name] = std::make_unique<ChainControlData<T>>(_app, data_name);
120 
121  return static_cast<ChainControlData<T> &>(*_chain_control_data_map[data_name]);
122 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
std::map< std::string, std::unique_ptr< ChainControlDataBase > > _chain_control_data_map
Map of chain control data name to its value.
MooseApp & _app
The MooseApp that owns this system.
bool hasChainControlData(const std::string &data_name) const
Queries if the chain control data of the given name exists.
Concrete definition of a parameter value for a specified type.

◆ getChainControlDataMap()

const std::map< std::string, std::unique_ptr< ChainControlDataBase > > & ChainControlDataSystem::getChainControlDataMap ( ) const

Gets the map of ChainControlData names to the relevant ChainControlDataBase.

Definition at line 28 of file ChainControlDataSystem.C.

Referenced by ChainControlSetupAction::act().

29 {
31 }
std::map< std::string, std::unique_ptr< ChainControlDataBase > > _chain_control_data_map
Map of chain control data name to its value.

◆ hasChainControlData()

bool ChainControlDataSystem::hasChainControlData ( const std::string &  data_name) const

Queries if the chain control data of the given name exists.

Parameters
[in]data_nameChain control data name
Returns
True if the chain control data of the given name exists

Definition at line 15 of file ChainControlDataSystem.C.

Referenced by getChainControlData(), and hasChainControlDataOfType().

16 {
17  return _chain_control_data_map.find(data_name) != _chain_control_data_map.end();
18 }
std::map< std::string, std::unique_ptr< ChainControlDataBase > > _chain_control_data_map
Map of chain control data name to its value.

◆ hasChainControlDataOfType()

template<typename T >
bool ChainControlDataSystem::hasChainControlDataOfType ( const std::string &  data_name) const

Queries if the chain control data of the given name and type exists.

Template Parameters
TType of the data
Parameters
[in]data_nameChain control data name
Returns
True if the chain control data of the given name and type exists

Definition at line 94 of file ChainControlDataSystem.h.

Referenced by ChainControlParsedFunctionWrapper::initializeFunctionInputs().

95 {
96  if (hasChainControlData(data_name))
97  return dynamic_cast<ChainControlData<T> *>(_chain_control_data_map.at(data_name).get()) !=
98  nullptr;
99  else
100  return false;
101 }
std::map< std::string, std::unique_ptr< ChainControlDataBase > > _chain_control_data_map
Map of chain control data name to its value.
bool hasChainControlData(const std::string &data_name) const
Queries if the chain control data of the given name exists.
Concrete definition of a parameter value for a specified type.

Member Data Documentation

◆ _app

MooseApp& ChainControlDataSystem::_app
private

The MooseApp that owns this system.

Definition at line 86 of file ChainControlDataSystem.h.

Referenced by getChainControlData().

◆ _chain_control_data_map

std::map<std::string, std::unique_ptr<ChainControlDataBase> > ChainControlDataSystem::_chain_control_data_map
private

Map of chain control data name to its value.

Definition at line 89 of file ChainControlDataSystem.h.

Referenced by copyValuesBack(), getChainControlData(), getChainControlDataMap(), hasChainControlData(), and hasChainControlDataOfType().


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