www.mooseframework.org
EulerAngleUpdaterCheck.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 /****************************************************************/
8 #include "EulerAngleUpdater.h"
9 #include "EulerAngleProvider.h"
10 #include "GrainTrackerInterface.h"
12 #include "RotationTensor.h"
13 
14 template <>
15 InputParameters
17 {
18  InputParameters params = validParams<GeneralVectorPostprocessor>();
19  params.addClassDescription(
20  "Provide updated euler angles after rigid body rotation of the grains.");
21  params.addRequiredParam<UserObjectName>("grain_tracker_object",
22  "The FeatureFloodCount UserObject to get values from.");
23  params.addParam<UserObjectName>("euler_angle_updater",
24  "Name of Euler angle provider user object");
25  params.addRequiredParam<UserObjectName>("grain_torques_object",
26  "Name of Euler angle provider user object");
27  params.addRequiredParam<VectorPostprocessorName>("grain_volumes",
28  "The feature volume VectorPostprocessorValue.");
29  params.addParam<Real>("rotation_constant", 1.0, "constant value characterizing grain rotation");
30  return params;
31 }
32 
33 EulerAngleUpdaterCheck::EulerAngleUpdaterCheck(const InputParameters & params)
34  : GeneralVectorPostprocessor(params),
35  _diff(declareVector("vec_diff")),
36  _grain_tracker(getUserObject<GrainTrackerInterface>("grain_tracker_object")),
37  _euler(getUserObject<EulerAngleUpdater>("euler_angle_updater")),
38  _grain_torque(getUserObject<GrainForceAndTorqueInterface>("grain_torques_object")),
39  _grain_volumes(getVectorPostprocessorValue("grain_volumes", "feature_volumes")),
40  _mr(getParam<Real>("rotation_constant"))
41 {
42 }
43 
44 void
46 {
47  const auto grain_num = _grain_tracker.getTotalFeatureCount();
48  _angles.resize(grain_num);
49  _angles_old.resize(grain_num);
50  _diff.assign(3 * grain_num, 0.0);
51 
52  for (unsigned int i = 0; i < grain_num; ++i)
53  {
56  RealGradient torque = _grain_torque.getTorqueValues()[i];
57 
58  RealVectorValue a(1, 1, 1);
59  RotationTensor R(_angles[i]); // Final rotation tensor
60  RealVectorValue a_rot = R * a; // final rotated vector
61 
62  RotationTensor R0(_angles_old[i]); // RotationTensor as per old euler angles
63  RealVectorValue torque_rot = R0 * torque; // Rotated torque
64  RealVectorValue a_rot0 = R0 * a; // Rotated unit vector as per old euler angles
65 
75  RealVectorValue torque_rot1;
76  RealVectorValue angle_rot;
77  torque_rot1(0) =
78  torque_rot(2); // Tourque about z changed to torque responsible for chaneg in angle phi1
79  angle_rot(0) = _mr / _grain_volumes[i] * torque_rot1(0) * _dt; // change in phi1
80  // Tourque about x' changed to torque responsible for chaneg in angle Phi
81  torque_rot1(1) =
82  (torque_rot(0) * std::cos(angle_rot(0)) + torque_rot(1) * std::sin(angle_rot(0)));
83  angle_rot(1) = _mr / _grain_volumes[i] * torque_rot1(1) * _dt; // change in Phi
84  // Tourque about z'' changed to torque responsible for chaneg in angle phi2
85  torque_rot1(2) = (torque_rot(0) * std::sin(angle_rot(0)) * std::sin(angle_rot(1)) -
86  torque_rot(1) * std::cos(angle_rot(0)) * std::sin(angle_rot(1)) +
87  torque_rot(2) * std::cos(angle_rot(1)));
88  angle_rot(2) = _mr / _grain_volumes[i] * torque_rot1(2) * _dt; // change in phi2
89  angle_rot *= (180.0 / libMesh::pi);
90 
91  RotationTensor R4(angle_rot); // RotationTensor due to grain rotation
92  RealVectorValue a_rot1 = R4 * a_rot0; // Final rotated vector obtained in two step rotation
93 
94  // Difference between the final positions of the rotated vector obtained in two different ways,
95  // should be 0.0
96  _diff[3 * i + 0] = a_rot(0) - a_rot1(0);
97  _diff[3 * i + 1] = a_rot(1) - a_rot1(1);
98  _diff[3 * i + 2] = a_rot(2) - a_rot1(2);
99  }
100 }
virtual const EulerAngles & getEulerAnglesOld(unsigned int) const
std::vector< RealVectorValue > _angles
This class defines the interface for the GrainTracking objects.
This class provides interface for extracting the forces and torques computed in other UserObjects...
virtual std::size_t getTotalFeatureCount() const =0
Returns a number large enough to contain the largest ID for all grains in use.
EulerAngleUpdaterCheck(const InputParameters &parameters)
const VectorPostprocessorValue & _grain_volumes
const GrainTrackerInterface & _grain_tracker
VectorPostprocessorValue & _diff
std::vector< RealVectorValue > _angles_old
Update Euler angles of each grains after rigid body rotation This class estimates the rotation of pri...
This is a RealTensor version of a rotation matrix It is instantiated with the Euler angles...
InputParameters validParams< EulerAngleUpdaterCheck >()
const EulerAngleUpdater & _euler
const GrainForceAndTorqueInterface & _grain_torque
virtual const std::vector< RealGradient > & getTorqueValues() const =0
virtual const EulerAngles & getEulerAngles(unsigned int) const override
virtual void initialize() override