https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PolycrystalKernelAction.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
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
15registerMooseAction("PhaseFieldApp", PolycrystalKernelAction, "add_kernel");
16
19{
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("coupled_variables",
38 "Vector of nonlinear variable arguments that L depends on");
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
50void
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;
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;
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 double v
registerMooseAction("PhaseFieldApp", PolycrystalKernelAction, "add_kernel")
void ErrorVector unsigned int
static InputParameters validParams()
std::shared_ptr< FEProblemBase > & _problem
InputParameters getValidParams(const std::string &name) const
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
void addCoupledVar(const std::string &name, const std::string &doc_string)
void applyParameters(const InputParameters &common, const std::vector< std::string > &exclude={}, const bool allow_private=false)
const InputParameters & parameters() const
bool isParamValid(const std::string &name) const
Factory & _factory
Action that sets up ACGrGrPoly, ACInterface, TimeDerivative, and ACGBPoly kernels.
static InputParameters validParams()
const std::string _var_name_base
base name for the order parameter variables
PolycrystalKernelAction(const InputParameters &params)
const unsigned int _op_num
number of grains to create
std::string stringify(const T &t)