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 
17 {
19  params.addClassDescription("Random initial condition for a polycrystalline material");
20  params.addRequiredParam<unsigned int>("op_num", "Number of order parameters");
21  params.addRequiredParam<unsigned int>("op_index", "The index for the current order parameter");
22  params.addRequiredParam<unsigned int>("random_type", "Type of random grain structure");
23  return params;
24 }
25 
27  : RandomICBase(parameters),
28  _op_num(getParam<unsigned int>("op_num")),
29  _op_index(getParam<unsigned int>("op_index")),
30  _random_type(getParam<unsigned int>("random_type"))
31 {
32 }
33 
34 Real
36 {
37  Real val = generateRandom();
38 
39  switch (_random_type)
40  {
41  case 0: // Continuously random
42  return val;
43 
44  case 1: // Discretely random
45  {
46  unsigned int rndind = _op_num * val;
47 
48  if (rndind == _op_index)
49  return 1.0;
50  else
51  return 0.0;
52  }
53  }
54 
55  paramError("random_type", "Bad type passed in PolycrystalRandomIC");
56 }
const unsigned int _op_num
Real generateRandom()
registerMooseObject("PhaseFieldApp", PolycrystalRandomIC)
void addRequiredParam(const std::string &name, const std::string &doc_string)
Random initial condition for a polycrystalline material.
PolycrystalRandomIC(const InputParameters &parameters)
void paramError(const std::string &param, Args... args) const
const unsigned int _random_type
const unsigned int _op_index
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
virtual Real value(const Point &p)
static InputParameters validParams()
void ErrorVector unsigned int
static InputParameters validParams()