11 #include "AddVariableAction.h"
12 #include "Conversion.h"
14 #include "FEProblem.h"
15 #include "NonlinearSystemBase.h"
17 #include "libmesh/string_to_enum.h"
27 InputParameters params = validParams<Action>();
28 params.addClassDescription(
"Set up order parameter variables for a polycrystal simulation");
30 MooseEnum families(AddVariableAction::getNonlinearVariableFamilies());
31 MooseEnum orders(AddVariableAction::getNonlinearVariableOrders());
32 params.addParam<MooseEnum>(
"family",
34 "Specifies the family of FE "
35 "shape function to use for the order parameters");
36 params.addParam<MooseEnum>(
"order",
38 "Specifies the order of the FE "
39 "shape function to use for the order parameters");
40 params.addParam<
bool>(
43 "Take the initial condition of all polycrystal variables from the mesh file");
44 params.addParam<Real>(
"scaling", 1.0,
"Specifies a scaling factor to apply to this variable");
45 params.addRequiredParam<
unsigned int>(
"op_num",
46 "specifies the number of order parameters to create");
47 params.addRequiredParam<std::string>(
"var_name_base",
"specifies the base name of the variables");
53 _op_num(getParam<unsigned int>(
"op_num")),
54 _var_name_base(getParam<std::string>(
"var_name_base"))
62 bool initial_from_file = getParam<bool>(
"initial_from_file");
65 for (
unsigned int op = 0; op <
_op_num; op++)
71 if (_current_task ==
"add_variable")
73 auto fe_type = AddVariableAction::feType(_pars);
74 auto type = AddVariableAction::determineType(fe_type, 1);
75 auto var_params = _factory.getValidParams(type);
77 var_params.applySpecificParameters(_pars, {
"order",
"family"});
78 var_params.set<std::vector<Real>>(
"scaling") = {_pars.get<Real>(
"scaling")};
79 _problem->addVariable(type, var_name, var_params);
83 if (initial_from_file)
85 if (_current_task ==
"check_copy_nodal_vars")
86 _app.setFileRestart() =
true;
88 if (_current_task ==
"copy_nodal_vars")
90 auto * system = &_problem->getNonlinearSystemBase();
91 system->addVariableToCopy(var_name, var_name,
"LATEST");