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 "HeatCapacityConductionTimeDerivative.h" 11 : 12 : registerMooseObject("HeatTransferApp", HeatCapacityConductionTimeDerivative); 13 : 14 : InputParameters 15 0 : HeatCapacityConductionTimeDerivative::validParams() 16 : { 17 0 : InputParameters params = JvarMapKernelInterface<TimeDerivative>::validParams(); 18 0 : params.addClassDescription("Time derivative term $C_p \\frac{\\partial T}{\\partial t}$ of " 19 : "the heat equation with the heat capacity $C_p$ as an argument."); 20 : 21 : // Density may be changing with deformation, so we must integrate 22 : // over current volume by setting the use_displaced_mesh flag. 23 0 : params.set<bool>("use_displaced_mesh") = true; 24 : 25 0 : params.addParam<MaterialPropertyName>( 26 : "heat_capacity", "heat_capacity", "Property name of the heat capacity material property"); 27 0 : return params; 28 0 : } 29 : 30 0 : HeatCapacityConductionTimeDerivative::HeatCapacityConductionTimeDerivative( 31 0 : const InputParameters & parameters) 32 : : DerivativeMaterialInterface<JvarMapKernelInterface<TimeDerivative>>(parameters), 33 0 : _heat_capacity(getMaterialProperty<Real>("heat_capacity")), 34 0 : _d_heat_capacity_dT(getMaterialPropertyDerivative<Real>("heat_capacity", _var.name())) 35 : { 36 : // get number of coupled variables 37 0 : unsigned int nvar = _coupled_moose_vars.size(); 38 : 39 : // reserve space for derivatives 40 0 : _d_heat_capacity_dargs.resize(nvar); 41 : 42 : // iterate over all coupled variables 43 0 : for (unsigned int i = 0; i < nvar; ++i) 44 0 : _d_heat_capacity_dargs[i] = 45 0 : &getMaterialPropertyDerivative<Real>("heat_capacity", _coupled_moose_vars[i]->name()); 46 0 : } 47 : 48 : Real 49 0 : HeatCapacityConductionTimeDerivative::computeQpResidual() 50 : { 51 0 : return _heat_capacity[_qp] * TimeDerivative::computeQpResidual(); 52 : } 53 : 54 : Real 55 0 : HeatCapacityConductionTimeDerivative::computeQpJacobian() 56 : { 57 : // on-diagonal Jacobian with all terms that may depend on the kernel variable 58 0 : return _heat_capacity[_qp] * TimeDerivative::computeQpJacobian() + 59 0 : _d_heat_capacity_dT[_qp] * _phi[_j][_qp] * TimeDerivative::computeQpResidual(); 60 : } 61 : 62 : Real 63 0 : HeatCapacityConductionTimeDerivative::computeQpOffDiagJacobian(unsigned int jvar) 64 : { 65 : // get the coupled variable jvar is referring to 66 : const unsigned int cvar = mapJvarToCvar(jvar); 67 : 68 : // off-diagonal contribution with terms that depend on coupled variables 69 0 : return (*_d_heat_capacity_dargs[cvar])[_qp] * _phi[_j][_qp] * TimeDerivative::computeQpResidual(); 70 : }