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