https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Private Attributes | List of all members
ControllableAlias Class Reference

Allows for aliases to be defined via InputParameterWarehouse::addControllableParameterAlias. More...

#include <ControllableItem.h>

Inheritance diagram for ControllableAlias:
[legend]

Public Member Functions

 ControllableAlias (const MooseObjectParameterName &name, ControllableItem *)
 
virtual const MooseObjectParameterNamename () const override
 Return the name of the master parameter.
 
virtual std::string dump (unsigned int indent=0) const override
 Returns a string displaying the parameter name and current value.
 
void connect (ControllableItem *item, bool type_check=true)
 Connects the supplied item with this item to allow for multiple parameters to be changed by one.
 
template<typename T >
void set (const T &value, bool type_check=true)
 Set the value(s) of the controlled parameters stored in this class.
 
template<typename T >
std::vector< T > get (bool type_check=true) const
 Return a copy of all values for this "item".
 
template<typename T >
bool check () const
 Return true if the template argument is valid for ALL items.
 
std::string type () const
 Return the type of the master parameter.
 
const std::set< ExecFlagType > & getExecuteOnFlags () const
 Return the execute flag restrictions, an empty set is un-restricted.
 
bool operator== (const ControllableItem &rhs) const
 Use the master name for comparison operators to allow object to work within a set/map.
 
bool operator!= (const ControllableItem &rhs) const
 
bool operator< (const ControllableItem &rhs) const
 
void resetChanged ()
 Methods for ControlOutput::outputChangedControls, these don't have meaning outside of this function.
 
bool isChanged ()
 

Protected Attributes

std::vector< std::pair< MooseObjectParameterName, libMesh::Parameters::Value * > > _pairs
 List of names for this item.
 
bool _changed = false
 Flag for ControlOutput, allows output objects to keep track of when a parameter is altered.
 
std::set< ExecFlagType_execute_flags
 Flags to which the control is restricted (if not set it is unrestricted)
 

Private Attributes

MooseObjectParameterName _name
 

Detailed Description

Allows for aliases to be defined via InputParameterWarehouse::addControllableParameterAlias.

Definition at line 190 of file ControllableItem.h.

Constructor & Destructor Documentation

◆ ControllableAlias()

ControllableAlias::ControllableAlias ( const MooseObjectParameterName name,
ControllableItem item 
)

Definition at line 78 of file ControllableItem.C.

80{
81 connect(item, false);
82}
MooseObjectParameterName _name
virtual const MooseObjectParameterName & name() const override
Return the name of the master parameter.
ControllableItem()
Constructor for creating an empty item (see ControllableAlias)
void connect(ControllableItem *item, bool type_check=true)
Connects the supplied item with this item to allow for multiple parameters to be changed by one.

Member Function Documentation

◆ check()

template<typename T >
bool ControllableItem::check ( ) const
inherited

Return true if the template argument is valid for ALL items.

Definition at line 175 of file ControllableItem.h.

176{
177 return std::all_of(_pairs.begin(),
178 _pairs.end(),
179 [](std::pair<MooseObjectParameterName, libMesh::Parameters::Value *> pair)
180 {
181 libMesh::Parameters::Parameter<T> * param =
182 dynamic_cast<libMesh::Parameters::Parameter<T> *>(pair.second);
183 return param != nullptr;
184 });
185}
std::vector< std::pair< MooseObjectParameterName, libMesh::Parameters::Value * > > _pairs
List of names for this item.

◆ connect()

void ControllableItem::connect ( ControllableItem item,
bool  type_check = true 
)
inherited

Connects the supplied item with this item to allow for multiple parameters to be changed by one.

Definition at line 24 of file ControllableItem.C.

25{
26 for (const auto & pair : item->_pairs)
27 {
28 if (type_check && type() != pair.second->type())
29 mooseError("The master parameter (",
30 name(),
31 ") has a type '",
32 type(),
33 "' and cannot be connected to the parameter (",
34 pair.first,
35 ") with a different type of '",
36 pair.second->type(),
37 "'.");
38
39 _pairs.emplace_back(pair.first, pair.second);
40 }
41}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
virtual const MooseObjectParameterName & name() const
Return the name of the master parameter.
std::string type() const
Return the type of the master parameter.

Referenced by ControllableAlias().

◆ dump()

std::string ControllableAlias::dump ( unsigned int  indent = 0) const
overridevirtual

Returns a string displaying the parameter name and current value.

Reimplemented from ControllableItem.

Definition at line 91 of file ControllableItem.C.

