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 "SpecificHeatConductionTimeDerivative.h" 11 : 12 : registerMooseObject("HeatTransferApp", SpecificHeatConductionTimeDerivative); 13 : 14 : InputParameters 15 41 : SpecificHeatConductionTimeDerivative::validParams() 16 : { 17 41 : InputParameters params = JvarMapKernelInterface<TimeDerivative>::validParams(); 18 41 : params.addClassDescription( 19 : "Time derivative term $\\rho c_p \\frac{\\partial T}{\\partial t}$ of " 20 : "the heat equation with the specific heat $c_p$ and the density $\\rho$ as arguments."); 21 : 22 : // Density may be changing with deformation, so we must integrate 23 : // over current volume by setting the use_displaced_mesh flag. 24 41 : params.set<bool>("use_displaced_mesh") = true; 25 : 26 82 : params.addParam<MaterialPropertyName>( 27 : "specific_heat", "specific_heat", "Property name of the specific heat material property"); 28 82 : params.addParam<MaterialPropertyName>( 29 : "density", "density", "Property name of the density material property"); 30 41 : return params; 31 0 : } 32 : 33 22 : SpecificHeatConductionTimeDerivative::SpecificHeatConductionTimeDerivative( 34 22 : const InputParameters & parameters) 35 : : DerivativeMaterialInterface<JvarMapKernelInterface<TimeDerivative>>(parameters), 36 22 : _specific_heat(getMaterialProperty<Real>("specific_heat")), 37 22 : _d_specific_heat_dT(getMaterialPropertyDerivative<Real>("specific_heat", _var.name())), 38 44 : _density(getMaterialProperty<Real>("density")), 39 44 : _d_density_dT(getMaterialPropertyDerivative<Real>("density", _var.name())) 40 : { 41 : // Get number of coupled variables 42 22 : unsigned int nvar = _coupled_moose_vars.size(); 43 : 44 : // reserve space for derivatives 45 22 : _d_specific_heat_dargs.resize(nvar); 46 22 : _d_density_dargs.resize(nvar); 47 : 48 : // Iterate over all coupled variables 49 22 : for (unsigned int i = 0; i < nvar; ++i) 50 : { 51 0 : const std::string iname = _coupled_moose_vars[i]->name(); 52 0 : _d_specific_heat_dargs[i] = &getMaterialPropertyDerivative<Real>("specific_heat", iname); 53 0 : _d_density_dargs[i] = &getMaterialPropertyDerivative<Real>("density", iname); 54 : } 55 22 : } 56 : 57 : Real 58 2809856 : SpecificHeatConductionTimeDerivative::computeQpResidual() 59 : { 60 2809856 : return _specific_heat[_qp] * _density[_qp] * TimeDerivative::computeQpResidual(); 61 : } 62 : 63 : Real 64 3014656 : SpecificHeatConductionTimeDerivative::computeQpJacobian() 65 : { 66 3014656 : const Real dT = TimeDerivative::computeQpResidual(); 67 : 68 : // on-diagonal Jacobian with all terms that may depend on the kernel variable 69 3014656 : return _specific_heat[_qp] * _density[_qp] * TimeDerivative::computeQpJacobian() + 70 3014656 : _d_specific_heat_dT[_qp] * _phi[_j][_qp] * _density[_qp] * dT + 71 3014656 : _specific_heat[_qp] * _d_density_dT[_qp] * _phi[_j][_qp] * dT; 72 : } 73 : 74 : Real 75 0 : SpecificHeatConductionTimeDerivative::computeQpOffDiagJacobian(unsigned int jvar) 76 : { 77 : // get the coupled variable jvar is referring to 78 : const unsigned int cvar = mapJvarToCvar(jvar); 79 : 80 : // off-diagonal contribution with terms that depend on coupled variables 81 0 : const Real dT = TimeDerivative::computeQpResidual(); 82 0 : return (*_d_specific_heat_dargs[cvar])[_qp] * _phi[_j][_qp] * _density[_qp] * dT + 83 0 : _specific_heat[_qp] * (*_d_density_dargs[cvar])[_qp] * _phi[_j][_qp] * dT; 84 : }