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 void
33 {
34  // Read in Euler angles from _file_name
35  std::ifstream inFile(_file_name.c_str());
36  if (!inFile)
37  mooseError("Can't open ", _file_name);
38 
39  // Skip first 4 lines
40  for (unsigned int i = 0; i < 4; ++i)
41  inFile.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
42 
43  // The angle files contain a fourth column with weights that we ignore in this version
44  Real weight;
45 
46  // Loop over grains
47  EulerAngles a;
48  while (inFile >> a.phi1 >> a.Phi >> a.phi2 >> weight)
49  _angles.push_back(EulerAngles(a));
50 }
EulerAngleFileReader(const InputParameters &parameters)
std::vector< EulerAngles > & _angles
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.