https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NSTemperatureDerivs.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 U0 = _data._rho[_data._qp];
53 const Real U1 = _data._rho_u[_data._qp];
54 const Real U2 = _data._rho_v[_data._qp];
55 const Real U3 = _data._rho_w[_data._qp];
56 const Real U4 = _data._rho_et[_data._qp];
57
58 const Real rho2 = U0 * U0;
59 const Real mom2 = U1 * U1 + U2 * U2 + U3 * U3;
60 const Real tmp = -1.0 / rho2 / _data._fp.cv();
61
62 switch (i)
63 {
64 case 0: // dT/d(rho)
65 return (U4 - (mom2 / U0)) * tmp;
66
67 case 1: // dT/d(rho*u)
68 return U1 * tmp;
69
70 case 2: // dT/d(rho*v)
71 return U2 * tmp;
72
73 case 3: // dT/d(rho*w)
74 return U3 * tmp;
75
76 case 4: // dT/d(rho*e)
77 return -U0 * tmp;
78
79 default:
80 mooseError("Should not get here!");
81 break;
82 }
83}
84
85template <class T>
86Real
87NSTemperatureDerivs<T>::get_hess(unsigned i, unsigned j)
88{
89 // Convenience vars
90 const Real U0 = _data._rho[_data._qp];
91 const Real U1 = _data._rho_u[_data._qp];
92 const Real U2 = _data._rho_v[_data._qp];
93 const Real U3 = _data._rho_w[_data._qp];
94 const Real U4 = _data._rho_et[_data._qp];
95
96 const Real rho2 = U0 * U0;
97 const Real rho3 = rho2 * U0;
98 const Real rho4 = rho3 * U0;
99 const Real mom2 = U1 * U1 + U2 * U2 + U3 * U3;
100
101 const Real cv = _data._fp.cv();
102 const Real tmp = -1.0 / rho2 / cv;
103
104 // Only lower-triangle of matrix is defined, it is symmetric
105 if (i < j)
106 std::swap(i, j);
107
108 // Map (i,j) into row-major storage index, 5 entries per row
109 unsigned idx = 5 * i + j;
110
111 switch (idx)
112 {
113 // Row 0
114 case 0: // rho, rho derivative
115 return 2.0 * U4 / rho3 / cv - 3.0 * mom2 / rho4 / cv;
116
117 // Row 1
118 case 5: // rho*u, rho
119 return 2.0 * U1 / rho3 / cv;
120
121 case 6: // rho*u, rho*u
122 return tmp;
123
124 // Row 2
125 case 10: // rho*v, rho
126 return 2.0 * U2 / rho3 / cv;
127
128 case 12: // rho*v, rho*v
129 return tmp;
130
131 // Row 3
132 case 15: // rho*w, rho
133 return 2.0 * U3 / rho3 / cv;
134
135 case 18: // rho*w, rho*w
136 return tmp;
137
138 // Row 4
139 case 20: // rho*e, rho
140 return tmp;
141
142 case 11:
143 case 16:
144 case 17:
145 case 21:
146 case 22:
147 case 23:
148 case 24:
149 return 0.0;
150
151 default:
152 mooseError("Should not get here!");
153 break;
154 }
155
156 return 0.0;
157}
const std::vector< double > x
const double T
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 temperature derivatives.