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 "PlasticHeatEnergy.h" 11 : #include "MooseMesh.h" 12 : #include "MooseVariable.h" 13 : 14 : registerMooseObject("TensorMechanicsApp", PlasticHeatEnergy); 15 : 16 : InputParameters 17 6 : PlasticHeatEnergy::validParams() 18 : { 19 6 : InputParameters params = Kernel::validParams(); 20 6 : params.addClassDescription("Plastic heat energy density = coeff * stress * plastic_strain_rate"); 21 12 : params.addRequiredCoupledVar("displacements", 22 : "The string of displacements suitable for the problem statement"); 23 12 : params.addParam<std::string>("base_name", "Material property base name"); 24 12 : params.addParam<Real>("coeff", 1.0, "Heat energy density = coeff * stress * plastic_strain_rate"); 25 6 : return params; 26 0 : } 27 : 28 3 : PlasticHeatEnergy::PlasticHeatEnergy(const InputParameters & parameters) 29 : : Kernel(parameters), 30 3 : _coeff(getParam<Real>("coeff")), 31 6 : _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""), 32 6 : _plastic_heat(getMaterialProperty<Real>(_base_name + "plastic_heat")), 33 3 : _dplastic_heat_dstrain( 34 3 : getMaterialProperty<RankTwoTensor>(_base_name + "dplastic_heat_dstrain")), 35 3 : _ndisp(coupledComponents("displacements")), 36 6 : _disp_var(_ndisp) 37 : { 38 12 : for (unsigned int i = 0; i < _ndisp; ++i) 39 9 : _disp_var[i] = coupled("displacements", i); 40 : 41 : // Checking for consistency between mesh size and length of the provided displacements vector 42 3 : if (_ndisp != _mesh.dimension()) 43 0 : mooseError("PlasticHeatEnergy: The number of displacement variables supplied must match the " 44 : "mesh dimension."); 45 3 : } 46 : 47 : Real 48 3712 : PlasticHeatEnergy::computeQpResidual() 49 : { 50 3712 : return -_test[_i][_qp] * _coeff * _plastic_heat[_qp]; 51 : } 52 : 53 : Real 54 1024 : PlasticHeatEnergy::computeQpJacobian() 55 : { 56 1024 : return computeQpOffDiagJacobian(_var.number()); 57 : } 58 : 59 : Real 60 3072 : PlasticHeatEnergy::computeQpOffDiagJacobian(unsigned int jvar) 61 : { 62 6144 : for (unsigned int i = 0; i < _ndisp; ++i) 63 6144 : if (jvar == _disp_var[i]) 64 3072 : return -_test[_i][_qp] * _coeff * (_dplastic_heat_dstrain[_qp] * _grad_phi[_j][_qp])(i); 65 : 66 : return 0.0; 67 : }