www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
NSEnergyViscousBC Class Reference

This class corresponds to the viscous part of the "natural" boundary condition for the energy equation, i.e. More...

#include <NSEnergyViscousBC.h>

Inheritance diagram for NSEnergyViscousBC:
[legend]

Public Member Functions

 NSEnergyViscousBC (const InputParameters &parameters)
 

Protected Member Functions

virtual Real computeQpResidual ()
 Just like other kernels, we must overload the Residual and Jacobian contributions... More...
 
virtual Real computeQpJacobian ()
 
virtual Real computeQpOffDiagJacobian (unsigned jvar)
 
bool isNSVariable (unsigned var)
 
unsigned mapVarNumber (unsigned var)
 

Protected Attributes

const VariableGradient & _grad_temperature
 
const MaterialProperty< Real > & _thermal_conductivity
 
NSViscStressTensorDerivs< NSEnergyViscousBC_vst_derivs
 
NSTemperatureDerivs< NSEnergyViscousBC_temp_derivs
 
std::vector< const VariableGradient * > _gradU
 
const VariableValue & _u_vel
 
const VariableValue & _v_vel
 
const VariableValue & _w_vel
 
const VariableValue & _rho
 
const VariableValue & _rho_u
 
const VariableValue & _rho_v
 
const VariableValue & _rho_w
 
const VariableValue & _rho_E
 
const VariableGradient & _grad_rho
 
const VariableGradient & _grad_rho_u
 
const VariableGradient & _grad_rho_v
 
const VariableGradient & _grad_rho_w
 
const VariableGradient & _grad_rho_E
 
unsigned _rho_var_number
 
unsigned _rhou_var_number
 
unsigned _rhov_var_number
 
unsigned _rhow_var_number
 
unsigned _rhoE_var_number
 
const MaterialProperty< Real > & _dynamic_viscosity
 
const MaterialProperty< RealTensorValue > & _viscous_stress_tensor
 
const IdealGasFluidProperties_fp
 

Friends

template<class U >
class NSViscStressTensorDerivs
 
template<class U >
class NSTemperatureDerivs
 

Detailed Description

This class corresponds to the viscous part of the "natural" boundary condition for the energy equation, i.e.

int_{Gamma} n . (- k*grad(T) - tau*u) v

A typical use for this kernel would be a subsonic outflow BC in which the pressure is specified. In this case, the residual and Jacobian contrbutions of the k*grad(T) and n.tau*u terms are computed and added to the matrix/rhs.

Definition at line 31 of file NSEnergyViscousBC.h.

Constructor & Destructor Documentation

NSEnergyViscousBC::NSEnergyViscousBC ( const InputParameters &  parameters)

Definition at line 21 of file NSEnergyViscousBC.C.

22  : NSIntegratedBC(parameters),
23  _grad_temperature(coupledGradient(NS::temperature)),
24  _thermal_conductivity(getMaterialProperty<Real>("thermal_conductivity")),
25  // Viscous stress tensor derivative computing object
26  _vst_derivs(*this),
27  // Temperature derivative computing object
28  _temp_derivs(*this)
29 {
30  // Store pointers to all variable gradients in a single vector.
31  _gradU.resize(5);
32  _gradU[0] = &_grad_rho;
33  _gradU[1] = &_grad_rho_u;
34  _gradU[2] = &_grad_rho_v;
35  _gradU[3] = &_grad_rho_w;
36  _gradU[4] = &_grad_rho_E;
37 }
const VariableGradient & _grad_rho_w
const VariableGradient & _grad_rho_u
const std::string temperature
Definition: NS.h:25
NSIntegratedBC(const InputParameters &parameters)
NSTemperatureDerivs< NSEnergyViscousBC > _temp_derivs
const VariableGradient & _grad_rho_v
const MaterialProperty< Real > & _thermal_conductivity
NSViscStressTensorDerivs< NSEnergyViscousBC > _vst_derivs
std::vector< const VariableGradient * > _gradU
const VariableGradient & _grad_rho_E
const VariableGradient & _grad_rho
const VariableGradient & _grad_temperature

Member Function Documentation

Real NSEnergyViscousBC::computeQpJacobian ( )
protectedvirtual

Definition at line 58 of file NSEnergyViscousBC.C.

