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