Go to the documentation of this file.
23 #include "libmesh/libmesh.h"
24 #include "libmesh/exodusII_io.h"
25 #include "libmesh/equation_systems.h"
26 #include "libmesh/nonlinear_implicit_system.h"
27 #include "libmesh/explicit_system.h"
28 #include "libmesh/string_to_enum.h"
41 params.set<std::string>(
"type") =
"MooseVariableBase";
47 "family", families,
"Specifies the family of FE shape functions to use for this variable");
50 "Specifies the order of the FE shape function to use "
51 "for this variable (additional orders not listed are "
53 params.addParam<std::vector<Real>>(
"scaling",
54 "Specifies a scaling factor to apply to this variable");
60 _fe_type(feType(params)),
61 _scalar_var(_fe_type.family == SCALAR),
69 return MooseEnum(
"LAGRANGE MONOMIAL HERMITE SCALAR HIERARCHIC CLOUGH XYZ SZABAB BERNSTEIN "
70 "L2_LAGRANGE L2_HIERARCHIC NEDELEC_ONE LAGRANGE_VEC MONOMIAL_VEC",
77 return MooseEnum(
"CONSTANT FIRST SECOND THIRD FOURTH",
"FIRST",
true);
83 return {Utility::string_to_enum<Order>(params.get<
MooseEnum>(
"order")),
84 Utility::string_to_enum<FEFamily>(params.get<
MooseEnum>(
"family"))};
92 mooseError(
"There must be at least one variable component, but somehow 0 has been specified");
105 mooseError(
"Both the MooseVariable* and Add*VariableAction parameters objects have had the "
106 "`family` parameter set, and they are different values: ",
110 " respectively. I don't know how you achieved this, but you need to rectify it.");
114 mooseError(
"Both the MooseVariable* and Add*VariableAction parameters objects have had the "
115 "`order` parameter set, and they are different values: ",
119 " respectively. I don't know how you achieved this, but you need to rectify it.");
122 _pars.get<std::vector<Real>>(
"scaling") !=
124 mooseError(
"Both the MooseVariable* and Add*VariableAction parameters objects have had the "
125 "`scaling` parameter set, and they are different values. I don't know how you "
126 "achieved this, but you need to rectify it.");
145 std::string var_name =
name();
157 std::string var_name =
name();
160 std::string long_name(
"");
161 long_name += var_name;
162 long_name +=
"_moose";
169 action_params.
set<std::string>(
"type") =
"ScalarConstantIC";
171 action_params.
set<std::string>(
"type") =
"ConstantIC";
173 action_params.
set<std::string>(
"type") =
"ArrayConstantIC";
176 std::shared_ptr<MooseObjectAction> action = std::static_pointer_cast<MooseObjectAction>(
180 action->getObjectParams().set<VariableName>(
"variable") = var_name;
183 mooseError(
"Size of 'initial_condition' is not consistent");
192 action->getObjectParams().set<Real>(
"value") = value[0];
203 if (fe_type.family == LAGRANGE_VEC || fe_type.family == NEDELEC_ONE ||
204 fe_type.family == MONOMIAL_VEC)
205 mooseError(
"Vector finite element families do not currently have ArrayVariable support");
207 return "ArrayMooseVariable";
209 else if (fe_type == FEType(0, MONOMIAL))
210 return "MooseVariableConstMonomial";
211 else if (fe_type.family == SCALAR)
212 return "MooseVariableScalar";
213 else if (fe_type.family == LAGRANGE_VEC || fe_type.family == NEDELEC_ONE ||
214 fe_type.family == MONOMIAL_VEC)
215 return "VectorMooseVariable";
217 return "MooseVariable";
228 mooseError(
"Size of 'scaling' is not consistent");
239 std::set<SubdomainID>
243 std::set<SubdomainID> blocks;
244 std::vector<SubdomainName> block_param =
246 for (
const auto & subdomain_name : block_param)
249 blocks.insert(blk_id);
virtual void addVariable(const std::string &var_type, const std::string &var_name, InputParameters ¶ms)
Canonical method for adding a non-linear variable.
InputParameters getValidParams(const std::string &name)
std::set< SubdomainID > getSubdomainIDs()
Get the block ids from the input parameters.
FEType _fe_type
FEType for the variable being created.
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
static std::string determineType(const FEType &fe_type, unsigned int components)
determine the variable type given an FEType and number of components
registerMooseAction("MooseApp", AddVariableAction, "add_variable")
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
defineLegacyParams(AddVariableAction)
void addActionBlock(std::shared_ptr< Action > blk)
This method add an Action instance to the warehouse.
const std::string & name() const
The name of the action.
ActionFactory & _action_factory
Builds Actions.
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
static MooseEnum getNonlinearVariableOrders()
Get the possible variable orders.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
static InputParameters validParams()
Storage for action instances.
std::shared_ptr< Action > create(const std::string &action, const std::string &action_name, InputParameters ¶meters)
static MooseEnum getNonlinearVariableFamilies()
Get the possible variable families.
unsigned int _components
Number of components for an array variable.
std::string _type
The Object type that is being created.
InputParameters _moose_object_pars
The parameters for the object to be created.
std::string _name
The name of the action.
InputParameters _pars
Input parameters for the action.
subdomain_id_type SubdomainID
void addVariable(const std::string &var_name)
Adds a nonlinear variable to the system.
static FEType feType(const InputParameters ¶ms)
determine the FEType by examining family and order in the provided parameters
virtual void init()
Initialize the action's member variables.
Eigen::Matrix< Real, Eigen::Dynamic, 1 > RealEigenVector
ActionWarehouse & _awh
Reference to ActionWarehouse where we store object build by actions.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual void markEigenVariable(const VariableName &var_name)
Mark a variable as a variable of the eigen system.
bool _scalar_var
True if the variable being created is a scalar.
std::function< void(FEProblemBase &, const std::string &, const std::string &, InputParameters &)> _problem_add_var_method
void createInitialConditionAction()
Create the action to generate the InitialCondition object.
static InputParameters validParams()
Class constructor.
AddVariableAction(InputParameters params)