www.mooseframework.org
PolycrystalVariablesAction.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
8 #include "AddVariableAction.h"
9 #include "Conversion.h"
10 #include "Factory.h"
11 #include "FEProblem.h"
12 
13 #include "libmesh/string_to_enum.h"
14 
15 template <>
16 InputParameters
18 {
19  InputParameters params = validParams<Action>();
20  params.addClassDescription("Set up order parameter variables for a polycrystal simulation");
21  // Get MooseEnums for the possible order/family options for this variable
22  MooseEnum families(AddVariableAction::getNonlinearVariableFamilies());
23  MooseEnum orders(AddVariableAction::getNonlinearVariableOrders());
24  params.addParam<MooseEnum>("family",
25  families,
26  "Specifies the family of FE "
27  "shape function to use for the order parameters");
28  params.addParam<MooseEnum>("order",
29  orders,
30  "Specifies the order of the FE "
31  "shape function to use for the order parameters");
32  params.addParam<Real>("scaling", 1.0, "Specifies a scaling factor to apply to this variable");
33  params.addRequiredParam<unsigned int>("op_num",
34  "specifies the number of order parameters to create");
35  params.addRequiredParam<std::string>("var_name_base", "specifies the base name of the variables");
36  return params;
37 }
38 
40  : Action(params),
41  _op_num(getParam<unsigned int>("op_num")),
42  _var_name_base(getParam<std::string>("var_name_base"))
43 {
44 }
45 
46 void
48 {
49  // Loop through the number of order parameters
50  for (unsigned int op = 0; op < _op_num; op++)
51  {
52  // Create variable names
53  std::string var_name = _var_name_base + Moose::stringify(op);
54 
55  // Add the variable
56  _problem->addVariable(var_name,
57  FEType(Utility::string_to_enum<Order>(getParam<MooseEnum>("order")),
58  Utility::string_to_enum<FEFamily>(getParam<MooseEnum>("family"))),
59  getParam<Real>("scaling"));
60  }
61 }
InputParameters validParams< PolycrystalVariablesAction >()
PolycrystalVariablesAction(const InputParameters &params)