www.mooseframework.org
Public Member Functions | Private Attributes | List of all members
NSPressureDerivs< T > Class Template Reference

Class outside the Moose hierarchy that contains common functionality for computing derivatives of the pressure variable. More...

#include <NSPressureDerivs.h>

Public Member Functions

 NSPressureDerivs (T &x)
 
Real get_grad (unsigned i)
 The primary interfaces for computing pressure derivatives. More...
 
Real get_hess (unsigned i, unsigned j)
 

Private Attributes

T & _data
 

Detailed Description

template<class T>
class NSPressureDerivs< T >

Class outside the Moose hierarchy that contains common functionality for computing derivatives of the pressure variable.

This class is templated so that it can be used by either a Kernel object or a BC object.

Definition at line 25 of file NSPressureDerivs.h.

Constructor & Destructor Documentation

◆ NSPressureDerivs()

template<class T>
NSPressureDerivs< T >::NSPressureDerivs ( T &  x)

Definition at line 44 of file NSPressureDerivs.h.

44  : _data(x)
45 {
46 }

Member Function Documentation

◆ get_grad()

template<class T >
Real NSPressureDerivs< T >::get_grad ( unsigned  i)

The primary interfaces for computing pressure derivatives.

Requires access to protected values from the _data reference. The indices input to these functions are in terms of the "canonical" variable numbering.

Definition at line 50 of file NSPressureDerivs.h.

Referenced by NSPressureNeumannBC::computeJacobianHelper(), NSMomentumInviscidFluxWithGradP::pressureQpJacobianHelper(), NSMomentumInviscidBC::pressureQpJacobianHelper(), and NSEnergyInviscidBC::qpJacobianTermC().

51 {
52  // Convenience vars
53  const Real u = _data._u_vel[_data._qp];
54  const Real v = _data._v_vel[_data._qp];
55  const Real w = _data._w_vel[_data._qp];
56 
57  const Real vel2 = (u * u + v * v + w * w);
58  const Real gam = _data._fp.gamma();
59 
60  switch (i)
61  {
62  case 0: // dP/d(rho)
63  return 0.5 * (gam - 1.0) * vel2;
64 
65  case 1: // dP/d(rho*u)
66  return (1.0 - gam) * u;
67 
68  case 2: // dP/d(rho*v)
69  return (1.0 - gam) * v;
70 
71  case 3: // dP/d(rho*w)
72  return (1.0 - gam) * w;
73 
74  case 4: // dP/d(rho*e)
75  return gam - 1.;
76 
77  default:
78  mooseError("Should not get here!");
79  break;
80  }
81 }

◆ get_hess()

template<class T >
Real NSPressureDerivs< T >::get_hess ( unsigned  i,
unsigned  j 
)

Definition at line 85 of file NSPressureDerivs.h.

Referenced by NSMomentumInviscidFluxWithGradP::pressureQpJacobianHelper().

86 {
87  // Convenience variables
88  const Real U0 = _data._rho[_data._qp];
89 
90  const Real u = _data._u_vel[_data._qp];
91  const Real v = _data._v_vel[_data._qp];
92  const Real w = _data._w_vel[_data._qp];
93  const Real vel2 = (u * u + v * v + w * w);
94 
95  // Save some typing...
96  const Real gam = _data._fp.gamma();
97 
98  // A frequently-used variable
99  const Real tmp = (1.0 - gam) / U0;
100 
101  // Only lower-triangle of matrix is defined, it is symmetric
102  if (i < j)
103  std::swap(i, j);
104 
105  // Map (i,j) into row-major storage index, 5 entries per row
106  const unsigned int idx = 5 * i + j;
107 
108  switch (idx)
109  {
110  // Row 0
111  case 0: // rho, rho derivative
112  return tmp * vel2;
113 
114  // Row 1
115  case 5: // rho*u, rho
116  return -tmp * u;
117 
118  case 6: // rho*u, rho*u
119  return tmp;
120 
121  // Row 2
122  case 10: // rho*v, rho
123  return -tmp * v;
124 
125  case 12: // rho*v, rho*v
126  return tmp;
127 
128  // Row 3
129  case 15: // rho*w, rho
130  return -tmp * w;
131 
132  case 18: // rho*w, rho*w
133  return tmp;
134 
135  case 11:
136  case 16:
137  case 17:
138  case 20:
139  case 21:
140  case 22:
141  case 23:
142  case 24:
143  return 0.;
144 
145  default:
146  mooseError("Should not get here!");
147  break;
148  }
149 
150  return 0.0;
151 }

Member Data Documentation

◆ _data

template<class T>
T& NSPressureDerivs< T >::_data
private

Definition at line 40 of file NSPressureDerivs.h.


The documentation for this class was generated from the following file: