www.mooseframework.org
Public Member Functions | Private Attributes | List of all members
NSTemperatureDerivs< T > Class Template Reference

Class outside the Moose hierarchy that contains common functionality for computing derivatives of the temperature variable. More...

#include <NSTemperatureDerivs.h>

Public Member Functions

 NSTemperatureDerivs (T &x)
 
Real get_grad (unsigned i)
 The primary interfaces for computing temperature derivatives. More...
 
Real get_hess (unsigned i, unsigned j)
 

Private Attributes

T & _data
 

Detailed Description

template<class T>
class NSTemperatureDerivs< T >

Class outside the Moose hierarchy that contains common functionality for computing derivatives of the temperature variable.

This class is templated so that it can be used by either a Kernel object or a BC object.

Definition at line 25 of file NSTemperatureDerivs.h.

Constructor & Destructor Documentation

◆ NSTemperatureDerivs()

template<class T>
NSTemperatureDerivs< T >::NSTemperatureDerivs ( T &  x)

Definition at line 44 of file NSTemperatureDerivs.h.

44  : _data(x)
45 {
46 }

Member Function Documentation

◆ get_grad()

template<class T >
Real NSTemperatureDerivs< T >::get_grad ( unsigned  i)

The primary interfaces for computing temperature derivatives.

Requires access to protected values from the _data reference. The indices input to these functions are in terms of the "canonical" variable numbering.

Definition at line 50 of file NSTemperatureDerivs.h.

Referenced by NSEnergyThermalFlux::computeJacobianHelper_value(), NSEnergyViscousBC::computeQpJacobian(), and NSEnergyViscousBC::computeQpOffDiagJacobian().

51 {
52  // Convenience vars
53  const Real U0 = _data._rho[_data._qp];
54  const Real U1 = _data._rho_u[_data._qp];
55  const Real U2 = _data._rho_v[_data._qp];
56  const Real U3 = _data._rho_w[_data._qp];
57  const Real U4 = _data._rho_E[_data._qp];
58 
59  const Real rho2 = U0 * U0;
60  const Real mom2 = U1 * U1 + U2 * U2 + U3 * U3;
61  const Real tmp = -1.0 / rho2 / _data._fp.cv();
62 
63  switch (i)
64  {
65  case 0: // dT/d(rho)
66  return (U4 - (mom2 / U0)) * tmp;
67 
68  case 1: // dT/d(rho*u)
69  return U1 * tmp;
70 
71  case 2: // dT/d(rho*v)
72  return U2 * tmp;
73 
74  case 3: // dT/d(rho*w)
75  return U3 * tmp;
76 
77  case 4: // dT/d(rho*e)
78  return -U0 * tmp;
79 
80  default:
81  mooseError("Should not get here!");
82  break;
83  }
84 }

◆ get_hess()

template<class T >
Real NSTemperatureDerivs< T >::get_hess ( unsigned  i,
unsigned  j 
)

Definition at line 88 of file NSTemperatureDerivs.h.

Referenced by NSEnergyThermalFlux::computeJacobianHelper_value(), NSEnergyViscousBC::computeQpJacobian(), and NSEnergyViscousBC::computeQpOffDiagJacobian().

89 {
90  // Convenience vars
91  const Real U0 = _data._rho[_data._qp];
92  const Real U1 = _data._rho_u[_data._qp];
93  const Real U2 = _data._rho_v[_data._qp];
94  const Real U3 = _data._rho_w[_data._qp];
95  const Real U4 = _data._rho_E[_data._qp];
96 
97  const Real rho2 = U0 * U0;
98  const Real rho3 = rho2 * U0;
99  const Real rho4 = rho3 * U0;
100  const Real mom2 = U1 * U1 + U2 * U2 + U3 * U3;
101 
102  const Real cv = _data._fp.cv();
103  const Real tmp = -1.0 / rho2 / cv;
104 
105  // Only lower-triangle of matrix is defined, it is symmetric
106  if (i < j)
107  std::swap(i, j);
108 
109  // Map (i,j) into row-major storage index, 5 entries per row
110  unsigned idx = 5 * i + j;
111 
112  switch (idx)
113  {
114  // Row 0
115  case 0: // rho, rho derivative
116  return 2.0 * U4 / rho3 / cv - 3.0 * mom2 / rho4 / cv;
117 
118  // Row 1
119  case 5: // rho*u, rho
120  return 2.0 * U1 / rho3 / cv;
121 
122  case 6: // rho*u, rho*u
123  return tmp;
124 
125  // Row 2
126  case 10: // rho*v, rho
127  return 2.0 * U2 / rho3 / cv;
128 
129  case 12: // rho*v, rho*v
130  return tmp;
131 
132  // Row 3
133  case 15: // rho*w, rho
134  return 2.0 * U3 / rho3 / cv;
135 
136  case 18: // rho*w, rho*w
137  return tmp;
138 
139  // Row 4
140  case 20: // rho*e, rho
141  return tmp;
142 
143  case 11:
144  case 16:
145  case 17:
146  case 21:
147  case 22:
148  case 23:
149  case 24:
150  return 0.0;
151 
152  default:
153  mooseError("Should not get here!");
154  break;
155  }
156 
157  return 0.0;
158 }

Member Data Documentation

◆ _data

template<class T>
T& NSTemperatureDerivs< T >::_data
private

Definition at line 40 of file NSTemperatureDerivs.h.


The documentation for this class was generated from the following file: