www.mooseframework.org
BicrystalCircleGrainICAction.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 /****************************************************************/
8 #include "Factory.h"
9 #include "FEProblem.h"
10 #include "Conversion.h"
11 
12 template <>
13 InputParameters
15 {
16  InputParameters params = validParams<Action>();
17  params.addClassDescription("Bicrystal with a circular grain and an embedding outer grain");
18  params.addRequiredParam<std::string>("var_name_base", "specifies the base name of the variables");
19  params.addRequiredParam<unsigned int>("op_num", "Number of grains, should be 2");
20  params.addRequiredParam<Real>("radius", "Void radius");
21  params.addRequiredParam<Real>("x", "The x coordinate of the circle grain center");
22  params.addRequiredParam<Real>("y", "The y coordinate of the circle grain center");
23  params.addParam<Real>("z", 0.0, "The z coordinate of the circle grain center");
24  params.addParam<Real>(
25  "int_width", 0.0, "The interfacial width of the void surface. Defaults to sharp interface");
26  params.addParam<bool>(
27  "3D_sphere", true, "in 3D, whether the smaller grain is a spheres or columnar grain");
28  return params;
29 }
30 
32  : Action(params),
33  _var_name_base(getParam<std::string>("var_name_base")),
34  _op_num(getParam<unsigned int>("op_num")),
35  _radius(getParam<Real>("radius")),
36  _x(getParam<Real>("x")),
37  _y(getParam<Real>("y")),
38  _z(getParam<Real>("z")),
39  _int_width(getParam<Real>("int_width")),
40  _3D_sphere(getParam<bool>("3D_sphere"))
41 {
42  if (_op_num != 2)
43  mooseError("op_num must equal 2 for bicrystal ICs");
44 }
45 
46 void
48 {
49  // Loop through the number of order parameters
50  for (unsigned int op = 0; op < _op_num; op++)
51  {
52  // Create variable names
53  std::string var_name = _var_name_base + Moose::stringify(op);
54 
55  // Set parameters for SmoothCircleIC
56  InputParameters poly_params = _factory.getValidParams("SmoothCircleIC");
57  poly_params.set<VariableName>("variable") = var_name;
58  poly_params.set<Real>("x1") = _x;
59  poly_params.set<Real>("y1") = _y;
60  poly_params.set<Real>("z1") = _z;
61  poly_params.set<Real>("radius") = _radius;
62  poly_params.set<Real>("int_width") = _int_width;
63  poly_params.set<bool>("3D_spheres") = _3D_sphere;
64  if (op == 0)
65  {
66  // Values for circle grain
67  poly_params.set<Real>("invalue") = 1.0;
68  poly_params.set<Real>("outvalue") = 0.0;
69  }
70  else
71  {
72  // Values for matrix grain
73  poly_params.set<Real>("invalue") = 0.0;
74  poly_params.set<Real>("outvalue") = 1.0;
75  }
76 
77  // Add initial condition
78  _problem->addInitialCondition(
79  "SmoothCircleIC", "BicrystalCircleGrainIC_" + Moose::stringify(op), poly_params);
80  }
81 }
InputParameters validParams< BicrystalCircleGrainICAction >()
BicrystalCircleGrainICAction(const InputParameters &params)