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