www.mooseframework.org
BicrystalBoundingBoxICAction.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 using a bounding box");
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>("x1", "The x coordinate of the lower left-hand corner of the box");
21  params.addRequiredParam<Real>("y1", "The y coordinate of the lower left-hand corner of the box");
22  params.addParam<Real>("z1", 0.0, "The z coordinate of the lower left-hand corner of the box");
23  params.addRequiredParam<Real>("x2", "The x coordinate of the upper right-hand corner of the box");
24  params.addRequiredParam<Real>("y2", "The y coordinate of the upper right-hand corner of the box");
25  params.addParam<Real>("z2", 0.0, "The z coordinate of the upper right-hand corner of the box");
26  return params;
27 }
28 
30  : Action(params),
31  _var_name_base(getParam<std::string>("var_name_base")),
32  _op_num(getParam<unsigned int>("op_num"))
33 {
34  if (_op_num != 2)
35  mooseError("op_num must equal 2 for bicrystal ICs");
36 }
37 
38 void
40 {
41 #ifdef DEBUG
42  Moose::err << "Inside the BicrystalBoundingBoxICAction Object\n";
43 #endif
44 
45  // Loop through the number of order parameters
46  for (unsigned int op = 0; op < _op_num; ++op)
47  {
48  // Create variable names
49  const std::string var_name = _var_name_base + Moose::stringify(op);
50 
51  // Set parameters for BoundingBoxIC
52  InputParameters poly_params = _factory.getValidParams("BoundingBoxIC");
53  poly_params.applyParameters(parameters());
54  poly_params.set<VariableName>("variable") = var_name;
55  if (op == 0)
56  {
57  // Values for bounding box
58  poly_params.set<Real>("inside") = 1.0;
59  poly_params.set<Real>("outside") = 0.0;
60  }
61  else
62  {
63  // Values for matrix grain
64  poly_params.set<Real>("inside") = 0.0;
65  poly_params.set<Real>("outside") = 1.0;
66  }
67 
68  // Add initial condition
69  _problem->addInitialCondition(
70  "BoundingBoxIC", "BicrystalBoundingBoxIC_" + Moose::stringify(op), poly_params);
71  }
72 }
BicrystalBoundingBoxICAction(const InputParameters &params)
InputParameters validParams< BicrystalBoundingBoxICAction >()