www.mooseframework.org
RandomEulerAngleProvider.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 /****************************************************************/
9 
10 template <>
11 InputParameters
13 {
14  InputParameters params = validParams<EulerAngleProvider>();
15  params.addClassDescription("Assign random euler angles for each grain.");
16  params.addRequiredParam<UserObjectName>("grain_tracker_object",
17  "The FeatureFloodCount UserObject to get values from.");
18  params.addParam<unsigned int>("seed", 0, "Seed value for the random number generator");
19  return params;
20 }
21 
23  : EulerAngleProvider(params),
24  _grain_tracker(getUserObject<GrainTrackerInterface>("grain_tracker_object")),
25  _angles(0)
26 {
27  _random.seed(0, getParam<unsigned int>("seed"));
28 }
29 
30 void
32 {
33  EulerAngles angle;
34  auto grain_num = _grain_tracker.getTotalFeatureCount();
35  for (auto i = _angles.size(); i < grain_num; ++i)
36  {
37  angle.random(_random);
38  _angles.push_back(angle);
39  }
40 }
41 
42 unsigned int
44 {
45  return _angles.size();
46 }
47 
48 const EulerAngles &
50 {
51  mooseAssert(i < getGrainNum(), "Requesting Euler angles for an invalid grain id");
52  return _angles[i];
53 }
virtual void initialize() override
virtual unsigned int getGrainNum() const override
This class defines the interface for the GrainTracking objects.
virtual std::size_t getTotalFeatureCount() const =0
Returns a number large enough to contain the largest ID for all grains in use.
InputParameters validParams< RandomEulerAngleProvider >()
InputParameters validParams< EulerAngleProvider >()
void random()
Definition: EulerAngles.C:12
RandomEulerAngleProvider(const InputParameters &parameters)
virtual const EulerAngles & getEulerAngles(unsigned int) const override
Euler angle triplet.
Definition: EulerAngles.h:20
Abstract base class for user objects that implement the Euler Angle provider interface.
std::vector< EulerAngles > _angles
const GrainTrackerInterface & _grain_tracker