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 "ComputeUpdatedEulerAngle.h" 11 : 12 : registerMooseObject("SolidMechanicsApp", ComputeUpdatedEulerAngle); 13 : 14 : InputParameters 15 170 : ComputeUpdatedEulerAngle::validParams() 16 : { 17 170 : InputParameters params = Material::validParams(); 18 170 : params.addClassDescription( 19 : "This class computes the updated Euler angle for crystal plasticity simulations. This needs " 20 : "to be used together with the ComputeMultipleCrystalPlasticityStress class, where the " 21 : "updated rotation material property is computed. "); 22 340 : params.addParam<bool>( 23 340 : "radian_to_degree", true, "Whether to convert euler angles from radian to degree."); 24 170 : return params; 25 0 : } 26 : 27 126 : ComputeUpdatedEulerAngle::ComputeUpdatedEulerAngle(const InputParameters & parameters) 28 : : Material(parameters), 29 126 : _updated_rotation(getMaterialProperty<RankTwoTensor>("updated_rotation")), 30 252 : _updated_euler_angle(declareProperty<RealVectorValue>("updated_Euler_angle")) 31 : { 32 126 : } 33 : 34 : void 35 0 : ComputeUpdatedEulerAngle::initQpStatefulProperties() 36 : { 37 0 : _updated_euler_angle[_qp].zero(); 38 0 : } 39 : 40 : void 41 280168 : ComputeUpdatedEulerAngle::computeQpProperties() 42 : { 43 280168 : computeEulerAngleFromRotationMatrix(_updated_rotation[_qp], _updated_euler_angle[_qp]); 44 280168 : } 45 : 46 : void 47 280168 : ComputeUpdatedEulerAngle::computeEulerAngleFromRotationMatrix(const RankTwoTensor & rot, 48 : RealVectorValue & euler_angle) 49 : { 50 : // transform RankTwoTensor to Eigen::Matrix 51 : Eigen::Matrix<Real, 3, 3> rot_mat; 52 : 53 1120672 : for (unsigned int i = 0; i < 3; ++i) 54 3362016 : for (unsigned int j = 0; j < 3; ++j) 55 2521512 : rot_mat(i, j) = rot(i, j); 56 : 57 : // compute Quaternion from rotation matrix 58 : Eigen::Quaternion<Real> q(rot_mat); 59 : // construct Euler angle from Quaternion 60 280168 : EulerAngles ea(q); 61 : // convert EulerAngles to RealVectorValue 62 280168 : euler_angle = (RealVectorValue)ea; 63 : 64 560336 : if (!getParam<bool>("radian_to_degree")) 65 : euler_angle *= libMesh::pi / 180.0; 66 280168 : }