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

Holds variables and provides some services. More...

#include <VariableWarehouse.h>

Public Member Functions

 VariableWarehouse ()
 
virtual ~VariableWarehouse ()
 
void add (const std::string &var_name, MooseVariableBase *var)
 Add a variable. More...
 
void addBoundaryVar (BoundaryID bnd, MooseVariable *var)
 Add a boundary variable. More...
 
void addBoundaryVar (const std::set< BoundaryID > &boundary_ids, MooseVariable *var)
 Add a variable to a set of boundaries. More...
 
void addBoundaryVars (const std::set< BoundaryID > &boundary_ids, const std::map< std::string, std::vector< MooseVariable * >> &vars)
 Add a map of variables to a set of boundaries. More...
 
MooseVariableBasegetVariable (const std::string &var_name)
 Get a variable from the warehouse. More...
 
MooseVariableBasegetVariable (unsigned int var_number)
 Get a variable from the warehouse. More...
 
const std::vector< VariableName > & names () const
 Get the list of all variable names. More...
 
const std::vector< MooseVariable * > & variables ()
 Get the list of variables. More...
 
const std::set< MooseVariable * > & boundaryVars (BoundaryID bnd)
 Get the list of variables that needs to be reinitialized on a given boundary. More...
 
const std::vector< MooseVariableScalar * > & scalars ()
 Get the list of scalar variables. More...
 

Protected Attributes

std::vector< VariableName > _names
 list of variable names More...
 
std::vector< MooseVariable * > _vars
 list of "normal" variables More...
 
std::map< std::string, MooseVariableBase * > _var_name
 Name to variable mapping. More...
 
std::map< BoundaryID, std::set< MooseVariable * > > _boundary_vars
 Map to variables that need to be evaluated on a boundary. More...
 
std::vector< MooseVariableScalar * > _scalar_vars
 list of all variables More...
 
std::vector< MooseVariableBase * > _all_objects
 All instances of objects (raw pointers) More...
 

Detailed Description

Holds variables and provides some services.

Definition at line 31 of file VariableWarehouse.h.

Constructor & Destructor Documentation

VariableWarehouse::VariableWarehouse ( )

Definition at line 20 of file VariableWarehouse.C.

20 {}
VariableWarehouse::~VariableWarehouse ( )
virtual

Definition at line 22 of file VariableWarehouse.C.

23 {
24  for (auto & var : _all_objects)
25  delete var;
26 }
std::vector< MooseVariableBase * > _all_objects
All instances of objects (raw pointers)

Member Function Documentation

void VariableWarehouse::add ( const std::string &  var_name,
MooseVariableBase var 
)

Add a variable.

Parameters
var_nameThe name of the variable
varVariable

Definition at line 29 of file VariableWarehouse.C.

30 {
31  _names.push_back(var_name);
32  _var_name[var_name] = var;
33  _all_objects.push_back(var);
34 
35  if (dynamic_cast<MooseVariable *>(var) != NULL)
36  {
37  _vars.push_back(dynamic_cast<MooseVariable *>(var));
38  }
39  else if (dynamic_cast<MooseVariableScalar *>(var) != NULL)
40  {
41  _scalar_vars.push_back(dynamic_cast<MooseVariableScalar *>(var));
42  }
43  else
44  mooseError("Unknown variable class passed into VariableWarehouse. Attempt to hack us?");
45 }
std::vector< MooseVariableScalar * > _scalar_vars
list of all variables
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
std::vector< MooseVariableBase * > _all_objects
All instances of objects (raw pointers)
std::map< std::string, MooseVariableBase * > _var_name
Name to variable mapping.
std::vector< MooseVariable * > _vars
list of "normal" variables
std::vector< VariableName > _names
list of variable names
void VariableWarehouse::addBoundaryVar ( BoundaryID  bnd,
MooseVariable var 
)

Add a boundary variable.

Parameters
bndThe boundary id where this variable is defined
varThe variable

Definition at line 48 of file VariableWarehouse.C.

Referenced by addBoundaryVar(), and addBoundaryVars().

49 {
50  _boundary_vars[bnd].insert(var);
51 }
std::map< BoundaryID, std::set< MooseVariable * > > _boundary_vars
Map to variables that need to be evaluated on a boundary.
void VariableWarehouse::addBoundaryVar ( const std::set< BoundaryID > &  boundary_ids,
MooseVariable var 
)

Add a variable to a set of boundaries.

Parameters
boundary_idsThe boundary ids where this variable is defined
varThe variable

