www.mooseframework.org
NSTemperatureDerivs.h
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 #ifndef NSTEMPERATUREDERIVS_H
8 #define NSTEMPERATUREDERIVS_H
9 
10 // FluidProperties includes
12 
21 template <class T>
23 {
24 public:
25  NSTemperatureDerivs(T & x);
26 
33  Real get_grad(unsigned i);
34  Real get_hess(unsigned i, unsigned j);
35 
36 private:
37  T & _data;
38 };
39 
40 template <class T>
42 {
43 }
44 
45 template <class T>
46 Real
48 {
49  // Convenience vars
50  const Real U0 = _data._rho[_data._qp];
51  const Real U1 = _data._rho_u[_data._qp];
52  const Real U2 = _data._rho_v[_data._qp];
53  const Real U3 = _data._rho_w[_data._qp];
54  const Real U4 = _data._rho_E[_data._qp];
55 
56  const Real rho2 = U0 * U0;
57  const Real mom2 = U1 * U1 + U2 * U2 + U3 * U3;
58  const Real tmp = -1.0 / rho2 / _data._fp.cv();
59 
60  switch (i)
61  {
62  case 0: // dT/d(rho)
63  return (U4 - (mom2 / U0)) * tmp;
64 
65  case 1: // dT/d(rho*u)
66  return U1 * tmp;
67 
68  case 2: // dT/d(rho*v)
69  return U2 * tmp;
70 
71  case 3: // dT/d(rho*w)
72  return U3 * tmp;
73 
74  case 4: // dT/d(rho*e)
75  return -U0 * tmp;
76 
77  default:
78  mooseError("Should not get here!");
79  break;
80  }
81 }
82 
83 template <class T>
84 Real
85 NSTemperatureDerivs<T>::get_hess(unsigned i, unsigned j)
86 {
87  // Convenience vars
88  const Real U0 = _data._rho[_data._qp];
89  const Real U1 = _data._rho_u[_data._qp];
90  const Real U2 = _data._rho_v[_data._qp];
91  const Real U3 = _data._rho_w[_data._qp];
92  const Real U4 = _data._rho_E[_data._qp];
93 
94  const Real rho2 = U0 * U0;
95  const Real rho3 = rho2 * U0;
96  const Real rho4 = rho3 * U0;
97  const Real mom2 = U1 * U1 + U2 * U2 + U3 * U3;
98 
99  const Real cv = _data._fp.cv();
100  const Real tmp = -1.0 / rho2 / cv;
101 
102  // Only lower-triangle of matrix is defined, it is symmetric
103  if (i < j)
104  std::swap(i, j);
105 
106  // Map (i,j) into row-major storage index, 5 entries per row
107  unsigned idx = 5 * i + j;
108 
109  switch (idx)
110  {
111  // Row 0
112  case 0: // rho, rho derivative
113  return 2.0 * U4 / rho3 / cv - 3.0 * mom2 / rho4 / cv;
114 
115  // Row 1
116  case 5: // rho*u, rho
117  return 2.0 * U1 / rho3 / cv;
118 
119  case 6: // rho*u, rho*u
120  return tmp;
121 
122  // Row 2
123  case 10: // rho*v, rho
124  return 2.0 * U2 / rho3 / cv;
125 
126  case 12: // rho*v, rho*v
127  return tmp;
128 
129  // Row 3
130  case 15: // rho*w, rho
131  return 2.0 * U3 / rho3 / cv;
132 
133  case 18: // rho*w, rho*w
134  return tmp;
135 
136  // Row 4
137  case 20: // rho*e, rho
138  return tmp;
139 
140  case 11:
141  case 16:
142  case 17:
143  case 21:
144  case 22:
145  case 23:
146  case 24:
147  return 0.0;
148 
149  default:
150  mooseError("Should not get here!");
151  break;
152  }
153 
154  return 0.0;
155 }
156 
157 #endif // NSTEMPERATUREDERIVS_H
Class outside the Moose hierarchy that contains common functionality for computing derivatives of the...
Real get_grad(unsigned i)
The primary interfaces for computing temperature derivatives.
Real get_hess(unsigned i, unsigned j)