92{
93 // The output stream
94 std::ostringstream oss;
95 oss << ConsoleUtils::indent(indent) << COLOR_GREEN << _name << COLOR_DEFAULT;
96 for (const auto & pair : _pairs)
97 {
98 oss << ConsoleUtils::indent(indent + 2) << COLOR_YELLOW << pair.first << COLOR_DEFAULT << " = ";
99 pair.second->print(oss);
100 oss << " <" << pair.second->type() << ">\n";
101 }
102 return oss.str();
103}
std::string indent(unsigned int spaces)
Create empty string for indenting.

◆ get()

template<typename T >
std::vector< T > ControllableItem::get ( bool  type_check = true) const
inherited

Return a copy of all values for this "item".

Definition at line 153 of file ControllableItem.h.

154{
155 std::vector<T> output;
156 output.reserve(_pairs.size());
157 for (const auto & pair : _pairs)
158 {
160 dynamic_cast<libMesh::Parameters::Parameter<T> *>(pair.second);
161 if (type_check && param == nullptr)
162 mooseError("Failed to get the '",
163 pair.first,
164 "' parameter the supplied template argument must be of type '",
165 pair.second->type(),
166 "'.");
167 else if (param != nullptr)
168 output.push_back(param->get());
169 }
170 return output;
171}

◆ getExecuteOnFlags()

const std::set< ExecFlagType > & ControllableItem::getExecuteOnFlags ( ) const
inlineinherited

Return the execute flag restrictions, an empty set is un-restricted.

Definition at line 108 of file ControllableItem.h.

108{ return _execute_flags; }
std::set< ExecFlagType > _execute_flags
Flags to which the control is restricted (if not set it is unrestricted)

◆ isChanged()

bool ControllableItem::isChanged ( )
inlineinherited

Definition at line 102 of file ControllableItem.h.

102{ return _changed; }
bool _changed
Flag for ControlOutput, allows output objects to keep track of when a parameter is altered.

◆ name()

const MooseObjectParameterName & ControllableAlias::name ( ) const
overridevirtual

Return the name of the master parameter.

Reimplemented from ControllableItem.

Definition at line 85 of file ControllableItem.C.

86{
87 return _name;
88}

◆ operator!=()

bool ControllableItem::operator!= ( const ControllableItem rhs) const
inlineinherited

Definition at line 77 of file ControllableItem.h.

77{ return name() != rhs.name(); }

◆ operator<()

bool ControllableItem::operator< ( const ControllableItem rhs) const
inlineinherited

Definition at line 78 of file ControllableItem.h.

78{ return name() < rhs.name(); }

◆ operator==()

bool ControllableItem::operator== ( const ControllableItem rhs) const
inlineinherited

Use the master name for comparison operators to allow object to work within a set/map.

Definition at line 76 of file ControllableItem.h.

76{ return name() == rhs.name(); }

◆ resetChanged()

void ControllableItem::resetChanged ( )
inlineinherited

Methods for ControlOutput::outputChangedControls, these don't have meaning outside of this function.

Definition at line 101 of file ControllableItem.h.

101{ _changed = false; }

◆ set()

template<typename T >
void ControllableItem::set ( const T &  value,
bool  type_check = true 
)
inherited

Set the value(s) of the controlled parameters stored in this class.

The 'skip_type_check' flag allows this object to work with ControllableParameter that can store values of varying types.

Definition at line 131 of file ControllableItem.h.

132{
133 for (auto & pair : _pairs)
134 {
136 dynamic_cast<libMesh::Parameters::Parameter<T> *>(pair.second);
137 if (type_check && param == nullptr)
138 mooseError("Failed to set the '",
139 pair.first,
140 "' parameter the supplied template argument must be of type '",
141 pair.second->type(),
142 "'.");
143 else if (param != nullptr)
144 {
145 param->set() = value;
146 _changed = true;
147 }
148 }
149}
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)

◆ type()

std::string ControllableItem::type ( ) const
inherited

Return the type of the master parameter.

Definition at line 67 of file ControllableItem.C.

68{
69 return _pairs[0].second->type();
70}

Referenced by ControllableItem::connect().

Member Data Documentation

◆ _changed

bool ControllableItem::_changed = false
protectedinherited

Flag for ControlOutput, allows output objects to keep track of when a parameter is altered.

Definition at line 123 of file ControllableItem.h.

Referenced by ControllableItem::isChanged(), ControllableItem::resetChanged(), and ControllableItem::set().

◆ _execute_flags

std::set<ExecFlagType> ControllableItem::_execute_flags
protectedinherited

Flags to which the control is restricted (if not set it is unrestricted)

Definition at line 126 of file ControllableItem.h.

Referenced by ControllableItem::getExecuteOnFlags().

◆ _name

MooseObjectParameterName ControllableAlias::_name
private

Definition at line 198 of file ControllableItem.h.

Referenced by dump(), and name().

◆ _pairs

std::vector<std::pair<MooseObjectParameterName, libMesh::Parameters::Value *> > ControllableItem::_pairs
protectedinherited

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