LCOV - code coverage report
Current view: top level - src/utils - RankTwoScalarTools.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 19 29 65.5 %
Date: 2025-07-25 05:00:39 Functions: 3 6 50.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 "RankTwoScalarTools.h"
      11             : 
      12             : namespace RankTwoScalarTools
      13             : {
      14             : 
      15             : /// This enum is left for legacy calls
      16             : MooseEnum
      17        1960 : scalarOptions()
      18             : {
      19             :   return MooseEnum("VonMisesStress EffectiveStrain Hydrostatic L2norm MaxPrincipal "
      20             :                    "MidPrincipal MinPrincipal VolumetricStrain FirstInvariant SecondInvariant "
      21             :                    "ThirdInvariant AxialStress HoopStress RadialStress TriaxialityStress "
      22        3920 :                    "Direction MaxShear StressIntensity");
      23             : }
      24             : 
      25             : MooseEnum
      26           0 : invariantOptions()
      27             : {
      28             :   return MooseEnum("VonMisesStress EffectiveStrain Hydrostatic L2norm VolumetricStrain "
      29             :                    "FirstInvariant SecondInvariant "
      30           0 :                    "ThirdInvariant TriaxialityStress MaxShear StressIntensity EffectiveStrain");
      31             : }
      32             : 
      33             : MooseEnum
      34           0 : cylindricalOptions()
      35             : {
      36           0 :   return MooseEnum("AxialStress HoopStress RadialStress");
      37             : }
      38             : 
      39             : MooseEnum
      40           0 : sphericalOptions()
      41             : {
      42           0 :   return MooseEnum("HoopStress RadialStress");
      43             : }
      44             : 
      45             : void
      46       98880 : normalPositionVector(const Point & point1,
      47             :                      const Point & point2,
      48             :                      const Point & curr_point,
      49             :                      Point & normalPosition)
      50             : {
      51             :   // Find the nearest point on the axis of rotation (defined by point2 - point1)
      52             :   // to the current position, e.g. the normal to the axis of rotation at the
      53             :   // current position
      54             :   Point axis_rotation = point2 - point1;
      55             :   Point positionWRTpoint1 = point1 - curr_point;
      56       98880 :   Real projection = (axis_rotation * positionWRTpoint1) / axis_rotation.norm_sq();
      57             :   Point normal = point1 - projection * axis_rotation;
      58             : 
      59             :   // Calculate the direction normal to the plane formed by the axis of rotation
      60             :   // and the normal to the axis of rotation from the current position.
      61       98880 :   normalPosition = curr_point - normal;
      62       98880 :   normalPosition /= normalPosition.norm();
      63       98880 : }
      64             : 
      65             : void
      66        4320 : setRotationMatrix(const RealVectorValue & outwardnormal,
      67             :                   const RealVectorValue & axialVector,
      68             :                   RankTwoTensor & rotationMatrix,
      69             :                   const bool transpose)
      70             : {
      71        4320 :   RealVectorValue radial_vector(outwardnormal);
      72             :   RealVectorValue azimuthal_vector(0, 0, 0);
      73        4320 :   RealVectorValue polar_vector(axialVector);
      74             : 
      75        4320 :   Real rv_norm = radial_vector.norm();
      76        4320 :   if (rv_norm)
      77             :     radial_vector /= rv_norm;
      78             :   else
      79           0 :     mooseError("The outward normal vector cannot be a zero vector");
      80             : 
      81        4320 :   azimuthal_vector = polar_vector.cross(radial_vector);
      82        4320 :   azimuthal_vector /= azimuthal_vector.norm();
      83             : 
      84        4320 :   if (!transpose)
      85             :   {
      86             :     // Considering that Moose uses convention [T'] = [Q][T][Q_transpose], the
      87             :     // basis vectors of old coordinate system should be arranged column wise
      88             :     // to construct the rotation matrix Q.
      89             : 
      90        4320 :     rotationMatrix.fillColumn(0, radial_vector);
      91        4320 :     rotationMatrix.fillColumn(1, azimuthal_vector);
      92        4320 :     rotationMatrix.fillColumn(2, polar_vector);
      93             :   }
      94             :   else
      95             :   {
      96           0 :     rotationMatrix.fillRow(0, radial_vector);
      97           0 :     rotationMatrix.fillRow(1, azimuthal_vector);
      98           0 :     rotationMatrix.fillRow(2, polar_vector);
      99             :   }
     100        4320 : }
     101             : }

Generated by: LCOV version 1.14