www.mooseframework.org
INSTemperature.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 /****************************************************************/
7 
8 #include "INSTemperature.h"
9 #include "MooseMesh.h"
10 
11 template <>
12 InputParameters
14 {
15  InputParameters params = validParams<Kernel>();
16 
17  params.addClassDescription("This class computes the residual and Jacobian contributions for the "
18  "incompressible Navier-Stokes temperature (energy) equation.");
19  // Coupled variables
20  params.addRequiredCoupledVar("u", "x-velocity");
21  params.addCoupledVar("v", "y-velocity"); // only required in 2D and 3D
22  params.addCoupledVar("w", "z-velocity"); // only required in 3D
23 
24  // Optional parameters
25  params.addParam<MaterialPropertyName>("rho_name", "rho", "density name");
26  params.addParam<MaterialPropertyName>("k_name", "k", "thermal conductivity name");
27  params.addParam<MaterialPropertyName>("cp_name", "cp", "specific heat name");
28 
29  return params;
30 }
31 
32 INSTemperature::INSTemperature(const InputParameters & parameters)
33  : Kernel(parameters),
34 
35  // Coupled variables
36  _u_vel(coupledValue("u")),
37  _v_vel(_mesh.dimension() >= 2 ? coupledValue("v") : _zero),
38  _w_vel(_mesh.dimension() == 3 ? coupledValue("w") : _zero),
39 
40  // Variable numberings
41  _u_vel_var_number(coupled("u")),
42  _v_vel_var_number(_mesh.dimension() >= 2 ? coupled("v") : libMesh::invalid_uint),
43  _w_vel_var_number(_mesh.dimension() == 3 ? coupled("w") : libMesh::invalid_uint),
44 
45  // Material Properties
46  _rho(getMaterialProperty<Real>("rho_name")),
47  _k(getMaterialProperty<Real>("k_name")),
48  _cp(getMaterialProperty<Real>("cp_name"))
49 {
50 }
51 
52 Real
54 {
55  // The convection part, rho * cp u.grad(T) * v.
56  // Note: _u is the temperature variable, _grad_u is its gradient.
57  Real convective_part = _rho[_qp] * _cp[_qp] *
58  (_u_vel[_qp] * _grad_u[_qp](0) + _v_vel[_qp] * _grad_u[_qp](1) +
59  _w_vel[_qp] * _grad_u[_qp](2)) *
60  _test[_i][_qp];
61 
62  // Thermal conduction part, k * grad(T) * grad(v)
63  Real conduction_part = _k[_qp] * _grad_u[_qp] * _grad_test[_i][_qp];
64 
65  return convective_part + conduction_part;
66 }
67 
68 Real
70 {
71  RealVectorValue U(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
72 
73  Real convective_part = _rho[_qp] * _cp[_qp] * (U * _grad_phi[_j][_qp]) * _test[_i][_qp];
74  Real conduction_part = _k[_qp] * (_grad_phi[_j][_qp] * _grad_test[_i][_qp]);
75 
76  return convective_part + conduction_part;
77 }
78 
79 Real
81 {
82  if (jvar == _u_vel_var_number)
83  {
84  Real convective_part = _rho[_qp] * _cp[_qp] * _phi[_j][_qp] * _grad_u[_qp](0) * _test[_i][_qp];
85  return convective_part;
86  }
87 
88  else if (jvar == _v_vel_var_number)
89  {
90  Real convective_part = _rho[_qp] * _cp[_qp] * _phi[_j][_qp] * _grad_u[_qp](1) * _test[_i][_qp];
91  return convective_part;
92  }
93 
94  else if (jvar == _w_vel_var_number)
95  {
96  Real convective_part = _rho[_qp] * _cp[_qp] * _phi[_j][_qp] * _grad_u[_qp](2) * _test[_i][_qp];
97  return convective_part;
98  }
99  else
100  return 0;
101 }
const VariableValue & _v_vel
virtual Real computeQpJacobian()
INSTemperature(const InputParameters &parameters)
const MaterialProperty< Real > & _rho
const VariableValue & _u_vel
InputParameters validParams< INSTemperature >()
virtual Real computeQpResidual()
unsigned _v_vel_var_number
const VariableValue & _w_vel
unsigned _u_vel_var_number
unsigned _w_vel_var_number
const MaterialProperty< Real > & _k
virtual Real computeQpOffDiagJacobian(unsigned jvar)
const MaterialProperty< Real > & _cp