www.mooseframework.org
EulerAngleFileReader.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 #include "EulerAngleFileReader.h"
8 
9 #include <fstream>
10 
11 template <>
12 InputParameters
14 {
15  InputParameters params = validParams<EulerAngleProvider>();
16  params.addClassDescription("Read Euler angle data from a file and provide it to other objects.");
17  params.addRequiredParam<FileName>("file_name", "Euler angle data file name");
18  return params;
19 }
20 
21 EulerAngleFileReader::EulerAngleFileReader(const InputParameters & params)
22  : EulerAngleProvider(params), _file_name(getParam<FileName>("file_name"))
23 {
24  readFile();
25 }
26 
27 unsigned int
29 {
30  return _angles.size();
31 }
32 
33 const EulerAngles &
35 {
36  mooseAssert(i < getGrainNum(), "Requesting Euler angles for an invalid grain id");
37  return _angles[i];
38 }
39 
40 void
42 {
43  // Read in Euler angles from _file_name
44  std::ifstream inFile(_file_name.c_str());
45  if (!inFile)
46  mooseError("Can't open ", _file_name);
47 
48  // Skip first 4 lines
49  for (unsigned int i = 0; i < 4; ++i)
50  inFile.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
51 
52  // The angle files contain a fourth column with weights that we ignore in this version
53  Real weight;
54 
55  // Loop over grains
56  EulerAngles a;
57  while (inFile >> a.phi1 >> a.Phi >> a.phi2 >> weight)
58  _angles.push_back(EulerAngles(a));
59 }
EulerAngleFileReader(const InputParameters &parameters)
InputParameters validParams< EulerAngleFileReader >()
virtual unsigned int getGrainNum() const
InputParameters validParams< EulerAngleProvider >()
virtual const EulerAngles & getEulerAngles(unsigned int) const
Euler angle triplet.
Definition: EulerAngles.h:20
Abstract base class for user objects that implement the Euler Angle provider interface.
std::vector< EulerAngles > _angles