www.mooseframework.org
PolycrystalRandomIC.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 
8 #include "PolycrystalRandomIC.h"
9 #include "MooseRandom.h"
10 
11 template <>
12 InputParameters
14 {
15  InputParameters params = validParams<InitialCondition>();
16  params.addClassDescription("Random initial condition for a polycrystalline material");
17  params.addRequiredParam<unsigned int>("op_num", "Number of order parameters");
18  params.addRequiredParam<unsigned int>("op_index", "The index for the current order parameter");
19  params.addRequiredParam<unsigned int>(
20  "typ", "Type of random grain structure"); // TODO: this should be called "type"!
21  return params;
22 }
23 
24 PolycrystalRandomIC::PolycrystalRandomIC(const InputParameters & parameters)
25  : InitialCondition(parameters),
26  _op_num(getParam<unsigned int>("op_num")),
27  _op_index(getParam<unsigned int>("op_index")),
28  _typ(getParam<unsigned int>("typ"))
29 {
30 }
31 
32 Real
34 {
35  Point cur_pos = p;
36  Real val = MooseRandom::rand();
37 
38  switch (_typ)
39  {
40  case 0: // Continuously random
41  return val;
42 
43  case 1: // Discretely random
44  {
45  unsigned int rndind = _op_num * val;
46 
47  if (rndind == _op_index)
48  return 1.0;
49  else
50  return 0.0;
51  }
52  }
53 
54  mooseError("Bad type passed in PolycrystalRandomIC");
55 }
const unsigned int _op_num
PolycrystalRandomIC(const InputParameters &parameters)
InputParameters validParams< PolycrystalRandomIC >()
const unsigned int _op_index
const unsigned int _typ
virtual Real value(const Point &p)