www.mooseframework.org
NSPressureDerivs.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 NSPRESSUREDERIVS_H
8 #define NSPRESSUREDERIVS_H
9 
10 // FluidProperties includes
12 
21 template <class T>
23 {
24 public:
25  NSPressureDerivs(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 u = _data._u_vel[_data._qp];
51  const Real v = _data._v_vel[_data._qp];
52  const Real w = _data._w_vel[_data._qp];
53 
54  const Real vel2 = (u * u + v * v + w * w);
55  const Real gam = _data._fp.gamma();
56 
57  switch (i)
58  {
59  case 0: // dP/d(rho)
60  return 0.5 * (gam - 1.0) * vel2;
61 
62  case 1: // dP/d(rho*u)
63  return (1.0 - gam) * u;
64 
65  case 2: // dP/d(rho*v)
66  return (1.0 - gam) * v;
67 
68  case 3: // dP/d(rho*w)
69  return (1.0 - gam) * w;
70 
71  case 4: // dP/d(rho*e)
72  return gam - 1.;
73 
74  default:
75  mooseError("Should not get here!");
76  break;
77  }
78 }
79 
80 template <class T>
81 Real
82 NSPressureDerivs<T>::get_hess(unsigned i, unsigned j)
83 {
84  // Convenience variables
85  const Real U0 = _data._rho[_data._qp];
86 
87  const Real u = _data._u_vel[_data._qp];
88  const Real v = _data._v_vel[_data._qp];
89  const Real w = _data._w_vel[_data._qp];
90  const Real vel2 = (u * u + v * v + w * w);
91 
92  // Save some typing...
93  const Real gam = _data._fp.gamma();
94 
95  // A frequently-used variable
96  const Real tmp = (1.0 - gam) / U0;
97 
98  // Only lower-triangle of matrix is defined, it is symmetric
99  if (i < j)
100  std::swap(i, j);
101 
102  // Map (i,j) into row-major storage index, 5 entries per row
103  const unsigned int idx = 5 * i + j;
104 
105  switch (idx)
106  {
107  // Row 0
108  case 0: // rho, rho derivative
109  return tmp * vel2;
110 
111  // Row 1
112  case 5: // rho*u, rho
113  return -tmp * u;
114 
115  case 6: // rho*u, rho*u
116  return tmp;
117 
118  // Row 2
119  case 10: // rho*v, rho
120  return -tmp * v;
121 
122  case 12: // rho*v, rho*v
123  return tmp;
124 
125  // Row 3
126  case 15: // rho*w, rho
127  return -tmp * w;
128 
129  case 18: // rho*w, rho*w
130  return tmp;
131 
132  case 11:
133  case 16:
134  case 17:
135  case 20:
136  case 21:
137  case 22:
138  case 23:
139  case 24:
140  return 0.;
141 
142  default:
143  mooseError("Should not get here!");
144  break;
145  }
146 
147  return 0.0;
148 }
149 
150 #endif // NSPRESSUREDERIVS_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 pressure derivatives.
Real get_hess(unsigned i, unsigned j)