https://mooseframework.inl.gov
EulerAngleFileReader.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 "EulerAngleFileReader.h"
11 
12 #include <fstream>
13 
14 registerMooseObject("SolidMechanicsApp", EulerAngleFileReader);
15 
18 {
20  params.addClassDescription("Read Euler angle data from a file and provide it to other objects.");
21  params.addRequiredParam<FileName>("file_name", "Euler angle data file name");
22  return params;
23 }
24 
26  : EulerAngleProvider(params), _file_name(getParam<FileName>("file_name"))
27 {
28  readFile();
29 }
30 
31 unsigned int
33 {
34  return _angles.size();
35 }
36 
37 const EulerAngles &
39 {
40  mooseAssert(i < getGrainNum(), "Requesting Euler angles for an invalid grain id");
41  return _angles[i];
42 }
43 
44 void
46 {
47  // Read in Euler angles from _file_name
48  std::ifstream inFile(_file_name.c_str());
49  if (!inFile)
50  mooseError("Can't open ", _file_name);
51 
52  // Skip first 4 lines
53  for (unsigned int i = 0; i < 4; ++i)
54  inFile.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
55 
56  // The angle files contain a fourth column with weights that we ignore in this version
57  Real weight;
58 
59  // Loop over grains
60  EulerAngles a;
61  while (inFile >> a.phi1 >> a.Phi >> a.phi2 >> weight)
62  _angles.push_back(EulerAngles(a));
63 }
EulerAngleFileReader(const InputParameters &parameters)
virtual unsigned int getGrainNum() const
virtual const EulerAngles & getEulerAngles(unsigned int) const
void addRequiredParam(const std::string &name, const std::string &doc_string)
static InputParameters validParams()
dof_id_type weight(const MeshBase &mesh, const processor_id_type pid)
registerMooseObject("SolidMechanicsApp", EulerAngleFileReader)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Euler angle triplet.
Definition: EulerAngles.h:24
void mooseError(Args &&... args) const
Read a set of Euler angles from a file.
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
Abstract base class for user objects that implement the Euler Angle provider interface.
std::vector< EulerAngles > _angles