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 37 of file EulerAngleUpdater.h.

Constructor & Destructor Documentation

◆ EulerAngleUpdater()

EulerAngleUpdater::EulerAngleUpdater ( const InputParameters &  parameters)

Definition at line 36 of file EulerAngleUpdater.C.

37  : EulerAngleProvider(params),
38  _grain_tracker(getUserObject<GrainTrackerInterface>("grain_tracker_object")),
39  _euler(getUserObject<EulerAngleProvider>("euler_angle_provider")),
40  _grain_torque(getUserObject<GrainForceAndTorqueInterface>("grain_torques_object")),
41  _grain_volumes(getVectorPostprocessorValue("grain_volumes", "feature_volumes")),
42  _mr(getParam<Real>("rotation_constant")),
43  _first_time(true)
44 {
45 }
const GrainTrackerInterface & _grain_tracker
const GrainForceAndTorqueInterface & _grain_torque
const VectorPostprocessorValue & _grain_volumes
const EulerAngleProvider & _euler
EulerAngleProvider(const InputParameters &parameters)

Member Function Documentation

◆ execute()

virtual void EulerAngleUpdater::execute ( )
inlineoverridevirtual

Definition at line 43 of file EulerAngleUpdater.h.

43 {}

◆ finalize()

virtual void EulerAngleUpdater::finalize ( )
inlineoverridevirtual

Definition at line 44 of file EulerAngleUpdater.h.

44 {}

◆ getEulerAngles()

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

Implements EulerAngleProvider.

Definition at line 168 of file EulerAngleUpdater.C.

Referenced by EulerAngleUpdaterCheck::initialize().

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

◆ getEulerAnglesOld()

const EulerAngles & EulerAngleUpdater::getEulerAnglesOld ( unsigned int  i) const
virtual

Definition at line 175 of file EulerAngleUpdater.C.

Referenced by EulerAngleUpdaterCheck::initialize().

176 {
177  mooseAssert(i < getGrainNum(), "Requesting Euler angles for an invalid grain id");
178  return _angles_old[i];
179 }
virtual unsigned int getGrainNum() const override
std::vector< EulerAngles > _angles_old

◆ getGrainNum()

unsigned int EulerAngleUpdater::getGrainNum ( ) const
overridevirtual

Implements EulerAngleProvider.

Definition at line 162 of file EulerAngleUpdater.C.

Referenced by getEulerAngles(), and getEulerAnglesOld().

163 {
164  return _angles.size();
165 }
std::vector< EulerAngles > _angles

◆ initialize()

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 48 of file EulerAngleUpdater.C.

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

Member Data Documentation

◆ _angles

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

Definition at line 59 of file EulerAngleUpdater.h.

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

◆ _angles_old

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

Definition at line 60 of file EulerAngleUpdater.h.

Referenced by getEulerAnglesOld(), and initialize().

◆ _euler

const EulerAngleProvider& EulerAngleUpdater::_euler
protected

Definition at line 52 of file EulerAngleUpdater.h.

Referenced by initialize().

◆ _first_time

bool EulerAngleUpdater::_first_time
protected

Definition at line 57 of file EulerAngleUpdater.h.

Referenced by initialize().

◆ _grain_torque

const GrainForceAndTorqueInterface& EulerAngleUpdater::_grain_torque
protected

Definition at line 53 of file EulerAngleUpdater.h.

Referenced by initialize().

◆ _grain_tracker

const GrainTrackerInterface& EulerAngleUpdater::_grain_tracker
protected

Definition at line 51 of file EulerAngleUpdater.h.

Referenced by initialize().

◆ _grain_volumes

const VectorPostprocessorValue& EulerAngleUpdater::_grain_volumes
protected

Definition at line 54 of file EulerAngleUpdater.h.

Referenced by initialize().

◆ _mr

const Real EulerAngleUpdater::_mr
protected

Definition at line 56 of file EulerAngleUpdater.h.

Referenced by initialize().


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