LCOV - code coverage report
Current view: top level - src/utils - RotationTensor.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 36 36 100.0 %
Date: 2025-07-25 05:00:39 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14