www.mooseframework.org
SpecificHeatConductionTimeDerivative.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
8 
9 template <>
10 InputParameters
12 {
13  InputParameters params = validParams<TimeDerivative>();
14  params.addClassDescription(
15  "Time derivative term $\\rho c_p \\frac{\\partial T}{\\partial t}$ of "
16  "the heat equation with the specific heat $c_p$ and the density $\\rho$ as arguments.");
17 
18  // Density may be changing with deformation, so we must integrate
19  // over current volume by setting the use_displaced_mesh flag.
20  params.set<bool>("use_displaced_mesh") = true;
21 
22  params.addParam<MaterialPropertyName>(
23  "specific_heat", "specific_heat", "Property name of the specific heat material property");
24  params.addParam<MaterialPropertyName>(
25  "density", "density", "Property name of the density material property");
26  params.addCoupledVar("args", "Vector of additional arguments of the specific heat and density");
27  return params;
28 }
29 
31  const InputParameters & parameters)
32  : DerivativeMaterialInterface<JvarMapKernelInterface<TimeDerivative>>(parameters),
33  _specific_heat(getMaterialProperty<Real>("specific_heat")),
34  _d_specific_heat_dT(getMaterialPropertyDerivative<Real>("specific_heat", _var.name())),
35  _density(getMaterialProperty<Real>("density")),
36  _d_density_dT(getMaterialPropertyDerivative<Real>("density", _var.name()))
37 {
38  // Get number of coupled variables
39  unsigned int nvar = _coupled_moose_vars.size();
40 
41  // reserve space for derivatives
42  _d_specific_heat_dargs.resize(nvar);
43  _d_density_dargs.resize(nvar);
44 
45  // Iterate over all coupled variables
46  for (unsigned int i = 0; i < nvar; ++i)
47  {
48  const std::string iname = _coupled_moose_vars[i]->name();
49  _d_specific_heat_dargs[i] = &getMaterialPropertyDerivative<Real>("specific_heat", iname);
50  _d_density_dargs[i] = &getMaterialPropertyDerivative<Real>("density", iname);
51  }
52 }
53 
54 Real
56 {
57  return _specific_heat[_qp] * _density[_qp] * TimeDerivative::computeQpResidual();
58 }
59 
60 Real
62 {
63  const Real dT = TimeDerivative::computeQpResidual();
64 
65  // on-diagonal Jacobian with all terms that may depend on the kernel variable
66  return _specific_heat[_qp] * _density[_qp] * TimeDerivative::computeQpJacobian() +
67  _d_specific_heat_dT[_qp] * _phi[_j][_qp] * _density[_qp] * dT +
68  _specific_heat[_qp] * _d_density_dT[_qp] * _phi[_j][_qp] * dT;
69 }
70 
71 Real
73 {
74  // get the coupled variable jvar is referring to
75  const unsigned int cvar = mapJvarToCvar(jvar);
76 
77  // off-diagonal contribution with terms that depend on coupled variables
78  const Real dT = TimeDerivative::computeQpResidual();
79  return (*_d_specific_heat_dargs[cvar])[_qp] * _phi[_j][_qp] * _density[_qp] * dT +
80  _specific_heat[_qp] * (*_d_density_dargs[cvar])[_qp] * _phi[_j][_qp] * dT;
81 }
InputParameters validParams< SpecificHeatConductionTimeDerivative >()
std::vector< const MaterialProperty< Real > * > _d_density_dargs
const MaterialProperty< Real > & _density
Density and its derivatives with respect to temperature and other coupled variables.
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
std::vector< const MaterialProperty< Real > * > _d_specific_heat_dargs
const MaterialProperty< Real > & _specific_heat
Specific heat and its derivatives with respect to temperature and other coupled variables.
SpecificHeatConductionTimeDerivative(const InputParameters &parameters)