59 {
60  // See notes for this term, involves temperature Hessian
61  Real thermal_term = 0.0;
62 
63  for (unsigned int ell = 0; ell < LIBMESH_DIM; ++ell)
64  {
65  Real intermediate_result = 0.;
66 
67  // The temperature Hessian contribution
68  for (unsigned n = 0; n < 5; ++n)
69  intermediate_result += _temp_derivs.get_hess(/*m=*/4, n) * (*_gradU[n])[_qp](ell);
70 
71  // Hit Hessian contribution with test function
72  intermediate_result *= _phi[_j][_qp];
73 
74  // Add in the temperature gradient contribution
75  intermediate_result += _temp_derivs.get_grad(/*rhoE=*/4) * _grad_phi[_j][_qp](ell);
76 
77  // Hit the result with the normal component, accumulate in thermal_term
78  thermal_term += intermediate_result * _normals[_qp](ell);
79  }
80 
81  // Hit thermal_term with thermal conductivity
82  thermal_term *= _thermal_conductivity[_qp];
83 
84  return (-thermal_term) * _test[_i][_qp];
85 }
Real get_grad(unsigned i)
The primary interfaces for computing temperature derivatives.
NSTemperatureDerivs< NSEnergyViscousBC > _temp_derivs
const MaterialProperty< Real > & _thermal_conductivity
std::vector< const VariableGradient * > _gradU
Real get_hess(unsigned i, unsigned j)
Real NSEnergyViscousBC::computeQpOffDiagJacobian ( unsigned  jvar)
protectedvirtual

Definition at line 88 of file NSEnergyViscousBC.C.

89 {
90  if (isNSVariable(jvar))
91  {
92  // Note: This function requires both _vst_derivs *and* _temp_derivs
93 
94  // Convenience variables
95  const RealTensorValue & tau = _viscous_stress_tensor[_qp];
96 
97  Real rho = _rho[_qp];
98  Real phij = _phi[_j][_qp];
99  RealVectorValue U(_rho_u[_qp], _rho_v[_qp], _rho_w[_qp]);
100 
101  // Map jvar into the variable m for our problem, regardless of
102  // how Moose has numbered things.
103  unsigned m = mapVarNumber(jvar);
104 
105  //
106  // 1.) Thermal term derivatives
107  //
108 
109  // See notes for this term, involves temperature Hessian
110  Real thermal_term = 0.;
111 
112  for (unsigned ell = 0; ell < LIBMESH_DIM; ++ell)
113  {
114  Real intermediate_result = 0.;
115 
116  // The temperature Hessian contribution
117  for (unsigned n = 0; n < 5; ++n)
118  intermediate_result += _temp_derivs.get_hess(m, n) * (*_gradU[n])[_qp](ell);
119 
120  // Hit Hessian contribution with test function
121  intermediate_result *= _phi[_j][_qp];
122 
123  // Add in the temperature gradient contribution
124  intermediate_result += _temp_derivs.get_grad(m) * _grad_phi[_j][_qp](ell);
125 
126  // Hit the result with the normal component, accumulate in thermal_term
127  thermal_term += intermediate_result * _normals[_qp](ell);
128  }
129 
130  // Hit thermal_term with thermal conductivity
131  thermal_term *= _thermal_conductivity[_qp];
132 
133  //
134  // 2.) Viscous term derivatives
135  //
136 
137  // Compute viscous term derivatives
138  Real visc_term = 0.;
139 
140  switch (m)
141  {
142  case 0: // density
143  {
144  // Loop over k and ell as in the notes...
145  for (unsigned int k = 0; k < LIBMESH_DIM; ++k)
146  {
147  Real intermediate_value = 0.0;
148  for (unsigned int ell = 0; ell < LIBMESH_DIM; ++ell)
149  intermediate_value +=
150  (U(ell) / rho * (-tau(k, ell) * phij / rho + _vst_derivs.dtau(k, ell, m)));
151 
152  // Hit accumulated value with normal component k. We will multiply by test function at
153  // the end of this routine...
154  visc_term += intermediate_value * _normals[_qp](k);
155  } // end for k
156 
157  break;
158  } // end case 0
159 
160  case 1:
161  case 2:
162  case 3: // momentums
163  {
164  // Map m -> 0,1,2 as usual...
165  unsigned int m_local = m - 1;
166 
167  // Loop over k and ell as in the notes...
168  for (unsigned int k = 0; k < LIBMESH_DIM; ++k)
169  {
170  Real intermediate_value = tau(k, m_local) * phij / rho;
171 
172  for (unsigned int ell = 0; ell < LIBMESH_DIM; ++ell)
173  intermediate_value += _vst_derivs.dtau(k, ell, m) * U(ell) /
174  rho; // Note: pass 'm' to dtau, it will convert it internally
175 
176  // Hit accumulated value with normal component k.
177  visc_term += intermediate_value * _normals[_qp](k);
178  } // end for k
179 
180  break;
181  } // end case 1,2,3
182 
183  case 4: // energy
184  mooseError("Shouldn't get here, this is the on-diagonal entry!");
185  break;
186 
187  default:
188  mooseError("Invalid m value.");
189  break;
190  }
191 
192  // Finally, sum up the different contributions (with appropriate
193  // sign) multiply by the test function, and return.
194  return (-thermal_term - visc_term) * _test[_i][_qp];
195  }
196  else
197  return 0.0;
198 }
bool isNSVariable(unsigned var)
Real get_grad(unsigned i)
The primary interfaces for computing temperature derivatives.
const VariableValue & _rho_w
const VariableValue & _rho
Real dtau(unsigned k, unsigned ell, unsigned m)
The primary interface for computing viscous stress tensor derivatives.
NSTemperatureDerivs< NSEnergyViscousBC > _temp_derivs
const MaterialProperty< Real > & _thermal_conductivity
const MaterialProperty< RealTensorValue > & _viscous_stress_tensor
NSViscStressTensorDerivs< NSEnergyViscousBC > _vst_derivs
std::vector< const VariableGradient * > _gradU
unsigned mapVarNumber(unsigned var)
const VariableValue & _rho_u
Real get_hess(unsigned i, unsigned j)
const VariableValue & _rho_v
Real NSEnergyViscousBC::computeQpResidual ( )
protectedvirtual