Definition at line 54 of file VariableWarehouse.C.

55 {
56  for (const auto & bid : boundary_ids)
57  addBoundaryVar(bid, var);
58 }
void addBoundaryVar(BoundaryID bnd, MooseVariable *var)
Add a boundary variable.
void VariableWarehouse::addBoundaryVars ( const std::set< BoundaryID > &  boundary_ids,
const std::map< std::string, std::vector< MooseVariable * >> &  vars 
)

Add a map of variables to a set of boundaries.

Parameters
boundary_idsThe boundary ids where this variable is defined
varsA map of variables

Definition at line 61 of file VariableWarehouse.C.

63 {
64  for (const auto & bid : boundary_ids)
65  for (const auto & it : vars)
66  for (const auto & var : it.second)
67  addBoundaryVar(bid, var);
68 }
void addBoundaryVar(BoundaryID bnd, MooseVariable *var)
Add a boundary variable.
const std::set< MooseVariable * > & VariableWarehouse::boundaryVars ( BoundaryID  bnd)

Get the list of variables that needs to be reinitialized on a given boundary.

Parameters
bndThe boundary ID
Returns
The list of variables

Definition at line 104 of file VariableWarehouse.C.

105 {
106  return _boundary_vars[bnd];
107 }
std::map< BoundaryID, std::set< MooseVariable * > > _boundary_vars
Map to variables that need to be evaluated on a boundary.
MooseVariableBase * VariableWarehouse::getVariable ( const std::string &  var_name)

Get a variable from the warehouse.

Parameters
var_nameThe name of the variable to retrieve
Returns
The retrieved variable

Definition at line 71 of file VariableWarehouse.C.

72 {
73  return _var_name[var_name];
74 }
std::map< std::string, MooseVariableBase * > _var_name
Name to variable mapping.
MooseVariableBase * VariableWarehouse::getVariable ( unsigned int  var_number)

Get a variable from the warehouse.

Parameters
var_numberThe number of the variable to retrieve
Returns
The retrieved variable

Definition at line 77 of file VariableWarehouse.C.

78 {
79  if (var_number < _all_objects.size())
80  return _all_objects[var_number];
81  else
82  return NULL;
83 }
std::vector< MooseVariableBase * > _all_objects
All instances of objects (raw pointers)
const std::vector< VariableName > & VariableWarehouse::names ( ) const

Get the list of all variable names.

Returns
The list of variable names

Definition at line 86 of file VariableWarehouse.C.

87 {
88  return _names;
89 }
std::vector< VariableName > _names
list of variable names
const std::vector< MooseVariableScalar * > & VariableWarehouse::scalars ( )

Get the list of scalar variables.

Returns
The list of scalar variables

Definition at line 98 of file VariableWarehouse.C.

99 {
100  return _scalar_vars;
101 }
std::vector< MooseVariableScalar * > _scalar_vars
list of all variables
const std::vector< MooseVariable * > & VariableWarehouse::variables ( )

Get the list of variables.

Returns
The list of variables

Definition at line 92 of file VariableWarehouse.C.

93 {
94  return _vars;
95 }
std::vector< MooseVariable * > _vars
list of "normal" variables

Member Data Documentation

std::vector<MooseVariableBase *> VariableWarehouse::_all_objects
protected

All instances of objects (raw pointers)

Definition at line 119 of file VariableWarehouse.h.

Referenced by add(), getVariable(), and ~VariableWarehouse().

std::map<BoundaryID, std::set<MooseVariable *> > VariableWarehouse::_boundary_vars
protected

Map to variables that need to be evaluated on a boundary.

Definition at line 113 of file VariableWarehouse.h.

Referenced by addBoundaryVar(), and boundaryVars().

std::vector<VariableName> VariableWarehouse::_names
protected

list of variable names

Definition at line 107 of file VariableWarehouse.h.

Referenced by add(), and names().

std::vector<MooseVariableScalar *> VariableWarehouse::_scalar_vars
protected

list of all variables

Definition at line 116 of file VariableWarehouse.h.

Referenced by add(), and scalars().

std::map<std::string, MooseVariableBase *> VariableWarehouse::_var_name
protected

Name to variable mapping.

Definition at line 111 of file VariableWarehouse.h.

Referenced by add(), and getVariable().

std::vector<MooseVariable *> VariableWarehouse::_vars
protected

list of "normal" variables

Definition at line 109 of file VariableWarehouse.h.

Referenced by add(), and variables().


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