www.mooseframework.org
Public Member Functions | Protected Attributes | List of all members
EulerAngleUpdater Class Reference

Update Euler angles of each grains after rigid body rotation This class estimates the rotation of principal axes of the grains due to applied torques and calculates the final grain orientation. More...

#include <EulerAngleUpdater.h>

Inheritance diagram for EulerAngleUpdater:
[legend]

Public Member Functions

 EulerAngleUpdater (const InputParameters &parameters)
 
virtual void initialize () override
 
virtual void execute () override
 
virtual void finalize () override
 
virtual const EulerAnglesgetEulerAngles (unsigned int) const override
 
virtual const EulerAnglesgetEulerAnglesOld (unsigned int) const
 
virtual unsigned int getGrainNum () const override
 

Protected Attributes

const GrainTrackerInterface_grain_tracker
 
const EulerAngleProvider_euler
 
const GrainForceAndTorqueInterface_grain_torque
 
const VectorPostprocessorValue & _grain_volumes
 
const Real _mr
 
bool _first_time
 
std::vector< EulerAngles_angles
 
std::vector< EulerAngles_angles_old
 

Detailed Description

Update Euler angles of each grains after rigid body rotation This class estimates the rotation of principal axes of the grains due to applied torques and calculates the final grain orientation.

Step1: Calculate RotationTensor based on euler angles from previous time step (R0) Step2: Obtain the torque acting on the grains at current time Step Step3: Calculate the angular velocities around global axes Step4: Calculate change in euler angles due to torque and corresponding rotation matrix(R1) Step5: Calculate final rotation matrix, R = R1 * R0, determines the final position of any rotated vector Step6: Back-calculate the euler angles from the final rotation matrix Step7: Ensure euler angles comply with Bunge definitions

Definition at line 34 of file EulerAngleUpdater.h.

Constructor & Destructor Documentation

EulerAngleUpdater::EulerAngleUpdater ( const InputParameters &  parameters)

Definition at line 31 of file EulerAngleUpdater.C.

32  : EulerAngleProvider(params),
33  _grain_tracker(getUserObject<GrainTrackerInterface>("grain_tracker_object")),
34  _euler(getUserObject<EulerAngleProvider>("euler_angle_provider")),
35  _grain_torque(getUserObject<GrainForceAndTorqueInterface>("grain_torques_object")),
36  _grain_volumes(getVectorPostprocessorValue("grain_volumes", "feature_volumes")),
37  _mr(getParam<Real>("rotation_constant")),
38  _first_time(true)
39 {
40 }
const GrainTrackerInterface & _grain_tracker
const GrainForceAndTorqueInterface & _grain_torque
const VectorPostprocessorValue & _grain_volumes
const EulerAngleProvider & _euler
EulerAngleProvider(const InputParameters &parameters)

Member Function Documentation

virtual void EulerAngleUpdater::execute ( )
inlineoverridevirtual

Definition at line 40 of file EulerAngleUpdater.h.

40 {}
virtual void EulerAngleUpdater::finalize ( )
inlineoverridevirtual

Definition at line 41 of file EulerAngleUpdater.h.

41 {}
const EulerAngles & EulerAngleUpdater::getEulerAngles ( unsigned int  i) const
overridevirtual

Implements EulerAngleProvider.

Definition at line 163 of file EulerAngleUpdater.C.

Referenced by finalize(), and EulerAngleUpdaterCheck::initialize().

164 {
165  mooseAssert(i < getGrainNum(), "Requesting Euler angles for an invalid grain id");
166  return _angles[i];
167 }
virtual unsigned int getGrainNum() const override
std::vector< EulerAngles > _angles
const EulerAngles & EulerAngleUpdater::getEulerAnglesOld ( unsigned int  i) const
virtual

Definition at line 170 of file EulerAngleUpdater.C.

Referenced by finalize(), and EulerAngleUpdaterCheck::initialize().

