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 "PorousFlowPlasticHeatEnergy.h" 11 : 12 : #include "MooseMesh.h" 13 : #include "MooseVariable.h" 14 : 15 : registerMooseObject("PorousFlowApp", PorousFlowPlasticHeatEnergy); 16 : 17 : InputParameters 18 199 : PorousFlowPlasticHeatEnergy::validParams() 19 : { 20 199 : InputParameters params = PlasticHeatEnergy::validParams(); 21 398 : params.addParam<bool>("strain_at_nearest_qp", 22 398 : false, 23 : "When calculating nodal porosity that depends on strain, use the strain at " 24 : "the nearest quadpoint. This adds a small extra computational burden, and " 25 : "is not necessary for simulations involving only linear lagrange elements. " 26 : " If you set this to true, you will also want to set the same parameter to " 27 : "true for related Kernels and Materials"); 28 398 : params.addRequiredParam<UserObjectName>( 29 : "PorousFlowDictator", "The UserObject that holds the list of PorousFlow variable names."); 30 199 : params.addClassDescription( 31 : "Plastic heat energy density source = (1 - porosity) * coeff * stress * plastic_strain_rate"); 32 199 : return params; 33 0 : } 34 : 35 110 : PorousFlowPlasticHeatEnergy::PorousFlowPlasticHeatEnergy(const InputParameters & parameters) 36 : : PlasticHeatEnergy(parameters), 37 110 : _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")), 38 220 : _strain_at_nearest_qp(getParam<bool>("strain_at_nearest_qp")), 39 220 : _nearest_qp(_strain_at_nearest_qp 40 110 : ? &getMaterialProperty<unsigned int>("PorousFlow_nearestqp_nodal") 41 : : nullptr), 42 220 : _porosity(getMaterialProperty<Real>("PorousFlow_porosity_nodal")), 43 220 : _dporosity_dvar(getMaterialProperty<std::vector<Real>>("dPorousFlow_porosity_nodal_dvar")), 44 110 : _dporosity_dgradvar( 45 220 : getMaterialProperty<std::vector<RealGradient>>("dPorousFlow_porosity_nodal_dgradvar")) 46 : { 47 110 : } 48 : 49 : Real 50 77568 : PorousFlowPlasticHeatEnergy::computeQpResidual() 51 : { 52 77568 : return (1.0 - _porosity[_i]) * PlasticHeatEnergy::computeQpResidual(); 53 : } 54 : 55 : Real 56 122368 : PorousFlowPlasticHeatEnergy::computeQpJacobian() 57 : { 58 122368 : return computeQpOffDiagJacobian(_var.number()); 59 : } 60 : 61 : Real 62 153088 : PorousFlowPlasticHeatEnergy::computeQpOffDiagJacobian(unsigned int jvar) 63 : { 64 : // If the variable is not a PorousFlow variable, the Jacobian terms are 0 65 153088 : if (_dictator.notPorousFlowVariable(jvar)) 66 : return 0.0; 67 : 68 153088 : const Real res_no_porosity = PlasticHeatEnergy::computeQpResidual(); 69 153088 : const Real jac_no_porosity = PlasticHeatEnergy::computeQpOffDiagJacobian(jvar); 70 : 71 153088 : const unsigned pvar = _dictator.porousFlowVariableNum(jvar); 72 153088 : const unsigned nearest_qp = (_strain_at_nearest_qp ? (*_nearest_qp)[_i] : _i); 73 : 74 153088 : Real jac = (1.0 - _porosity[_i]) * jac_no_porosity - 75 153088 : _dporosity_dgradvar[_i][pvar] * _grad_phi[_j][nearest_qp] * res_no_porosity; 76 153088 : if (_i != _j) 77 : return jac; 78 : 79 19136 : return jac - _dporosity_dvar[_i][pvar] * res_no_porosity; 80 : }