www.mooseframework.org
NSEnergyThermalFlux.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 // Navier-Stokes includes
9 #include "NS.h"
10 #include "NSEnergyThermalFlux.h"
11 
12 template <>
13 InputParameters
15 {
16  InputParameters params = validParams<NSKernel>();
17  params.addClassDescription("This class is responsible for computing residuals and Jacobian terms "
18  "for the k * grad(T) * grad(phi) term in the Navier-Stokes energy "
19  "equation.");
20  params.addRequiredCoupledVar(NS::temperature, "temperature");
21  return params;
22 }
23 
24 NSEnergyThermalFlux::NSEnergyThermalFlux(const InputParameters & parameters)
25  : NSKernel(parameters),
26  _grad_temp(coupledGradient(NS::temperature)),
27  _thermal_conductivity(getMaterialProperty<Real>("thermal_conductivity")),
28  // Temperature derivative computing object
29  _temp_derivs(*this)
30 {
31  // Store pointers to all variable gradients in a single vector.
32  _gradU.resize(5);
33  _gradU[0] = &_grad_rho;
34  _gradU[1] = &_grad_rho_u;
35  _gradU[2] = &_grad_rho_v;
36  _gradU[3] = &_grad_rho_w;
37  _gradU[4] = &_grad_rho_E;
38 }
39 
40 Real
42 {
43  // k * grad(T) * grad(phi)
44  return _thermal_conductivity[_qp] * (_grad_temp[_qp] * _grad_test[_i][_qp]);
45 }
46 
47 Real
49 {
50  // The "on-diagonal" Jacobian for the energy equation
51  // corresponds to variable number 4.
52  return computeJacobianHelper_value(/*var_number=*/4);
53 }
54 
55 Real
57 {
58  if (isNSVariable(jvar))
60  else
61  return 0.0;
62 }
63 
64 Real
66 {
67  // The value to return
68  Real result = 0.0;
69 
70  // I used "ell" here as the loop counter since it matches the
71  // "\ell" used in my LaTeX notes.
72  for (unsigned int ell = 0; ell < 3; ++ell)
73  {
74  // Accumulate the first dot product term
75  Real intermediate_result = _temp_derivs.get_grad(var_number) * _grad_phi[_j][_qp](ell);
76 
77  // Now accumulate the Hessian term
78  Real hess_term = 0.0;
79  for (unsigned n = 0; n < 5; ++n)
80  {
81  // hess_term += get_hess(m,n) * gradU[n](ell); // ideally... but you can't have a
82  // vector<VariableGradient&> :-(
83  hess_term += _temp_derivs.get_hess(var_number, n) *
84  (*_gradU[n])[_qp](ell); // dereference pointer to get value
85  }
86 
87  // Accumulate the second dot product term
88  intermediate_result += hess_term * _phi[_j][_qp];
89 
90  // Hit intermediate_result with the test function, accumulate in the final value
91  result += intermediate_result * _grad_test[_i][_qp](ell);
92  }
93 
94  // Return result, don't forget to multiply by "k"!
95  return _thermal_conductivity[_qp] * result;
96 }
Definition: NS.h:13
NSEnergyThermalFlux(const InputParameters &parameters)
This class couples together all the variables for the compressible Navier-Stokes equations to allow t...
Definition: NSKernel.h:27
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
Real get_grad(unsigned i)
The primary interfaces for computing temperature derivatives.
virtual Real computeQpResidual()
NSTemperatureDerivs< NSEnergyThermalFlux > _temp_derivs
const VariableGradient & _grad_rho_w
Definition: NSKernel.h:48
const std::string temperature
Definition: NS.h:25
InputParameters validParams< NSKernel >()
Definition: NSKernel.C:20
Real computeJacobianHelper_value(unsigned var_number)
virtual Real computeQpJacobian()
const VariableGradient & _grad_rho
Definition: NSKernel.h:45
bool isNSVariable(unsigned var)
Helper functions for mapping Moose variable numberings into the "canonical" numbering for the compres...
Definition: NSKernel.C:76
InputParameters validParams< NSEnergyThermalFlux >()
const VariableGradient & _grad_rho_u
Definition: NSKernel.h:46
const VariableGradient & _grad_temp
std::vector< const VariableGradient * > _gradU
const MaterialProperty< Real > & _thermal_conductivity
const VariableGradient & _grad_rho_v
Definition: NSKernel.h:47
const VariableGradient & _grad_rho_E
Definition: NSKernel.h:49
unsigned mapVarNumber(unsigned var)
Definition: NSKernel.C:86
Real get_hess(unsigned i, unsigned j)