171 {
172  mooseAssert(i < getGrainNum(), "Requesting Euler angles for an invalid grain id");
173  return _angles_old[i];
174 }
virtual unsigned int getGrainNum() const override
std::vector< EulerAngles > _angles_old
unsigned int EulerAngleUpdater::getGrainNum ( ) const
overridevirtual

Implements EulerAngleProvider.

Definition at line 157 of file EulerAngleUpdater.C.

Referenced by finalize(), getEulerAngles(), and getEulerAnglesOld().

158 {
159  return _angles.size();
160 }
std::vector< EulerAngles > _angles
void EulerAngleUpdater::initialize ( )
overridevirtual

Change in euler angles are obtained from the torque & angular velocities about the material axes. Change in phi1, Phi and phi2 are caused by rotation about z axis, x' axis & z'' axis, respectively. Components of the angular velocities across z, x' and z'' axes are obtained from the torque values. This yields change in euler angles due to grain rotation.

Final RotationMatrix = RotationMatrix due to applied torque X old RotationMatrix Updated Euler angles are obtained by back-tracking the angles from the rotation matrix For details about the componenets of the rotation matrix please refer to RotationTensor.C Phi = acos(R33); phi1 = atan2(R31,-R32); phi2 = atan2(R13,R23) for phi != 0.0 por 180.0

Definition at line 43 of file EulerAngleUpdater.C.

44 {
45  const auto grain_num = _grain_tracker.getTotalFeatureCount();
46 
47  if (_first_time)
48  {
49  _angles.resize(grain_num);
50  _angles_old.resize(grain_num);
51  for (unsigned int i = 0; i < grain_num; ++i)
52  _angles[i] = _euler.getEulerAngles(i); // Read initial euler angles
53  }
54 
55  unsigned int angle_size = _angles.size();
56  for (unsigned int i = angle_size; i < grain_num; ++i) // if new grains are created
57  _angles.push_back(_euler.getEulerAngles(i)); // Assign initial euler angles
58 
59  for (unsigned int i = 0; i < grain_num; ++i)
60  {
61  if (!_first_time && !_fe_problem.converged())
62  _angles[i] = _angles_old[i];
63 
64  RealGradient torque = _grain_torque.getTorqueValues()[i];
65 
66  if (i <= angle_size) // if new grains are created
67  _angles_old[i] = _angles[i];
68  else
69  _angles_old.push_back(_angles[i]);
70 
71  RotationTensor R0(_angles_old[i]); // RotationTensor as per old euler angles
72  RealVectorValue torque_rotated =
73  R0 * torque; // Applied torque is rotated to allign with old grain axes
74  RealVectorValue omega =
75  _mr / _grain_volumes[i] * torque_rotated; // Angular velocity as per old grain axes
85  RealVectorValue angle_change;
86  angle_change(0) = omega(2) * _dt;
87  angle_change(1) =
88  (omega(0) * std::cos(angle_change(0)) + omega(1) * std::sin(angle_change(0))) * _dt;
89  angle_change(2) = (omega(0) * std::sin(angle_change(0)) * std::sin(angle_change(1)) -
90  omega(1) * std::cos(angle_change(0)) * std::sin(angle_change(1)) +
91  omega(2) * std::cos(angle_change(1))) *
92  _dt;
93  angle_change *= (180.0 / libMesh::pi);
94 
95  RotationTensor R1(angle_change); // Rotation matrix due to torque
102  RealTensorValue R = R1 * R0;
103 
104  if (R(2, 2) != 1.0 && R(2, 2) != -1.0) // checks if cos(Phi) = 1 or -1
105  {
106  _angles[i].phi1 = std::atan2(R(2, 0), -R(2, 1)) * (180.0 / libMesh::pi);
107  _angles[i].Phi = std::acos(R(2, 2)) * (180.0 / libMesh::pi);
108  _angles[i].phi2 = std::atan2(R(0, 2), R(1, 2)) * (180.0 / libMesh::pi);
109  }
110  else if (R(2, 2) == 1.0) // special case for Phi = 0.0
111  {
112  if (R0(2, 2) == 1.0)
113  // when Phi_old = 0.0; all the rotations are about z axis and angles accumulates after each
114  // rotation
115  _angles[i].phi1 = _angles_old[i].phi1 + _angles_old[i].phi2 + angle_change(0);
116  else
117  _angles[i].phi1 = angle_change(0);
118  // Comply with bunge euler angle definitions, 0.0 <= phi1 <= 360.0
119  if (std::abs(_angles[i].phi1) > 360.0)
120  {
121  int laps = _angles[i].phi1 / 360.0;
122  _angles[i].phi1 -= laps * 360.0;
123  }
124  _angles[i].Phi = 0.0;
125  _angles[i].phi2 = -_angles[i].phi1 + std::atan2(R(0, 1), R(1, 1)) * (180.0 / libMesh::pi);
126  }
127  else
128  {
129  if (R0(2, 2) == 1.0)
130  _angles[i].phi1 = _angles_old[i].phi1 + _angles_old[i].phi2 + angle_change(0);
131  else
132  _angles[i].phi1 = angle_change(0);
133  // Comply with bunge euler angle definitions, 0.0 <= phi1 <= 360.0
134  if (std::abs(_angles[i].phi1) > 360.0)
135  {
136  int laps = _angles[i].phi1 / 360.0;
137  _angles[i].phi1 -= laps * 360.0;
138  }
139  _angles[i].Phi = 180.0;
140  _angles[i].phi2 = _angles[i].phi1 - std::atan2(-R(0, 1), -R(1, 1)) * (180.0 / libMesh::pi);
141  }
142 
143  // Following checks and updates are done only to comply with bunge euler angle definitions, 0.0
144  // <= phi1/phi2 <= 360.0
145  if (_angles[i].phi1 < 0.0)
146  _angles[i].phi1 += 360.0;
147  if (_angles[i].phi2 < 0.0)
148  _angles[i].phi2 += 360.0;
149  if (_angles[i].Phi < 0.0)
150  mooseError("Euler angle out of range.");
151  }
152 
153  _first_time = false;
154 }
const GrainTrackerInterface & _grain_tracker
const GrainForceAndTorqueInterface & _grain_torque
virtual std::size_t getTotalFeatureCount() const =0
Returns a number large enough to contain the largest ID for all grains in use.
const VectorPostprocessorValue & _grain_volumes
const EulerAngleProvider & _euler
This is a RealTensor version of a rotation matrix It is instantiated with the Euler angles...
std::vector< EulerAngles > _angles_old
virtual const std::vector< RealGradient > & getTorqueValues() const =0
std::vector< EulerAngles > _angles
virtual const EulerAngles & getEulerAngles(unsigned int) const =0

