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