21 #include "libmesh/string_to_enum.h" 37 "Set up the variable and the kernels needed for a grain growth simulation");
39 "specifies the number of order parameters to create");
40 params.
addRequiredParam<std::string>(
"var_name_base",
"specifies the base name of the variables");
42 "scaling", 1.0,
"Specifies a scaling factor to apply to the order parameters");
46 "Take the initial condition of all polycrystal variables from the mesh file");
53 "Specifies the family of FE " 54 "shape function to use for the order parameters");
57 "Specifies the order of the FE " 58 "shape function to use for the order parameters");
60 params.
addParam<MaterialPropertyName>(
61 "mobility",
"L",
"The isotropic mobility used with the kernels");
62 params.
addParam<MaterialPropertyName>(
"kappa",
"kappa_op",
"The kappa used with the kernels");
64 params.
addParam<VariableName>(
"c",
"Name of coupled concentration variable");
66 params.
addParam<
Real>(
"en_ratio", 1.0,
"Ratio of surface to GB energy");
67 params.
addParam<
unsigned int>(
"ndef", 0,
"Specifies the number of deformed grains to create");
68 params.
addParam<
bool>(
"variable_mobility",
70 "The mobility is a function of any MOOSE variable (if " 71 "this is set to false, L must be constant over the " 73 params.
addCoupledVar(
"args",
"Vector of nonlinear variable arguments that L depends on");
76 params.
addParam<
bool>(
"implicit",
true,
"Whether kernels are implicit or not");
78 "use_displaced_mesh",
false,
"Whether to use displaced mesh in the kernels");
79 params.
addParam<
bool>(
"use_automatic_differentiation",
81 "Flag to use automatic differentiation (AD) objects when possible");
82 params.
addParam<std::vector<SubdomainName>>(
83 "block", {},
"Block restriction for the variables and kernels");
93 _op_num(getParam<unsigned
int>(
"op_num")),
94 _var_name_base(getParam<
std::string>(
"var_name_base")),
97 _initial_from_file(getParam<bool>(
"initial_from_file")),
98 _use_ad(getParam<bool>(
"use_automatic_differentiation"))
109 for (
unsigned int op = 0; op <
_op_num; op++)
122 std::string kernel_type =
_use_ad ?
"ADTimeDerivative" :
"TimeDerivative";
124 std::string kernel_name = var_name +
"_" + kernel_type;
126 params.
set<NonlinearVariableName>(
"variable") = var_name;
129 _problem->addKernel(kernel_type, kernel_name, params);
137 std::string kernel_type =
_use_ad ?
"ADGrainGrowth" :
"ACGrGrPoly";
140 std::vector<VariableName>
v;
143 unsigned int ind = 0;
148 std::string kernel_name = var_name +
"_" + kernel_type;
150 params.
set<NonlinearVariableName>(
"variable") = var_name;
151 params.
set<std::vector<VariableName>>(
"v") =
v;
152 params.
set<MaterialPropertyName>(
"mob_name") = getParam<MaterialPropertyName>(
"mobility");
155 _problem->addKernel(kernel_type, kernel_name, params);
163 std::string kernel_type =
_use_ad ?
"ADACInterface" :
"ACInterface";
165 std::string kernel_name = var_name +
"_" + kernel_type;
167 params.
set<NonlinearVariableName>(
"variable") = var_name;
168 params.
set<MaterialPropertyName>(
"mob_name") = getParam<MaterialPropertyName>(
"mobility");
169 params.
set<MaterialPropertyName>(
"kappa_name") = getParam<MaterialPropertyName>(
"kappa");
170 params.
set<
bool>(
"variable_L") = getParam<bool>(
"variable_mobility");
173 _problem->addKernel(kernel_type, kernel_name, params);
183 mooseError(
"AD version of ACGBPoly is not implemented");
185 std::string kernel_type =
"ACGBPoly";
187 std::string kernel_name = var_name +
"_" + kernel_type;
189 params.
set<NonlinearVariableName>(
"variable") = var_name;
190 params.
set<std::vector<VariableName>>(
"c") = {getParam<VariableName>(
"c")};
193 _problem->addKernel(kernel_type, kernel_name, params);
205 for (
unsigned int op = 0; op <
_op_num; op++)
218 auto * system = &
_problem->getNonlinearSystemBase(0);
219 system->addVariableToCopy(var_name, var_name,
"LATEST");
229 var_params.applySpecificParameters(
_pars, {
"family",
"order",
"block"});
230 var_params.set<std::vector<Real>>(
"scaling") = {getParam<Real>(
"scaling")};
244 auto var_params =
_factory.getValidParams(
"MooseVariable");
245 var_params.set<
MooseEnum>(
"family") =
"LAGRANGE";
246 var_params.set<
MooseEnum>(
"order") =
"FIRST";
247 var_params.applySpecificParameters(
_pars, {
"block"});
248 _problem->addAuxVariable(
"MooseVariable",
"bnds", var_params);
254 std::vector<VariableName>
v;
260 std::string aux_kernel_type =
"BndsCalcAux";
262 std::string aux_kernel_name =
"bnds_" + aux_kernel_type;
264 params.
set<AuxVariableName>(
"variable") =
"bnds";
265 params.
set<std::vector<VariableName>>(
"v") =
v;
269 _problem->addAuxKernel(aux_kernel_type, aux_kernel_name, params);
const bool _use_ad
use AD objects where possible
const libMesh::FEType _fe_type
FEType for the variable being created.
void addBnds(const std::string &name_base)
const ExecFlagType EXEC_TIMESTEP_END
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...
static MooseEnum getNonlinearVariableFamilies()
const unsigned int _op_num
number of variables and variable name base for variable creation
bool isParamValid(const std::string &name) const
static InputParameters validParams()
static MooseEnum getNonlinearVariableOrders()
registerMooseAction("PhaseFieldApp", GrainGrowthAction, "add_aux_variable")
const std::string _var_name_base
void setExodusFileRestart(bool flag)
T string_to_enum(const std::string &s)
const std::string & type() const
const std::string & _current_task
static std::string variableType(const libMesh::FEType &fe_type, const bool is_fv=false, const bool is_array=false)
std::string stringify(const T &t)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string v
static InputParameters validParams()
GrainGrowthAction(const InputParameters ¶ms)
void mooseError(Args &&... args) const
const InputParameters & _pars
std::shared_ptr< FEProblemBase > & _problem
const InputParameters & parameters() const
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
void ErrorVector unsigned int
const bool _initial_from_file
Take initial values from file?
const ExecFlagType EXEC_INITIAL