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