www.mooseframework.org
BicrystalBoundingBoxICAction.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", BicrystalBoundingBoxICAction, "add_ic");
16 
17 template <>
18 InputParameters
20 {
21  InputParameters params = validParams<Action>();
22  params.addClassDescription("Constructs a bicrystal, where one grain is on the inside of "
23  "the box and the other grain is the outside of the box");
24  params.addRequiredParam<std::string>("var_name_base", "specifies the base name of the variables");
25  params.addRequiredParam<unsigned int>("op_num", "Number of grains, should be 2");
26  params.addRequiredParam<Real>("x1", "The x coordinate of the lower left-hand corner of the box");
27  params.addRequiredParam<Real>("y1", "The y coordinate of the lower left-hand corner of the box");
28  params.addParam<Real>("z1", 0.0, "The z coordinate of the lower left-hand corner of the box");
29  params.addRequiredParam<Real>("x2", "The x coordinate of the upper right-hand corner of the box");
30  params.addRequiredParam<Real>("y2", "The y coordinate of the upper right-hand corner of the box");
31  params.addParam<Real>("z2", 0.0, "The z coordinate of the upper right-hand corner of the box");
32  return params;
33 }
34 
36  : Action(params),
37  _var_name_base(getParam<std::string>("var_name_base")),
38  _op_num(getParam<unsigned int>("op_num"))
39 {
40  if (_op_num != 2)
41  paramError("op_num", "Must equal 2 for bicrystal ICs");
42 }
43 
44 void
46 {
47 #ifdef DEBUG
48  Moose::err << "Inside the BicrystalBoundingBoxICAction Object\n";
49 #endif
50 
51  // Loop through the number of order parameters
52  for (unsigned int op = 0; op < _op_num; ++op)
53  {
54  // Create variable names
55  const std::string var_name = _var_name_base + Moose::stringify(op);
56 
57  // Set parameters for BoundingBoxIC
58  InputParameters poly_params = _factory.getValidParams("BoundingBoxIC");
59  poly_params.applyParameters(parameters());
60  poly_params.set<VariableName>("variable") = var_name;
61  if (op == 0)
62  {
63  // Values for bounding box grain
64  poly_params.set<Real>("inside") = 1.0;
65  poly_params.set<Real>("outside") = 0.0;
66  }
67  else
68  {
69  // Values for matrix grain
70  poly_params.set<Real>("inside") = 0.0;
71  poly_params.set<Real>("outside") = 1.0;
72  }
73 
74  // Add initial condition
75  _problem->addInitialCondition(
76  "BoundingBoxIC", "BicrystalBoundingBoxIC_" + Moose::stringify(op), poly_params);
77  }
78 }
BicrystalBoundingBoxICAction
Bicrystal using a bounding box.
Definition: BicrystalBoundingBoxICAction.h:18
BicrystalBoundingBoxICAction::_var_name_base
const std::string _var_name_base
Definition: BicrystalBoundingBoxICAction.h:26
BicrystalBoundingBoxICAction::act
virtual void act()
Definition: BicrystalBoundingBoxICAction.C:45
BicrystalBoundingBoxICAction.h
registerMooseAction
registerMooseAction("PhaseFieldApp", BicrystalBoundingBoxICAction, "add_ic")
BicrystalBoundingBoxICAction::_op_num
const unsigned int _op_num
Definition: BicrystalBoundingBoxICAction.h:27
BicrystalBoundingBoxICAction::BicrystalBoundingBoxICAction
BicrystalBoundingBoxICAction(const InputParameters &params)
Definition: BicrystalBoundingBoxICAction.C:35
validParams< BicrystalBoundingBoxICAction >
InputParameters validParams< BicrystalBoundingBoxICAction >()
Definition: BicrystalBoundingBoxICAction.C:19