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 34 of file NSEnergyViscousBC.h.

Constructor & Destructor Documentation

◆ NSEnergyViscousBC()

NSEnergyViscousBC::NSEnergyViscousBC ( const InputParameters &  parameters)

Definition at line 25 of file NSEnergyViscousBC.C.

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

◆ computeQpJacobian()

Real NSEnergyViscousBC::computeQpJacobian ( )
protectedvirtual

Definition at line 62 of file NSEnergyViscousBC.C.

63 {
64  // See notes for this term, involves temperature Hessian
65  Real thermal_term = 0.0;
66 
67  for (unsigned int ell = 0; ell < LIBMESH_DIM; ++ell)
68  {
69  Real intermediate_result = 0.;
70 
71  // The temperature Hessian contribution
72  for (unsigned n = 0; n < 5; ++n)
73  intermediate_result += _temp_derivs.get_hess(/*m=*/4, n) * (*_gradU[n])[_qp](ell);
74 
75  // Hit Hessian contribution with test function
76  intermediate_result *= _phi[_j][_qp];
77 
78  // Add in the temperature gradient contribution
79  intermediate_result += _temp_derivs.get_grad(/*rhoE=*/4) * _grad_phi[_j][_qp](ell);
80 
81  // Hit the result with the normal component, accumulate in thermal_term
82  thermal_term += intermediate_result * _normals[_qp](ell);
83  }
84 
85  // Hit thermal_term with thermal conductivity
86  thermal_term *= _thermal_conductivity[_qp];
87 
88  return (-thermal_term) * _test[_i][_qp];
89 }
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)

◆ computeQpOffDiagJacobian()

Real NSEnergyViscousBC::computeQpOffDiagJacobian ( unsigned  jvar)
protectedvirtual

Definition at line 92 of file NSEnergyViscousBC.C.

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

◆ computeQpResidual()

Real NSEnergyViscousBC::computeQpResidual ( )
protectedvirtual

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

Definition at line 44 of file NSEnergyViscousBC.C.

45 {
46  // n . (- k*grad(T) - tau*u) v
47 
48  // Velocity vector object
49  RealVectorValue vel(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
50 
51  // k*grad(T)
52  RealVectorValue thermal_vec = _thermal_conductivity[_qp] * _grad_temperature[_qp];
53 
54  // tau*u
55  RealVectorValue visc_vec = _viscous_stress_tensor[_qp] * vel;
56 
57  // Add everything up, dot with normal, hit with test function.
58  return ((-thermal_vec - visc_vec) * _normals[_qp]) * _test[_i][_qp];
59 }
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

◆ isNSVariable()

bool NSIntegratedBC::isNSVariable ( unsigned  var)
protectedinherited

◆ mapVarNumber()

unsigned NSIntegratedBC::mapVarNumber ( unsigned  var)
protectedinherited

Definition at line 90 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().

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

◆ NSTemperatureDerivs

template<class U >
friend class NSTemperatureDerivs
friend

Definition at line 67 of file NSEnergyViscousBC.h.

◆ NSViscStressTensorDerivs

template<class U >
friend class NSViscStressTensorDerivs
friend

Definition at line 59 of file NSEnergyViscousBC.h.

Member Data Documentation

◆ _dynamic_viscosity

const MaterialProperty<Real>& NSIntegratedBC::_dynamic_viscosity
protectedinherited

Definition at line 59 of file NSIntegratedBC.h.

◆ _fp

const IdealGasFluidProperties& NSIntegratedBC::_fp
protectedinherited

◆ _grad_rho

const VariableGradient& NSIntegratedBC::_grad_rho
protectedinherited

Definition at line 46 of file NSIntegratedBC.h.

Referenced by NSEnergyViscousBC().

◆ _grad_rho_E

const VariableGradient& NSIntegratedBC::_grad_rho_E
protectedinherited

Definition at line 50 of file NSIntegratedBC.h.

Referenced by NSEnergyViscousBC().

◆ _grad_rho_u

const VariableGradient& NSIntegratedBC::_grad_rho_u
protectedinherited

Definition at line 47 of file NSIntegratedBC.h.

Referenced by NSEnergyViscousBC().

◆ _grad_rho_v

const VariableGradient& NSIntegratedBC::_grad_rho_v
protectedinherited

Definition at line 48 of file NSIntegratedBC.h.

Referenced by NSEnergyViscousBC().

◆ _grad_rho_w

const VariableGradient& NSIntegratedBC::_grad_rho_w
protectedinherited

Definition at line 49 of file NSIntegratedBC.h.

Referenced by NSEnergyViscousBC().

◆ _grad_temperature

const VariableGradient& NSEnergyViscousBC::_grad_temperature
protected

Definition at line 48 of file NSEnergyViscousBC.h.

Referenced by computeQpResidual().

◆ _gradU

std::vector<const VariableGradient *> NSEnergyViscousBC::_gradU
protected

◆ _rho

const VariableValue& NSIntegratedBC::_rho
protectedinherited

◆ _rho_E

const VariableValue& NSIntegratedBC::_rho_E
protectedinherited

◆ _rho_u

const VariableValue& NSIntegratedBC::_rho_u
protectedinherited

◆ _rho_v

const VariableValue& NSIntegratedBC::_rho_v
protectedinherited

◆ _rho_var_number

unsigned NSIntegratedBC::_rho_var_number
protectedinherited

Definition at line 52 of file NSIntegratedBC.h.

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

◆ _rho_w

const VariableValue& NSIntegratedBC::_rho_w
protectedinherited

◆ _rhoE_var_number

unsigned NSIntegratedBC::_rhoE_var_number
protectedinherited

Definition at line 56 of file NSIntegratedBC.h.

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

◆ _rhou_var_number

unsigned NSIntegratedBC::_rhou_var_number
protectedinherited

Definition at line 53 of file NSIntegratedBC.h.

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

◆ _rhov_var_number

unsigned NSIntegratedBC::_rhov_var_number
protectedinherited

Definition at line 54 of file NSIntegratedBC.h.

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

◆ _rhow_var_number

unsigned NSIntegratedBC::_rhow_var_number
protectedinherited

Definition at line 55 of file NSIntegratedBC.h.

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

◆ _temp_derivs

NSTemperatureDerivs<NSEnergyViscousBC> NSEnergyViscousBC::_temp_derivs
protected

Definition at line 63 of file NSEnergyViscousBC.h.

Referenced by computeQpJacobian(), and computeQpOffDiagJacobian().

◆ _thermal_conductivity

const MaterialProperty<Real>& NSEnergyViscousBC::_thermal_conductivity
protected

◆ _u_vel

const VariableValue& NSIntegratedBC::_u_vel
protectedinherited

◆ _v_vel

const VariableValue& NSIntegratedBC::_v_vel
protectedinherited

◆ _viscous_stress_tensor

const MaterialProperty<RealTensorValue>& NSIntegratedBC::_viscous_stress_tensor
protectedinherited

◆ _vst_derivs

NSViscStressTensorDerivs<NSEnergyViscousBC> NSEnergyViscousBC::_vst_derivs
protected

Definition at line 55 of file NSEnergyViscousBC.h.

Referenced by computeQpOffDiagJacobian().

◆ _w_vel

const VariableValue& NSIntegratedBC::_w_vel
protectedinherited

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