www.mooseframework.org
NSEnergyViscousBC.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 // Navier-Stokes includes
11 #include "NS.h"
12 #include "NSEnergyViscousBC.h"
13 
14 registerMooseObject("NavierStokesApp", NSEnergyViscousBC);
15 
16 template <>
17 InputParameters
19 {
20  InputParameters params = validParams<NSIntegratedBC>();
21  params.addRequiredCoupledVar(NS::temperature, "temperature");
22  return params;
23 }
24 
25 NSEnergyViscousBC::NSEnergyViscousBC(const InputParameters & parameters)
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 }
42 
43 Real
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 }
60 
61 Real
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 }
90 
91 Real
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 }
validParams< NSEnergyViscousBC >
InputParameters validParams< NSEnergyViscousBC >()
Definition: NSEnergyViscousBC.C:18
NSIntegratedBC::mapVarNumber
unsigned mapVarNumber(unsigned var)
Definition: NSIntegratedBC.C:90
NSIntegratedBC::_grad_rho
const VariableGradient & _grad_rho
Definition: NSIntegratedBC.h:45
NSEnergyViscousBC::_grad_temperature
const VariableGradient & _grad_temperature
Definition: NSEnergyViscousBC.h:47
validParams< NSIntegratedBC >
InputParameters validParams< NSIntegratedBC >()
Definition: NSIntegratedBC.C:22
NSIntegratedBC::_w_vel
const VariableValue & _w_vel
Definition: NSIntegratedBC.h:37
NSViscStressTensorDerivs::dtau
Real dtau(unsigned k, unsigned ell, unsigned m)
The primary interface for computing viscous stress tensor derivatives.
Definition: NSViscStressTensorDerivs.h:45
NSEnergyViscousBC::computeQpResidual
virtual Real computeQpResidual()
Just like other kernels, we must overload the Residual and Jacobian contributions....
Definition: NSEnergyViscousBC.C:44
NSIntegratedBC::_rho_w
const VariableValue & _rho_w
Definition: NSIntegratedBC.h:42
NSEnergyViscousBC::_thermal_conductivity
const MaterialProperty< Real > & _thermal_conductivity
Definition: NSEnergyViscousBC.h:50
NSIntegratedBC::isNSVariable
bool isNSVariable(unsigned var)
Definition: NSIntegratedBC.C:80
NS
Definition: NS.h:14
NSIntegratedBC::_grad_rho_E
const VariableGradient & _grad_rho_E
Definition: NSIntegratedBC.h:49
NSIntegratedBC
This class couples together all the variables for the compressible Navier-Stokes equations to allow t...
Definition: NSIntegratedBC.h:29
NSIntegratedBC::_v_vel
const VariableValue & _v_vel
Definition: NSIntegratedBC.h:36
NSIntegratedBC::_rho_v
const VariableValue & _rho_v
Definition: NSIntegratedBC.h:41
NSIntegratedBC::_u_vel
const VariableValue & _u_vel
Definition: NSIntegratedBC.h:35
NSEnergyViscousBC::computeQpJacobian
virtual Real computeQpJacobian()
Definition: NSEnergyViscousBC.C:62
NSIntegratedBC::_rho
const VariableValue & _rho
Definition: NSIntegratedBC.h:39
NSIntegratedBC::_grad_rho_u
const VariableGradient & _grad_rho_u
Definition: NSIntegratedBC.h:46
NSTemperatureDerivs::get_hess
Real get_hess(unsigned i, unsigned j)
Definition: NSTemperatureDerivs.h:87
NSEnergyViscousBC::_temp_derivs
NSTemperatureDerivs< NSEnergyViscousBC > _temp_derivs
Definition: NSEnergyViscousBC.h:62
NSIntegratedBC::_grad_rho_v
const VariableGradient & _grad_rho_v
Definition: NSIntegratedBC.h:47
NSEnergyViscousBC
This class corresponds to the viscous part of the "natural" boundary condition for the energy equatio...
Definition: NSEnergyViscousBC.h:33
NS.h
NSIntegratedBC::_viscous_stress_tensor
const MaterialProperty< RealTensorValue > & _viscous_stress_tensor
Definition: NSIntegratedBC.h:59
NSIntegratedBC::_rho_u
const VariableValue & _rho_u
Definition: NSIntegratedBC.h:40
NSIntegratedBC::_grad_rho_w
const VariableGradient & _grad_rho_w
Definition: NSIntegratedBC.h:48
NSEnergyViscousBC::_gradU
std::vector< const VariableGradient * > _gradU
Definition: NSEnergyViscousBC.h:70
NS::temperature
const std::string temperature
Definition: NS.h:26
NSEnergyViscousBC::_vst_derivs
NSViscStressTensorDerivs< NSEnergyViscousBC > _vst_derivs
Definition: NSEnergyViscousBC.h:54
NSTemperatureDerivs::get_grad
Real get_grad(unsigned i)
The primary interfaces for computing temperature derivatives.
Definition: NSTemperatureDerivs.h:49
registerMooseObject
registerMooseObject("NavierStokesApp", NSEnergyViscousBC)
NSEnergyViscousBC.h
NSEnergyViscousBC::computeQpOffDiagJacobian
virtual Real computeQpOffDiagJacobian(unsigned jvar)
Definition: NSEnergyViscousBC.C:92
NSEnergyViscousBC::NSEnergyViscousBC
NSEnergyViscousBC(const InputParameters &parameters)
Definition: NSEnergyViscousBC.C:25