www.mooseframework.org
HHPFCRFFSplitKernelAction.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 /****************************************************************/
7 
9 #include "Factory.h"
10 #include "FEProblem.h"
11 #include "Conversion.h"
12 
13 template <>
14 InputParameters
16 {
17  InputParameters params = validParams<Action>();
18  params.addClassDescription(
19  "Set up kernels for the rational function fit (RFF) phase field crystal model");
20  params.addRequiredParam<unsigned int>(
21  "num_L", "specifies the number of complex L variables will be solved for");
22  params.addRequiredParam<VariableName>("n_name", "Variable name used for the n variable");
23  params.addRequiredParam<std::string>("L_name_base", "Base name for the complex L variables");
24  params.addParam<MaterialPropertyName>("mob_name", "M", "The mobility used for n in this model");
25  MooseEnum log_options("tolerance cancelation expansion");
26  params.addRequiredParam<MooseEnum>(
27  "log_approach", log_options, "Which approach will be used to handle the natural log");
28  params.addParam<Real>("tol", 1.0e-9, "Tolerance used when the tolerance approach is chosen");
29  params.addParam<Real>(
30  "n_exp_terms", 4, "Number of terms used in the Taylor expansion of the natural log term");
31  params.addParam<bool>(
32  "use_displaced_mesh", false, "Whether to use displaced mesh in the kernels");
33  return params;
34 }
35 
37  : Action(params),
38  _num_L(getParam<unsigned int>("num_L")),
39  _L_name_base(getParam<std::string>("L_name_base")),
40  _n_name(getParam<VariableName>("n_name"))
41 {
42 }
43 
44 void
46 {
47  // Loop over the L_variables
48  for (unsigned int l = 0; l < _num_L; ++l)
49  {
50  // Create L base name
51  std::string L_name = _L_name_base + Moose::stringify(l);
52 
53  // Create real and imaginary L variable names
54  std::string real_name = L_name + "_real";
55  std::string imag_name = L_name + "_imag";
56 
57  //
58  // Create the kernels for the real L variable
59  //
60 
61  // Create the diffusion kernel for L_real_l
62  InputParameters poly_params = _factory.getValidParams("Diffusion");
63  poly_params.set<NonlinearVariableName>("variable") = real_name;
64  poly_params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
65  _problem->addKernel("Diffusion", "diff_" + real_name, poly_params);
66 
67  // Create the (alpha^R_m L^R_m) term
68  poly_params = _factory.getValidParams("HHPFCRFF");
69  poly_params.set<NonlinearVariableName>("variable") = real_name;
70  poly_params.set<bool>("positive") = true;
71  poly_params.set<MaterialPropertyName>("prop_name") = "alpha_R_" + Moose::stringify(l);
72  poly_params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
73  _problem->addKernel("HHPFCRFF", "HH1_" + real_name, poly_params);
74 
75  // **Create the -(alpha^I_m L^I_m) term
76  if (l > 0)
77  {
78  poly_params = _factory.getValidParams("HHPFCRFF");
79  poly_params.set<NonlinearVariableName>("variable") = real_name;
80  poly_params.set<bool>("positive") = false;
81  poly_params.set<std::vector<VariableName>>("coupled_var").push_back(imag_name);
82  poly_params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
83  poly_params.set<MaterialPropertyName>("prop_name") = "alpha_I_" + Moose::stringify(l);
84  _problem->addKernel("HHPFCRFF", "HH2_" + real_name, poly_params);
85  }
86 
87  // **Create the -(A^R_m n) term
88  poly_params = _factory.getValidParams("HHPFCRFF");
89  poly_params.set<NonlinearVariableName>("variable") = real_name;
90  poly_params.set<bool>("positive") = false;
91  poly_params.set<std::vector<VariableName>>("coupled_var").push_back(_n_name);
92  poly_params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
93  poly_params.set<MaterialPropertyName>("prop_name") = "A_R_" + Moose::stringify(l);
94  _problem->addKernel("HHPFCRFF", "HH3_" + real_name, poly_params);
95 
96  //
97  // Create the kernels for the imaginary L variable, l > 0
98  //
99  if (l > 0)
100  {
101  // Create the diffusion kernel for L_imag_l
102  InputParameters poly_params = _factory.getValidParams("Diffusion");
103  poly_params.set<NonlinearVariableName>("variable") = imag_name;
104  poly_params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
105  _problem->addKernel("Diffusion", "diff_" + imag_name, poly_params);
106 
107  // **Create the (alpha^R_m L^I_m) term
108  poly_params = _factory.getValidParams("HHPFCRFF");
109  poly_params.set<NonlinearVariableName>("variable") = imag_name;
110  poly_params.set<bool>("positive") = true;
111  poly_params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
112  poly_params.set<MaterialPropertyName>("prop_name") = "alpha_R_" + Moose::stringify(l);
113  _problem->addKernel("HHPFCRFF", "HH1_" + imag_name, poly_params);
114 
115  // **Create the (alpha^I_m L^R_m) term
116  poly_params = _factory.getValidParams("HHPFCRFF");
117  poly_params.set<NonlinearVariableName>("variable") = imag_name;
118  poly_params.set<bool>("positive") = true;
119  poly_params.set<std::vector<VariableName>>("coupled_var").push_back(real_name);
120  poly_params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
121  poly_params.set<MaterialPropertyName>("prop_name") = "alpha_I_" + Moose::stringify(l);
122  _problem->addKernel("HHPFCRFF", "HH2_" + imag_name, poly_params);
123 
124  // **Create the -(A^I_m n) term
125  poly_params = _factory.getValidParams("HHPFCRFF");
126  poly_params.set<NonlinearVariableName>("variable") = imag_name;
127  poly_params.set<bool>("positive") = false;
128  poly_params.set<std::vector<VariableName>>("coupled_var").push_back(_n_name);
129  poly_params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
130  poly_params.set<MaterialPropertyName>("prop_name") = "A_I_" + Moose::stringify(l);
131  _problem->addKernel("HHPFCRFF", "HH3_" + imag_name, poly_params);
132  }
133  }
134 }
HHPFCRFFSplitKernelAction(const InputParameters &params)
InputParameters validParams< HHPFCRFFSplitKernelAction >()