www.mooseframework.org
AddAuxVariableAction.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "AddAuxVariableAction.h"
16 #include "FEProblem.h"
17 
18 template <>
21 {
24 
26  params += validParams<OutputInterface>();
27 
28  params.addParam<MooseEnum>(
29  "family", families, "Specifies the family of FE shape functions to use for this variable");
30  params.addParam<MooseEnum>("order",
31  orders,
32  "Specifies the order of the FE shape function to use "
33  "for this variable (additional orders not listed are "
34  "allowed)");
35  params.addParam<Real>("initial_condition", "Specifies the initial condition for this variable");
36  params.addParam<std::vector<SubdomainName>>("block", "The block id where this variable lives");
37 
38  return params;
39 }
40 
42 
45 {
46  return MooseEnum("LAGRANGE MONOMIAL SCALAR", "LAGRANGE", true);
47 }
48 
51 {
52  return MooseEnum(
53  "CONSTANT FIRST SECOND THIRD FOURTH FIFTH SIXTH SEVENTH EIGHTH NINTH", "FIRST", true);
54 }
55 
56 void
58 {
59  // Name of variable being added
60  std::string var_name = name();
61 
62  // Blocks from the input
63  std::set<SubdomainID> blocks = getSubdomainIDs();
64 
65  // Scalar variable
66  if (_scalar_var)
67  _problem->addAuxScalarVariable(var_name, _fe_type.order);
68 
69  // Non-scalar variable
70  else
71  {
72  // Check that the order is valid (CONSTANT, FIRST, or SECOND)
73  if (_fe_type.order > 9)
74  mooseError("Non-scalar AuxVariables must be CONSTANT, FIRST, SECOND, THIRD, FOURTH, FIFTH, "
75  "SIXTH, SEVENTH, EIGHTH or NINTH order (",
76  _fe_type.order,
77  " supplied)");
78 
79  if (blocks.empty())
80  _problem->addAuxVariable(var_name, _fe_type);
81  else
82  _problem->addAuxVariable(var_name, _fe_type, &blocks);
83  }
84 
85  // Create the initial condition
86  if (isParamValid("initial_condition"))
88 }
AddAuxVariableAction(InputParameters params)
Class constructor.
std::set< SubdomainID > getSubdomainIDs()
Get the block ids from the input parameters.
bool _scalar_var
True if the variable being created is a scalar.
Adds nonlinear variable.
InputParameters validParams< OutputInterface >()
static MooseEnum getAuxVariableFamilies()
Returns available families for AuxVariables.
FEType _fe_type
FEType for the variable being created.
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters validParams< AddAuxVariableAction >()
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:37
bool isParamValid(const std::string &name) const
Definition: Action.h:80
virtual void act() override
static MooseEnum getAuxVariableOrders()
Returns available orders for AuxVariables.
const std::string & name() const
The name of the action.
Definition: Action.h:51
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
Definition: Action.h:131
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
void createInitialConditionAction()
Create the action to generate the InitialCondition object.
InputParameters validParams< Action >()
Definition: Action.C:23