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