LCOV - code coverage report
Current view: top level - src/materials/crystal_plasticity - ComputeCrystalPlasticityEigenstrainBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 32 35 91.4 %
Date: 2025-07-25 05:00:39 Functions: 7 8 87.5 %
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 "ComputeCrystalPlasticityEigenstrainBase.h"
      11             : #include "RankTwoTensor.h"
      12             : 
      13             : InputParameters
      14         256 : ComputeCrystalPlasticityEigenstrainBase::validParams()
      15             : {
      16         256 :   InputParameters params = ComputeEigenstrainBase::validParams();
      17             : 
      18             :   // The return stress increment classes are intended to be iterative materials, so must set compute
      19             :   // = false for all inheriting classes
      20         256 :   params.set<bool>("compute") = false;
      21         256 :   params.suppressParameter<bool>("compute");
      22             : 
      23         512 :   params.addRequiredParam<std::string>(
      24             :       "deformation_gradient_name",
      25             :       "Material property name for the deformation gradient tensor computed "
      26             :       "by this model.");
      27         256 :   return params;
      28           0 : }
      29             : 
      30         192 : ComputeCrystalPlasticityEigenstrainBase::ComputeCrystalPlasticityEigenstrainBase(
      31         192 :     const InputParameters & parameters)
      32             :   : ComputeEigenstrainBase(parameters),
      33         192 :     _deformation_gradient_name(_base_name + getParam<std::string>("deformation_gradient_name")),
      34         192 :     _deformation_gradient(declareProperty<RankTwoTensor>(_deformation_gradient_name)),
      35         192 :     _deformation_gradient_old(getMaterialPropertyOld<RankTwoTensor>(_deformation_gradient_name)),
      36         384 :     _crysrot(getMaterialProperty<RankTwoTensor>(
      37         192 :         "crysrot")) // defined in the elasticity tensor classes for crystal plasticity
      38             : {
      39         192 : }
      40             : 
      41             : void
      42       12928 : ComputeCrystalPlasticityEigenstrainBase::initQpStatefulProperties()
      43             : {
      44       12928 :   ComputeEigenstrainBase::initQpStatefulProperties();
      45             : 
      46             :   // Initialize deformation gradient to be identity
      47       12928 :   _deformation_gradient[_qp].zero();
      48       12928 :   _deformation_gradient[_qp].addIa(1.0);
      49       12928 : }
      50             : 
      51             : void
      52      815684 : ComputeCrystalPlasticityEigenstrainBase::computeQpEigenstrain()
      53             : {
      54             :   // updates the deformation gradient from the child class
      55      815684 :   computeQpDeformationGradient();
      56             :   // use the updated deformation gradient for the eigenstrain calculation
      57      815664 :   _eigenstrain[_qp] = 0.5 * (_deformation_gradient[_qp].transpose() * _deformation_gradient[_qp] -
      58      815664 :                              RankTwoTensor::Identity());
      59      815664 : }
      60             : 
      61             : void
      62      660244 : ComputeCrystalPlasticityEigenstrainBase::setQp(const unsigned int & qp)
      63             : {
      64      660244 :   _qp = qp;
      65      660244 : }
      66             : 
      67             : void
      68      815684 : ComputeCrystalPlasticityEigenstrainBase::setSubstepDt(const Real & substep_dt)
      69             : {
      70      815684 :   _substep_dt = substep_dt;
      71      815684 : }
      72             : 
      73             : const RankTwoTensor
      74           0 : ComputeCrystalPlasticityEigenstrainBase::getDeformationGradient() const
      75             : {
      76           0 :   return _deformation_gradient[_qp];
      77             : }
      78             : 
      79             : const RankTwoTensor
      80      815664 : ComputeCrystalPlasticityEigenstrainBase::getDeformationGradientInverse() const
      81             : {
      82      815664 :   return _deformation_gradient[_qp].inverse();
      83             : }

Generated by: LCOV version 1.14