www.mooseframework.org
NSEnergyInviscidFlux.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
8 // Navier-Stokes includes
9 #include "NS.h"
10 #include "NSEnergyInviscidFlux.h"
11 
12 // FluidProperties includes
14 
15 template <>
16 InputParameters
18 {
19  InputParameters params = validParams<NSKernel>();
20  params.addClassDescription("This class computes the inviscid part of the energy flux.");
21  params.addRequiredCoupledVar(NS::enthalpy, "total enthalpy");
22  return params;
23 }
24 
25 NSEnergyInviscidFlux::NSEnergyInviscidFlux(const InputParameters & parameters)
26  : NSKernel(parameters), _enthalpy(coupledValue(NS::enthalpy))
27 {
28 }
29 
30 Real
32 {
33  // H = total enthalpy = E + P/rho
34  // => rho * u * H = rho * u ( E + P/rho)
35  // = u ( rho*E + P)
36 
37  // velocity vector
38  RealVectorValue vel(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
39 
40  // Multiply vector U by the scalar value (rho*E + P) to get rho * U * H
41  // vel *= (_u[_qp] + _pressure[_qp]);
42 
43  // Multiply velocity vector by the scalar (rho * H)
44  vel *= (_rho[_qp] * _enthalpy[_qp]);
45 
46  // Return -1 * vel * grad(phi_i)
47  return -(vel * _grad_test[_i][_qp]);
48 }
49 
50 Real
52 {
53  // Derivative of this kernel wrt rho*E
54  const RealVectorValue vel(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
55 
56  // Ratio of specific heats
57  const Real gam = _fp.gamma();
58 
59  // -gamma * phi_j * (U*grad(phi_i))
60  return -gam * _phi[_j][_qp] * (vel * _grad_test[_i][_qp]);
61 }
62 
63 Real
65 {
66  if (isNSVariable(jvar))
67  {
68  RealVectorValue vel(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
69  Real V2 = vel.norm_sq();
70 
71  // Ratio of specific heats
72  const Real gam = _fp.gamma();
73 
74  // Derivative wrt density
75  if (jvar == _rho_var_number)
76  return -((0.5 * (gam - 1) * V2 - _enthalpy[_qp]) * _phi[_j][_qp] *
77  (vel * _grad_test[_i][_qp]));
78 
79  // Derivatives wrt momentums
80  else if ((jvar == _rhou_var_number) || (jvar == _rhov_var_number) || (jvar == _rhow_var_number))
81  {
82  // Map jvar into jlocal = {0,1,2}, regardless of how Moose has numbered things.
83  unsigned jlocal = 0;
84 
85  if (jvar == _rhov_var_number)
86  jlocal = 1;
87  else if (jvar == _rhow_var_number)
88  jlocal = 2;
89 
90  // Scale the velocity vector by the scalar (1-gamma)*vel(jlocal)
91  vel *= (1.0 - gam) * vel(jlocal);
92 
93  // Add in the enthalpy in the jlocal'th entry
94  vel(jlocal) += _enthalpy[_qp];
95 
96  // Return -1 * (vel * grad(phi_i)) * phi_j
97  return -(vel * _grad_test[_i][_qp]) * _phi[_j][_qp];
98  }
99 
100  else
101  {
102  std::ostringstream oss;
103  oss << "Invalid jvar=" << jvar << " requested!\n"
104  << "Did not match:\n"
105  << " _rho_var_number =" << _rho_var_number << "\n"
106  << " _rhou_var_number=" << _rhou_var_number << "\n"
107  << " _rhov_var_number=" << _rhov_var_number << "\n"
108  << " _rhow_var_number=" << _rhow_var_number << std::endl;
109  mooseError(oss.str());
110  }
111  }
112  else
113  return 0.0;
114 }
Definition: NS.h:13
NSEnergyInviscidFlux(const InputParameters &parameters)
This class couples together all the variables for the compressible Navier-Stokes equations to allow t...
Definition: NSKernel.h:27
const IdealGasFluidProperties & _fp
Definition: NSKernel.h:63
const VariableValue & _w_vel
Definition: NSKernel.h:36
virtual Real computeQpJacobian()
const VariableValue & _rho
Definition: NSKernel.h:38
virtual Real computeQpResidual()
unsigned _rhov_var_number
Definition: NSKernel.h:54
unsigned _rho_var_number
Definition: NSKernel.h:52
InputParameters validParams< NSKernel >()
Definition: NSKernel.C:20
const std::string enthalpy
Definition: NS.h:26
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
unsigned _rhow_var_number
Definition: NSKernel.h:55
bool isNSVariable(unsigned var)
Helper functions for mapping Moose variable numberings into the "canonical" numbering for the compres...
Definition: NSKernel.C:76
InputParameters validParams< NSEnergyInviscidFlux >()
const VariableValue & _u_vel
Definition: NSKernel.h:34
virtual Real gamma(Real v=0., Real u=0.) const override
Compute the ratio of specific heats.
const VariableValue & _v_vel
Definition: NSKernel.h:35
unsigned _rhou_var_number
Definition: NSKernel.h:53
const VariableValue & _enthalpy