LCOV - code coverage report
Current view: top level - src/materials/crystal_plasticity - ComputeElasticityTensorCP.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 50 51 98.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 "ComputeElasticityTensorCP.h"
      11             : #include "RotationTensor.h"
      12             : 
      13             : registerMooseObject("SolidMechanicsApp", ComputeElasticityTensorCP);
      14             : 
      15             : InputParameters
      16        2078 : ComputeElasticityTensorCP::validParams()
      17             : {
      18        2078 :   InputParameters params = ComputeElasticityTensor::validParams();
      19        2078 :   params.addClassDescription("Compute an elasticity tensor for crystal plasticity.");
      20        4156 :   params.addParam<UserObjectName>("read_prop_user_object",
      21             :                                   "The ElementReadPropertyFile "
      22             :                                   "GeneralUserObject to read element "
      23             :                                   "specific property values from file");
      24        4156 :   params.addCoupledVar("euler_angle_variables",
      25             :                        "Vector of coupled variables representing the Euler angles' components.");
      26        2078 :   return params;
      27           0 : }
      28             : 
      29        1560 : ComputeElasticityTensorCP::ComputeElasticityTensorCP(const InputParameters & parameters)
      30             :   : ComputeElasticityTensor(parameters),
      31        4680 :     _read_prop_user_object(isParamValid("read_prop_user_object")
      32        1706 :                                ? &getUserObject<PropertyReadFile>("read_prop_user_object")
      33             :                                : nullptr),
      34        1560 :     _Euler_angles_mat_prop(declareProperty<RealVectorValue>("Euler_angles")),
      35        1560 :     _crysrot(declareProperty<RankTwoTensor>(_base_name + "crysrot")),
      36        1560 :     _R(_Euler_angles),
      37        1560 :     _n_euler_angle_vars(coupledComponents("euler_angle_variables")),
      38        3120 :     _euler_angle_vars(coupledValues("euler_angle_variables"))
      39             : {
      40             :   // the base class guarantees constant in time, but in this derived class the
      41             :   // tensor will rotate over time once plastic deformation sets in
      42        1560 :   revokeGuarantee(_elasticity_tensor_name, Guarantee::CONSTANT_IN_TIME);
      43             : 
      44             :   // the base class performs a passive rotation, but the crystal plasticity
      45             :   // materials use active rotation: recover unrotated _Cijkl here
      46        3120 :   if (parameters.isParamValid("rotation_matrix"))
      47             :   {
      48          56 :     _user_provided_rotation_matrix = true;
      49          56 :     _Cijkl.rotate(_rotation_matrix.transpose());
      50             :   }
      51             :   else
      52             :   {
      53        1504 :     _user_provided_rotation_matrix = false;
      54        1504 :     _Cijkl.rotate(_R.transpose());
      55             :   }
      56             : 
      57        1560 :   if (_user_provided_rotation_matrix &&
      58        1672 :       (_read_prop_user_object || (parameters.isParamSetByUser("euler_angle_1")) ||
      59        1616 :        (parameters.isParamSetByUser("euler_angle_2")) ||
      60        1614 :        (parameters.isParamSetByUser("euler_angle_3"))))
      61           2 :     mooseError("Bunge Euler angle information and the rotation_matrix cannot both be specified. "
      62             :                "Provide only one type of orientation information in the input file.");
      63             : 
      64             :   // Check if source of Euler angle values has a conflict
      65        1558 :   if (_read_prop_user_object && _n_euler_angle_vars)
      66           2 :     paramError("euler_angle_variables",
      67             :                "Euler angles cannot be supplied from both coupled variables and auxiliary input "
      68             :                "file in the option `read_prop_user_object`.");
      69             : 
      70        3112 :   if (isCoupled("euler_angle_variables") && _n_euler_angle_vars != 3)
      71           2 :     paramError("euler_angle_variables", "The Euler angles should have three components.");
      72        1554 : }
      73             : 
      74             : void
      75     2168636 : ComputeElasticityTensorCP::assignEulerAngles()
      76             : {
      77     2168636 :   if (_read_prop_user_object)
      78             :   {
      79      170240 :     _Euler_angles_mat_prop[_qp](0) = _read_prop_user_object->getData(_current_elem, 0);
      80      170240 :     _Euler_angles_mat_prop[_qp](1) = _read_prop_user_object->getData(_current_elem, 1);
      81      170240 :     _Euler_angles_mat_prop[_qp](2) = _read_prop_user_object->getData(_current_elem, 2);
      82             :   }
      83     1998396 :   else if (_n_euler_angle_vars)
      84             :   {
      85        7520 :     _Euler_angles_mat_prop[_qp](0) = (*_euler_angle_vars[0])[_qp];
      86        7520 :     _Euler_angles_mat_prop[_qp](1) = (*_euler_angle_vars[1])[_qp];
      87        7520 :     _Euler_angles_mat_prop[_qp](2) = (*_euler_angle_vars[2])[_qp];
      88             :   }
      89             :   else
      90     1990876 :     _Euler_angles_mat_prop[_qp] = _Euler_angles;
      91             : 
      92     2168636 :   _R.update(_Euler_angles_mat_prop[_qp]);
      93     2168636 : }
      94             : 
      95             : void
      96     2279372 : ComputeElasticityTensorCP::computeQpElasticityTensor()
      97             : {
      98             :   // Properties assigned at the beginning of every call to material calculation
      99             :   // is required by the monolithic and user object versions. If those classes
     100             :   // are deprecated, these update can be removed and save time
     101     2279372 :   if (!_user_provided_rotation_matrix)
     102             :   {
     103     2168636 :     assignEulerAngles();
     104     2168636 :     _crysrot[_qp] = _R.transpose();
     105             :   }
     106             :   else
     107      110736 :     _crysrot[_qp] = _rotation_matrix.transpose();
     108             : 
     109     2279372 :   _elasticity_tensor[_qp] = _Cijkl;
     110     2279372 :   _elasticity_tensor[_qp].rotate(_crysrot[_qp]);
     111     2279372 : }

Generated by: LCOV version 1.14