www.mooseframework.org
Tricrystal2CircleGrainsIC.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 /****************************************************************/
7 
9 #include "MooseRandom.h"
10 #include "MooseMesh.h"
11 
12 template <>
13 InputParameters
15 {
16  InputParameters params = validParams<InitialCondition>();
17  params.addClassDescription("Tricrystal with two circles/bubbles");
18  params.addRequiredParam<unsigned int>("op_num", "Number of grain order parameters");
19  params.addRequiredParam<unsigned int>("op_index", "Index for the current grain order parameter");
20  return params;
21 }
22 
23 Tricrystal2CircleGrainsIC::Tricrystal2CircleGrainsIC(const InputParameters & parameters)
24  : InitialCondition(parameters),
25  _mesh(_fe_problem.mesh()),
26  _op_num(getParam<unsigned int>("op_num")),
27  _op_index(getParam<unsigned int>("op_index"))
28 {
29  if (_op_num != 3)
30  mooseError("Tricrystal ICs must have op_num = 3");
31 
32  // Set up domain bounds with mesh tools
33  for (unsigned int i = 0; i < LIBMESH_DIM; i++)
34  {
35  _bottom_left(i) = _mesh.getMinInDimension(i);
36  _top_right(i) = _mesh.getMaxInDimension(i);
37  }
39 }
40 
41 Real
43 {
44  Point grain_center_left;
45  grain_center_left(0) = _bottom_left(0) + _range(0) / 4.0;
46  grain_center_left(1) = _bottom_left(1) + _range(1) / 2.0;
47  grain_center_left(2) = _bottom_left(2) + _range(2) / 2.0;
48 
49  Point grain_center_right;
50  grain_center_right(0) = _bottom_left(0) + _range(0) * 3.0 / 4.0;
51  grain_center_right(1) = _bottom_left(1) + _range(1) / 2.0;
52  grain_center_right(2) = _bottom_left(2) + _range(2) / 2.0;
53 
54  Real radius = _range(0) / 5.0;
55  Real dist_left = (p - grain_center_left).norm();
56  Real dist_right = (p - grain_center_right).norm();
57 
58  if ((dist_left <= radius && _op_index == 1) || (dist_right <= radius && _op_index == 2) ||
59  (dist_left > radius && dist_right > radius && _op_index == 0))
60  return 1.0;
61  else
62  return 0.0;
63 }
virtual Real value(const Point &p)
InputParameters validParams< Tricrystal2CircleGrainsIC >()
Tricrystal2CircleGrainsIC(const InputParameters &parameters)