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