https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NSPressureDerivs.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
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#pragma once
11
12// FluidProperties includes
14
23template <class T>
25{
26public:
28
35 Real get_grad(unsigned i);
36 Real get_hess(unsigned i, unsigned j);
37
38private:
40};
41
42template <class T>
46
47template <class T>
48Real
50{
51 // Convenience vars
52 const Real u = _data._u_vel[_data._qp];
53 const Real v = _data._v_vel[_data._qp];
54 const Real w = _data._w_vel[_data._qp];
55
56 const Real vel2 = (u * u + v * v + w * w);
57 const Real gam = _data._fp.gamma();
58
59 switch (i)
60 {
61 case 0: // dP/d(rho)
62 return 0.5 * (gam - 1.0) * vel2;
63
64 case 1: // dP/d(rho*u)
65 return (1.0 - gam) * u;
66
67 case 2: // dP/d(rho*v)
68 return (1.0 - gam) * v;
69
70 case 3: // dP/d(rho*w)
71 return (1.0 - gam) * w;
72
73 case 4: // dP/d(rho*e)
74 return gam - 1.;
75
76 default:
77 mooseError("Should not get here!");
78 break;
79 }
80}
81
82template <class T>
83Real
84NSPressureDerivs<T>::get_hess(unsigned i, unsigned j)
85{
86 // Convenience variables
87 const Real U0 = _data._rho[_data._qp];
88
89 const Real u = _data._u_vel[_data._qp];
90 const Real v = _data._v_vel[_data._qp];
91 const Real w = _data._w_vel[_data._qp];
92 const Real vel2 = (u * u + v * v + w * w);
93
94 // Save some typing...
95 const Real gam = _data._fp.gamma();
96
97 // A frequently-used variable
98 const Real tmp = (1.0 - gam) / U0;
99
100 // Only lower-triangle of matrix is defined, it is symmetric
101 if (i < j)
102 std::swap(i, j);
103
104 // Map (i,j) into row-major storage index, 5 entries per row
105 const unsigned int idx = 5 * i + j;
106
107 switch (idx)
108 {
109 // Row 0
110 case 0: // rho, rho derivative
111 return tmp * vel2;
112
113 // Row 1
114 case 5: // rho*u, rho
115 return -tmp * u;
116
117 case 6: // rho*u, rho*u
118 return tmp;
119
120 // Row 2
121 case 10: // rho*v, rho
122 return -tmp * v;
123
124 case 12: // rho*v, rho*v
125 return tmp;
126
127 // Row 3
128 case 15: // rho*w, rho
129 return -tmp * w;
130
131 case 18: // rho*w, rho*w
132 return tmp;
133
134 case 11:
135 case 16:
136 case 17:
137 case 20:
138 case 21:
139 case 22:
140 case 23:
141 case 24:
142 return 0.;
143
144 default:
145 mooseError("Should not get here!");
146 break;
147 }
148
149 return 0.0;
150}
const std::vector< double > x
const double T
const double v
void mooseError(Args &&... args)
Class outside the Moose hierarchy that contains common functionality for computing derivatives of the...
Real get_hess(unsigned i, unsigned j)
Real get_grad(unsigned i)
The primary interfaces for computing pressure derivatives.