https://mooseframework.inl.gov
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 
23 template <class T>
25 {
26 public:
27  NSPressureDerivs(T & x);
28 
35  Real get_grad(unsigned i);
36  Real get_hess(unsigned i, unsigned j);
37 
38 private:
39  T & _data;
40 };
41 
42 template <class T>
44 {
45 }
46 
47 template <class T>
48 Real
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 
82 template <class T>
83 Real
84 NSPressureDerivs<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 }
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.
void mooseError(Args &&... args)
Real get_hess(unsigned i, unsigned j)
const std::vector< double > x
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string v
Definition: NS.h:84
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)