www.mooseframework.org
RotationTensor.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 /****************************************************************/
7 #include "RotationTensor.h"
8 #include "libmesh/libmesh.h"
9 
10 RotationTensor::RotationTensor(Axis axis, Real angle) { update(axis, angle); }
11 
12 RotationTensor::RotationTensor(const RealVectorValue & euler_angles) { update(euler_angles); }
13 
14 void
15 RotationTensor::update(Axis axis, Real angle)
16 {
17  zero();
18 
19  RealVectorValue a;
20  a(axis) = 1.0;
21 
22  const Real s = std::sin(angle * libMesh::pi / 180.0);
23  const Real c = std::cos(angle * libMesh::pi / 180.0);
24 
25  // assemble row wise
26  _coords[0] = a * RealVectorValue(1.0, -c, -c);
27  _coords[1] = a * RealVectorValue(0.0, 0.0, s);
28  _coords[2] = a * RealVectorValue(0.0, -s, 0.0);
29 
30  _coords[3] = a * RealVectorValue(0.0, 0.0, -s);
31  _coords[4] = a * RealVectorValue(-c, 1.0, -c);
32  _coords[5] = a * RealVectorValue(s, 0.0, 0.0);
33 
34  _coords[6] = a * RealVectorValue(0.0, s, 0.0);
35  _coords[7] = a * RealVectorValue(-s, 0.0, 0.0);
36  _coords[8] = a * RealVectorValue(-c, -c, 1.0);
37 }
38 
39 void
40 RotationTensor::update(const RealVectorValue & euler_angles)
41 {
42  const Real phi_1 = euler_angles(0) * (libMesh::pi / 180.0);
43  const Real Phi = euler_angles(1) * (libMesh::pi / 180.0);
44  const Real phi_2 = euler_angles(2) * (libMesh::pi / 180.0);
45 
46  const Real c1 = std::cos(phi_1);
47  const Real c2 = std::cos(Phi);
48  const Real c3 = std::cos(phi_2);
49 
50  const Real s1 = std::sin(phi_1);
51  const Real s2 = std::sin(Phi);
52  const Real s3 = std::sin(phi_2);
53 
54  // doing a Z1, X2, Z3 rotation
55  // RealTensorValue is formed row-wise
56 
57  _coords[0] = c1 * c3 - c2 * s1 * s3; // R11
58  _coords[3] = -c1 * s3 - c2 * c3 * s1; // R12
59  _coords[6] = s1 * s2; // R13
60 
61  _coords[1] = c3 * s1 + c1 * c2 * s3; // R21
62  _coords[4] = c1 * c2 * c3 - s1 * s3; // R22
63  _coords[7] = -c1 * s2; // R23
64 
65  _coords[2] = s2 * s3; // R31
66  _coords[5] = c3 * s2; // R32
67  _coords[8] = c2; // R33
68 }
Axis
axis for single axis rotation constructor
RotationTensor(Axis axis, Real angle)
single axis rotation (in degrees)
void update(Axis axis, Real angle)
reforms the rotation matrix according to axis and angle.