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 146 : ComputeUpdatedEulerAngle::validParams() 16 : { 17 146 : InputParameters params = Material::validParams(); 18 146 : 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 292 : params.addParam<bool>( 23 292 : "radian_to_degree", true, "Whether to convert euler angles from radian to degree."); 24 146 : return params; 25 0 : } 26 : 27 108 : ComputeUpdatedEulerAngle::ComputeUpdatedEulerAngle(const InputParameters & parameters) 28 : : Material(parameters), 29 108 : _updated_rotation(getMaterialProperty<RankTwoTensor>("updated_rotation")), 30 216 : _updated_euler_angle(declareProperty<RealVectorValue>("updated_Euler_angle")) 31 : { 32 108 : } 33 : 34 : void 35 0 : ComputeUpdatedEulerAngle::initQpStatefulProperties() 36 : { 37 0 : _updated_euler_angle[_qp].zero(); 38 0 : } 39 : 40 : void 41 223184 : ComputeUpdatedEulerAngle::computeQpProperties() 42 : { 43 223184 : computeEulerAngleFromRotationMatrix(_updated_rotation[_qp], _updated_euler_angle[_qp]); 44 223184 : } 45 : 46 : void 47 223184 : 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 892736 : for (unsigned int i = 0; i < 3; ++i) 54 2678208 : for (unsigned int j = 0; j < 3; ++j) 55 2008656 : 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 223184 : EulerAngles ea(q); 61 : // convert EulerAngles to RealVectorValue 62 223184 : euler_angle = (RealVectorValue)ea; 63 : 64 446368 : if (!getParam<bool>("radian_to_degree")) 65 : euler_angle *= libMesh::pi / 180.0; 66 223184 : }