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