https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PolycrystalRandomIC.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
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
34Real
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}
registerMooseObject("PhaseFieldApp", PolycrystalRandomIC)
void ErrorVector unsigned int
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void paramError(const std::string &param, Args... args) const
Random initial condition for a polycrystalline material.
const unsigned int _op_num
const unsigned int _op_index
PolycrystalRandomIC(const InputParameters &parameters)
const unsigned int _random_type
static InputParameters validParams()
virtual Real value(const Point &p)
static InputParameters validParams()
Real generateRandom()