LCOV - code coverage report
Current view: top level - src/materials/crystal_plasticity - ComputeCrystalPlasticityThermalEigenstrain.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 30 31 96.8 %
Date: 2025-07-25 05:00:39 Functions: 3 3 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 "ComputeCrystalPlasticityThermalEigenstrain.h"
      11             : 
      12             : registerMooseObject("SolidMechanicsApp", ComputeCrystalPlasticityThermalEigenstrain);
      13             : 
      14             : InputParameters
      15         144 : ComputeCrystalPlasticityThermalEigenstrain::validParams()
      16             : {
      17         144 :   InputParameters params = ComputeCrystalPlasticityEigenstrainBase::validParams();
      18         144 :   params.addClassDescription("Computes the deformation gradient associated with the linear thermal "
      19             :                              "expansion in a crystal plasticity simulation");
      20         288 :   params.addCoupledVar("temperature", "Coupled temperature variable");
      21             : 
      22             :   // Let's check the range of the parameter here
      23         288 :   params.addRequiredRangeCheckedParam<std::vector<Real>>(
      24             :       "thermal_expansion_coefficients",
      25             :       "thermal_expansion_coefficients_size=1 | thermal_expansion_coefficients_size=3 | "
      26             :       "thermal_expansion_coefficients_size=6 | thermal_expansion_coefficients_size=9",
      27             :       "Vector of values defining the constant second order thermal expansion coefficients, "
      28             :       "depending on the degree of anisotropy, this should be of size 1, 3, 6 or 9");
      29             : 
      30         144 :   return params;
      31           0 : }
      32             : 
      33         108 : ComputeCrystalPlasticityThermalEigenstrain::ComputeCrystalPlasticityThermalEigenstrain(
      34         108 :     const InputParameters & parameters)
      35             :   : DerivativeMaterialInterface<ComputeCrystalPlasticityEigenstrainBase>(parameters),
      36         108 :     _temperature(coupledValue("temperature")),
      37         108 :     _temperature_old(coupledValueOld("temperature")),
      38         108 :     _ddeformation_gradient_dT(isCoupledConstant("temperature")
      39         108 :                                   ? nullptr
      40         324 :                                   : &declarePropertyDerivative<RankTwoTensor>(
      41         324 :                                         _deformation_gradient_name, coupledName("temperature", 0))),
      42         216 :     _thermal_expansion_coefficients(getParam<std::vector<Real>>("thermal_expansion_coefficients")),
      43         108 :     _lattice_thermal_expansion_coefficients(declareProperty<RankTwoTensor>(
      44         108 :         _eigenstrain_name +
      45         108 :         "_lattice_thermal_expansion_coefficients")) // avoid duplicated material name by including
      46             :                                                     // the eigenstrain name this coeff corresponds
      47             :                                                     // to
      48             : {
      49         108 : }
      50             : 
      51             : void
      52      529840 : ComputeCrystalPlasticityThermalEigenstrain::computeQpDeformationGradient()
      53             : {
      54             :   // rotate the thermal deformation gradient for crystals based on Euler angles
      55      529840 :   _lattice_thermal_expansion_coefficients[_qp] =
      56      529840 :       _thermal_expansion_coefficients.rotated(_crysrot[_qp]);
      57             : 
      58             :   // compute the deformation gradient due to thermal expansion
      59      529840 :   Real dtheta = (_temperature[_qp] - _temperature_old[_qp]) * _substep_dt / _dt;
      60             :   RankTwoTensor residual_equivalent_thermal_expansion_increment =
      61      529840 :       RankTwoTensor::Identity() - dtheta * _lattice_thermal_expansion_coefficients[_qp];
      62      529840 :   _deformation_gradient[_qp] =
      63      529840 :       residual_equivalent_thermal_expansion_increment.inverse() * _deformation_gradient_old[_qp];
      64             : 
      65             :   // compute the derivative of deformation gradient w.r.t temperature
      66      529840 :   if (_ddeformation_gradient_dT)
      67      529840 :     (*_ddeformation_gradient_dT)[_qp] =
      68      529840 :         _lattice_thermal_expansion_coefficients[_qp] * _deformation_gradient[_qp];
      69      529840 : }

Generated by: LCOV version 1.14