LCOV - code coverage report
Current view: top level - src/materials - ComputePlasticHeatEnergy.C (source / functions) Hit Total Coverage
Test: idaholab/moose tensor_mechanics: d6b47a Lines: 27 29 93.1 %
Date: 2024-02-27 11:53:14 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://www.mooseframework.org
       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 "ComputePlasticHeatEnergy.h"
      11             : 
      12             : registerMooseObject("TensorMechanicsApp", ComputePlasticHeatEnergy);
      13             : 
      14             : InputParameters
      15          12 : ComputePlasticHeatEnergy::validParams()
      16             : {
      17          12 :   InputParameters params = Material::validParams();
      18          24 :   params.addParam<std::string>("base_name",
      19             :                                "Optional parameter that allows the user to define "
      20             :                                "multiple mechanics material systems on the same "
      21             :                                "block, i.e. for multiple phases");
      22          12 :   params.addClassDescription("Plastic heat energy density = stress * plastic_strain_rate");
      23          12 :   return params;
      24           0 : }
      25             : 
      26           9 : ComputePlasticHeatEnergy::ComputePlasticHeatEnergy(const InputParameters & parameters)
      27             :   : DerivativeMaterialInterface<Material>(parameters),
      28           9 :     _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
      29          18 :     _plastic_strain(getMaterialProperty<RankTwoTensor>("plastic_strain")),
      30          18 :     _plastic_strain_old(getMaterialPropertyOld<RankTwoTensor>("plastic_strain")),
      31          18 :     _stress(getMaterialProperty<RankTwoTensor>(_base_name + "stress")),
      32          18 :     _Jacobian_mult(getMaterialProperty<RankFourTensor>(_base_name + "Jacobian_mult")),
      33          18 :     _elasticity_tensor(getMaterialProperty<RankFourTensor>(_base_name + "elasticity_tensor")),
      34           9 :     _plastic_heat(declareProperty<Real>(_base_name + "plastic_heat")),
      35          18 :     _dplastic_heat_dstrain(declareProperty<RankTwoTensor>(_base_name + "dplastic_heat_dstrain"))
      36             : {
      37           9 : }
      38             : 
      39             : void
      40         480 : ComputePlasticHeatEnergy::computeQpProperties()
      41             : {
      42         480 :   _plastic_heat[_qp] =
      43         480 :       _stress[_qp].doubleContraction(_plastic_strain[_qp] - _plastic_strain_old[_qp]) / _dt;
      44         480 :   if (_fe_problem.currentlyComputingJacobian())
      45             :   {
      46          16 :     if (_plastic_strain[_qp] == _plastic_strain_old[_qp])
      47             :       // no plastic deformation, so _elasticity_tensor = _Jacobian_mult
      48           0 :       _dplastic_heat_dstrain[_qp] = RankTwoTensor();
      49             :     else
      50             :     {
      51          16 :       _dplastic_heat_dstrain[_qp] =
      52          16 :           (_plastic_strain[_qp] - _plastic_strain_old[_qp]).initialContraction(_Jacobian_mult[_qp]);
      53          16 :       _dplastic_heat_dstrain[_qp] += _stress[_qp];
      54          16 :       _dplastic_heat_dstrain[_qp] -=
      55          16 :           _stress[_qp].initialContraction(_elasticity_tensor[_qp].invSymm() * _Jacobian_mult[_qp]);
      56          16 :       _dplastic_heat_dstrain[_qp] /= _dt;
      57             :     }
      58             :   }
      59         480 : }

Generated by: LCOV version 1.14