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

Class outside the Moose hierarchy that contains common functionality for computing derivatives of the viscous stress tensor. More...

#include <NSViscStressTensorDerivs.h>

Public Member Functions

 NSViscStressTensorDerivs (T &x)
 
Real dtau (unsigned k, unsigned ell, unsigned m)
 The primary interface for computing viscous stress tensor derivatives. More...
 

Private Attributes

T & _data
 

Detailed Description

template<class T>
class NSViscStressTensorDerivs< T >

Class outside the Moose hierarchy that contains common functionality for computing derivatives of the viscous stress tensor.

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

Definition at line 19 of file NSViscStressTensorDerivs.h.

Constructor & Destructor Documentation

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

Definition at line 37 of file NSViscStressTensorDerivs.h.

37  : _data(x)
38 {
39 }

Member Function Documentation

template<class T >
Real NSViscStressTensorDerivs< T >::dtau ( unsigned  k,
unsigned  ell,
unsigned  m 
)

The primary interface for computing viscous stress tensor derivatives.

Requires access to protected data from the the underlying data. Uses index notation from the notes.

Definition at line 43 of file NSViscStressTensorDerivs.h.

Referenced by NSMomentumViscousFlux::computeQpJacobian(), NSMomentumViscousBC::computeQpJacobian(), NSEnergyViscousFlux::computeQpOffDiagJacobian(), NSMomentumViscousFlux::computeQpOffDiagJacobian(), NSMomentumViscousBC::computeQpOffDiagJacobian(), and NSEnergyViscousBC::computeQpOffDiagJacobian().

44 {
45  // Try to access underlying data. Since this class is a friend, we can
46  // directly access _qp and other protected data. This only works if the
47  // individual variables have the **same names** in all types T which may
48  // be used to construct this class.
49 
50  //
51  // Some error checking on input indices...
52  //
53 
54  // 0 <= k,ell <= 2
55  if (k > 2 || ell > 2)
56  mooseError("Error, 0 <= k,ell <= 2 violated!");
57 
58  // 0 <= m <= 4
59  if (m >= 5)
60  mooseError("Error, m <= 4 violated!");
61 
62  //
63  // Convenience variables
64  //
65 
66  const Real rho = _data._rho[_data._qp];
67  const Real rho2 = rho * rho;
68  const Real phij = _data._phi[_data._j][_data._qp];
69 
70  const Real mu = _data._dynamic_viscosity[_data._qp];
71  const Real nu = mu / rho;
72 
73  const RealVectorValue U(
74  _data._rho_u[_data._qp], _data._rho_v[_data._qp], _data._rho_w[_data._qp]);
75 
76  const Real divU = _data._grad_rho_u[_data._qp](0) + _data._grad_rho_v[_data._qp](1) +
77  _data._grad_rho_w[_data._qp](2);
78 
79  // This makes a copy...but the resulting code is cleaner
80  std::vector<RealVectorValue> gradU(3);
81  gradU[0] = _data._grad_rho_u[_data._qp];
82  gradU[1] = _data._grad_rho_v[_data._qp];
83  gradU[2] = _data._grad_rho_w[_data._qp];
84 
85  // So we can refer to gradients without repeated indexing.
86  const RealVectorValue & grad_phij = _data._grad_phi[_data._j][_data._qp];
87  const RealVectorValue & grad_rho = _data._grad_rho[_data._qp];
88 
89  switch (m)
90  {
91  case 0: // density
92  {
93  const Real term1 = 2.0 / rho2 * (U(k) * grad_rho(ell) + U(ell) * grad_rho(k)) * phij;
94  const Real term2 = -1.0 / rho * ((gradU[k](ell) + gradU[ell](k)) * phij +
95  (U(k) * grad_phij(ell) + U(ell) * grad_phij(k)));
96 
97  // Kronecker delta terms
98  Real term3 = 0.0;
99  Real term4 = 0.0;
100  if (k == ell)
101  {
102  term3 = -4.0 / 3.0 / rho2 * (U * grad_rho) * phij;
103  term4 = 2.0 / 3.0 / rho * (U * grad_phij + divU * phij);
104  }
105 
106  // Sum up result and return
107  return nu * (term1 + term2 + term3 + term4);
108  }
109 
110  // momentums
111  case 1:
112  case 2:
113  case 3:
114  {
115  // note: when comparing m to k or ell, or indexing into Points,
116  // must map m -> 0, 1, 2 by subtracting 1.
117  const unsigned m_local = m - 1;
118 
119  // Kronecker delta terms
120  const Real delta_km = (k == m_local ? 1.0 : 0.0);
121  const Real delta_ellm = (ell == m_local ? 1.0 : 0.0);
122  const Real delta_kell = (k == ell ? 1.0 : 0.0);
123 
124  return nu *
125  (
126  /* */ delta_km * (grad_phij(ell) - (phij / rho) * grad_rho(ell)) +
127  /* */ delta_ellm * (grad_phij(k) - (phij / rho) * grad_rho(k)) -
128  (2. / 3.) * delta_kell * (grad_phij(m_local) - (phij / rho) * grad_rho(m_local)));
129  } // end case 1,2,3
130 
131  case 4:
132  // Derivative wrt to energy variable is zero.
133  return 0.;
134 
135  default:
136  mooseError("Invalid variable requested.");
137  break;
138  }
139 
140  return 0.;
141 }

Member Data Documentation

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

Definition at line 33 of file NSViscStressTensorDerivs.h.

Referenced by NSViscStressTensorDerivs< T >::dtau().


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