www.mooseframework.org
AddAuxVariableAction.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "AddAuxVariableAction.h"
11 #include "FEProblem.h"
12 
13 registerMooseAction("MooseApp", AddAuxVariableAction, "add_aux_variable");
14 
15 template <>
18 {
21 
23  params += validParams<OutputInterface>();
24 
25  params.addParam<MooseEnum>(
26  "family", families, "Specifies the family of FE shape functions to use for this variable");
27  params.addParam<MooseEnum>("order",
28  orders,
29  "Specifies the order of the FE shape function to use "
30  "for this variable (additional orders not listed are "
31  "allowed)");
32  params.addParam<Real>("initial_condition", "Specifies the initial condition for this variable");
33  params.addParam<std::vector<SubdomainName>>("block", "The block id where this variable lives");
34 
35  return params;
36 }
37 
39 
42 {
43  return MooseEnum("LAGRANGE MONOMIAL SCALAR LAGRANGE_VEC", "LAGRANGE", true);
44 }
45 
48 {
49  return MooseEnum(
50  "CONSTANT FIRST SECOND THIRD FOURTH FIFTH SIXTH SEVENTH EIGHTH NINTH", "FIRST", true);
51 }
52 
53 void
55 {
56  // Name of variable being added
57  std::string var_name = name();
58 
59  // Blocks from the input
60  std::set<SubdomainID> blocks = getSubdomainIDs();
61 
62  // Scalar variable
63  if (_scalar_var)
64  _problem->addAuxScalarVariable(var_name, _fe_type.order);
65 
66  // Non-scalar variable
67  else
68  {
69  // Check that the order is valid (CONSTANT, FIRST, or SECOND)
70  if (_fe_type.order > 9)
71  mooseError("Non-scalar AuxVariables must be CONSTANT, FIRST, SECOND, THIRD, FOURTH, FIFTH, "
72  "SIXTH, SEVENTH, EIGHTH or NINTH order (",
73  _fe_type.order,
74  " supplied)");
75 
76  if (blocks.empty())
77  _problem->addAuxVariable(var_name, _fe_type);
78  else
79  _problem->addAuxVariable(var_name, _fe_type, &blocks);
80  }
81 
82  // Create the initial condition
83  if (isParamValid("initial_condition"))
85 }
bool isParamValid(const std::string &name) const
Definition: Action.h:115
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.
const std::string & name() const
The name of the action.
Definition: Action.h:76
Adds nonlinear variable.
InputParameters validParams< OutputInterface >()
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:207
static MooseEnum getAuxVariableFamilies()
Returns available families for AuxVariables.
FEType _fe_type
FEType for the variable being created.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters validParams< AddAuxVariableAction >()
Action for creating Auxiliary variables.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
static MooseEnum getAuxVariableOrders()
Returns available orders for AuxVariables.
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
Definition: Action.h:216
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:22
registerMooseAction("MooseApp", AddAuxVariableAction, "add_aux_variable")