Member Data Documentation

std::vector<EulerAngles> EulerAngleUpdater::_angles
protected

Definition at line 56 of file EulerAngleUpdater.h.

Referenced by getEulerAngles(), getGrainNum(), and initialize().

std::vector<EulerAngles> EulerAngleUpdater::_angles_old
protected

Definition at line 57 of file EulerAngleUpdater.h.

Referenced by getEulerAnglesOld(), and initialize().

const EulerAngleProvider& EulerAngleUpdater::_euler
protected

Definition at line 49 of file EulerAngleUpdater.h.

Referenced by initialize().

bool EulerAngleUpdater::_first_time
protected

Definition at line 54 of file EulerAngleUpdater.h.

Referenced by initialize().

const GrainForceAndTorqueInterface& EulerAngleUpdater::_grain_torque
protected

Definition at line 50 of file EulerAngleUpdater.h.

Referenced by initialize().

const GrainTrackerInterface& EulerAngleUpdater::_grain_tracker
protected

Definition at line 48 of file EulerAngleUpdater.h.

Referenced by initialize().

const VectorPostprocessorValue& EulerAngleUpdater::_grain_volumes
protected

Definition at line 51 of file EulerAngleUpdater.h.

Referenced by initialize().

const Real EulerAngleUpdater::_mr
protected

Definition at line 53 of file EulerAngleUpdater.h.

Referenced by initialize().


The documentation for this class was generated from the following files: