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