Just like other kernels, we must overload the Residual and Jacobian contributions...

Definition at line 40 of file NSEnergyViscousBC.C.

41 {
42  // n . (- k*grad(T) - tau*u) v
43 
44  // Velocity vector object
45  RealVectorValue vel(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
46 
47  // k*grad(T)
48  RealVectorValue thermal_vec = _thermal_conductivity[_qp] * _grad_temperature[_qp];
49 
50  // tau*u
51  RealVectorValue visc_vec = _viscous_stress_tensor[_qp] * vel;
52 
53  // Add everything up, dot with normal, hit with test function.
54  return ((-thermal_vec - visc_vec) * _normals[_qp]) * _test[_i][_qp];
55 }
const VariableValue & _w_vel
const MaterialProperty< Real > & _thermal_conductivity
const MaterialProperty< RealTensorValue > & _viscous_stress_tensor
const VariableValue & _v_vel
const VariableGradient & _grad_temperature
const VariableValue & _u_vel
bool NSIntegratedBC::isNSVariable ( unsigned  var)
protectedinherited
unsigned NSIntegratedBC::mapVarNumber ( unsigned  var)
protectedinherited

Definition at line 87 of file NSIntegratedBC.C.

Referenced by NSEnergyInviscidSpecifiedBC::computeQpOffDiagJacobian(), NSEnergyInviscidSpecifiedNormalFlowBC::computeQpOffDiagJacobian(), NSEnergyInviscidUnspecifiedBC::computeQpOffDiagJacobian(), NSEnergyInviscidSpecifiedPressureBC::computeQpOffDiagJacobian(), NSMomentumInviscidSpecifiedNormalFlowBC::computeQpOffDiagJacobian(), NSMassUnspecifiedNormalFlowBC::computeQpOffDiagJacobian(), NSMomentumInviscidSpecifiedPressureBC::computeQpOffDiagJacobian(), NSMomentumInviscidNoPressureImplicitFlowBC::computeQpOffDiagJacobian(), NSPressureNeumannBC::computeQpOffDiagJacobian(), NSMomentumViscousBC::computeQpOffDiagJacobian(), and computeQpOffDiagJacobian().

88 {
89  // Convert the Moose numbering to:
90  // 0 for rho
91  // 1 for rho*u
92  // 2 for rho*v
93  // 3 for rho*w
94  // 4 for rho*e
95  // regardless of the problem dimension, etc.
96  unsigned int mapped_var_number;
97 
98  if (var == _rho_var_number)
99  mapped_var_number = 0;
100  else if (var == _rhou_var_number)
101  mapped_var_number = 1;
102  else if (var == _rhov_var_number)
103  mapped_var_number = 2;
104  else if (var == _rhow_var_number)
105  mapped_var_number = 3;
106  else if (var == _rhoE_var_number)
107  mapped_var_number = 4;
108  else
109  mooseError("Invalid var!");
110 
111  return mapped_var_number;
112 }
unsigned _rhov_var_number
unsigned _rhou_var_number
unsigned _rhow_var_number
unsigned _rho_var_number
unsigned _rhoE_var_number

Friends And Related Function Documentation

template<class U >
friend class NSTemperatureDerivs
friend

Definition at line 64 of file NSEnergyViscousBC.h.

template<class U >
friend class NSViscStressTensorDerivs
friend

Definition at line 56 of file NSEnergyViscousBC.h.

Member Data Documentation

const MaterialProperty<Real>& NSIntegratedBC::_dynamic_viscosity
protectedinherited

Definition at line 56 of file NSIntegratedBC.h.

const IdealGasFluidProperties& NSIntegratedBC::_fp
protectedinherited
const VariableGradient& NSIntegratedBC::_grad_rho
protectedinherited

Definition at line 43 of file NSIntegratedBC.h.

Referenced by NSEnergyViscousBC().

const VariableGradient& NSIntegratedBC::_grad_rho_E
protectedinherited

Definition at line 47 of file NSIntegratedBC.h.

Referenced by NSEnergyViscousBC().

const VariableGradient& NSIntegratedBC::_grad_rho_u
protectedinherited

Definition at line 44 of file NSIntegratedBC.h.

Referenced by NSEnergyViscousBC().

const VariableGradient& NSIntegratedBC::_grad_rho_v
protectedinherited

Definition at line 45 of file NSIntegratedBC.h.

Referenced by NSEnergyViscousBC().

const VariableGradient& NSIntegratedBC::_grad_rho_w
protectedinherited

Definition at line 46 of file NSIntegratedBC.h.

Referenced by NSEnergyViscousBC().

const VariableGradient& NSEnergyViscousBC::_grad_temperature
protected

Definition at line 45 of file NSEnergyViscousBC.h.

Referenced by computeQpResidual().

std::vector<const VariableGradient *> NSEnergyViscousBC::_gradU
protected
const VariableValue& NSIntegratedBC::_rho
protectedinherited
const VariableValue& NSIntegratedBC::_rho_E
protectedinherited
const VariableValue& NSIntegratedBC::_rho_u
protectedinherited
const VariableValue& NSIntegratedBC::_rho_v
protectedinherited
unsigned NSIntegratedBC::_rho_var_number
protectedinherited

Definition at line 49 of file NSIntegratedBC.h.

Referenced by NSIntegratedBC::isNSVariable(), and NSIntegratedBC::mapVarNumber().

const VariableValue& NSIntegratedBC::_rho_w
protectedinherited
unsigned NSIntegratedBC::_rhoE_var_number
protectedinherited

Definition at line 53 of file NSIntegratedBC.h.

Referenced by NSIntegratedBC::isNSVariable(), and NSIntegratedBC::mapVarNumber().

unsigned NSIntegratedBC::_rhou_var_number
protectedinherited

Definition at line 50 of file NSIntegratedBC.h.

Referenced by NSIntegratedBC::isNSVariable(), and NSIntegratedBC::mapVarNumber().

unsigned NSIntegratedBC::_rhov_var_number
protectedinherited

Definition at line 51 of file NSIntegratedBC.h.

Referenced by NSIntegratedBC::isNSVariable(), and NSIntegratedBC::mapVarNumber().

unsigned NSIntegratedBC::_rhow_var_number
protectedinherited

Definition at line 52 of file NSIntegratedBC.h.

Referenced by NSIntegratedBC::isNSVariable(), and NSIntegratedBC::mapVarNumber().

NSTemperatureDerivs<NSEnergyViscousBC> NSEnergyViscousBC::_temp_derivs
protected

Definition at line 60 of file NSEnergyViscousBC.h.

Referenced by computeQpJacobian(), and computeQpOffDiagJacobian().

const MaterialProperty<Real>& NSEnergyViscousBC::_thermal_conductivity
protected
const VariableValue& NSIntegratedBC::_u_vel
protectedinherited
const VariableValue& NSIntegratedBC::_v_vel
protectedinherited
const MaterialProperty<RealTensorValue>& NSIntegratedBC::_viscous_stress_tensor
protectedinherited
NSViscStressTensorDerivs<NSEnergyViscousBC> NSEnergyViscousBC::_vst_derivs
protected

Definition at line 52 of file NSEnergyViscousBC.h.

Referenced by computeQpOffDiagJacobian().

const VariableValue& NSIntegratedBC::_w_vel
protectedinherited

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