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