www.mooseframework.org
PolycrystalKernelAction.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 "Factory.h"
9 #include "Conversion.h"
10 #include "FEProblem.h"
11 
12 template <>
13 InputParameters
15 {
16  InputParameters params = validParams<Action>();
17  params.addClassDescription(
18  "Set up ACGrGrPoly, ACInterface, TimeDerivative, and ACGBPoly kernels");
19  params.addRequiredParam<unsigned int>(
20  "op_num", "specifies the total number of grains (deformed + recrystallized) to create");
21  params.addRequiredParam<std::string>("var_name_base", "specifies the base name of the variables");
22  params.addParam<VariableName>("c", "Name of coupled concentration variable");
23  params.addParam<Real>("en_ratio", 1.0, "Ratio of surface to GB energy");
24  params.addParam<unsigned int>("ndef", 0, "specifies the number of deformed grains to create");
25  params.addParam<bool>("implicit", true, "Whether kernels are implicit or not");
26  params.addParam<bool>(
27  "use_displaced_mesh", false, "Whether to use displaced mesh in the kernels");
28  params.addParam<bool>("variable_mobility",
29  true,
30  "The mobility is a function of any MOOSE variable (if "
31  "this is set to false, L must be constant over the "
32  "entire domain!)");
33  params.addParam<std::vector<VariableName>>("args", "Vector of variable arguments L depends on");
34  return params;
35 }
36 
37 PolycrystalKernelAction::PolycrystalKernelAction(const InputParameters & params)
38  : Action(params),
39  _op_num(getParam<unsigned int>("op_num")),
40  _var_name_base(getParam<std::string>("var_name_base"))
41 {
42 }
43 
44 void
46 {
47  for (unsigned int op = 0; op < _op_num; ++op)
48  {
49  //
50  // Create variable names
51  //
52 
53  std::string var_name = _var_name_base + Moose::stringify(op);
54  std::vector<VariableName> v;
55  v.resize(_op_num - 1);
56 
57  unsigned int ind = 0;
58  for (unsigned int j = 0; j < _op_num; ++j)
59  if (j != op)
60  v[ind++] = _var_name_base + Moose::stringify(j);
61 
62  //
63  // Set up ACGrGrPoly kernels
64  //
65 
66  {
67  InputParameters params = _factory.getValidParams("ACGrGrPoly");
68  params.set<NonlinearVariableName>("variable") = var_name;
69  params.set<std::vector<VariableName>>("v") = v;
70  params.applyParameters(parameters());
71 
72  std::string kernel_name = "ACBulk_" + var_name;
73  _problem->addKernel("ACGrGrPoly", kernel_name, params);
74  }
75 
76  //
77  // Set up ACInterface kernels
78  //
79 
80  {
81  InputParameters params = _factory.getValidParams("ACInterface");
82  params.set<NonlinearVariableName>("variable") = var_name;
83  params.applyParameters(parameters());
84 
85  std::string kernel_name = "ACInt_" + var_name;
86  _problem->addKernel("ACInterface", kernel_name, params);
87  }
88 
89  //
90  // Set up TimeDerivative kernels
91  //
92 
93  {
94  InputParameters params = _factory.getValidParams("TimeDerivative");
95  params.set<NonlinearVariableName>("variable") = var_name;
96  params.set<bool>("implicit") = true;
97  params.applyParameters(parameters());
98 
99  std::string kernel_name = "IE_" + var_name;
100  _problem->addKernel("TimeDerivative", kernel_name, params);
101  }
102 
103  //
104  // Set up optional ACGBPoly bubble interaction kernels
105  //
106 
107  if (isParamValid("c"))
108  {
109  InputParameters params = _factory.getValidParams("ACGBPoly");
110  params.set<NonlinearVariableName>("variable") = var_name;
111  params.set<std::vector<VariableName>>("c") = {getParam<VariableName>("c")};
112  params.applyParameters(parameters());
113 
114  std::string kernel_name = "ACBubInteraction_" + var_name;
115  _problem->addKernel("ACGBPoly", kernel_name, params);
116  }
117  }
118 }
InputParameters validParams< PolycrystalKernelAction >()
const unsigned int _op_num
number of grains to create
PolycrystalKernelAction(const InputParameters &params)
const std::string _var_name_base
base name for the order parameter variables