www.mooseframework.org
NSMomentumInviscidFlux.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 "NSMomentumInviscidFlux.h"
11 
12 // FluidProperties includes
14 
15 template <>
16 InputParameters
18 {
19  InputParameters params = validParams<NSKernel>();
20  params.addClassDescription(
21  "The inviscid flux (convective + pressure terms) for the momentum conservation equations.");
22  params.addRequiredCoupledVar(NS::pressure, "pressure");
23  params.addRequiredParam<unsigned int>(
24  "component",
25  "0,1,2 depending on if we are solving the x,y,z component of the momentum equation");
26  return params;
27 }
28 
29 NSMomentumInviscidFlux::NSMomentumInviscidFlux(const InputParameters & parameters)
30  : NSKernel(parameters),
31  _pressure(coupledValue(NS::pressure)),
32  _component(getParam<unsigned int>("component"))
33 {
34 }
35 
36 Real
38 {
39  // For _component = k,
40 
41  // (rho*u) * u_k = (rho*u_k) * u <- we write it this way
42  RealVectorValue vec(_u[_qp] * _u_vel[_qp], // (U_k) * u_1
43  _u[_qp] * _v_vel[_qp], // (U_k) * u_2
44  _u[_qp] * _w_vel[_qp]); // (U_k) * u_3
45 
46  // (rho*u_k) * u + e_k * P [ e_k = unit vector in k-direction ]
47  vec(_component) += _pressure[_qp];
48 
49  // -((rho*u_k) * u + e_k * P) * grad(phi)
50  return -(vec * _grad_test[_i][_qp]);
51 }
52 
53 Real
55 {
56  // The on-diagonal entry corresponds to variable number _component+1.
58 }
59 
60 Real
62 {
63  if (isNSVariable(jvar))
64  return computeJacobianHelper(mapVarNumber(jvar));
65  else
66  return 0.0;
67 }
68 
69 Real
71 {
72  const RealVectorValue vel(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
73 
74  // Ratio of specific heats
75  const Real gam = _fp.gamma();
76 
77  switch (m)
78  {
79  case 0: // density
80  {
81  const Real V2 = vel.norm_sq();
82  return vel(_component) * (vel * _grad_test[_i][_qp]) -
83  0.5 * (gam - 1.0) * V2 * _grad_test[_i][_qp](_component);
84  }
85 
86  case 1:
87  case 2:
88  case 3: // momentums
89  {
90  // Map m into m_local = {0,1,2}
91  unsigned int m_local = m - 1;
92 
93  // Kronecker delta
94  const Real delta_kl = (_component == m_local ? 1. : 0.);
95 
96  return -1.0 * (vel(_component) * _grad_test[_i][_qp](m_local) +
97  delta_kl * (vel * _grad_test[_i][_qp]) +
98  (1. - gam) * vel(m_local) * _grad_test[_i][_qp](_component)) *
99  _phi[_j][_qp];
100  }
101 
102  case 4: // energy
103  return -1.0 * (gam - 1.0) * _phi[_j][_qp] * _grad_test[_i][_qp](_component);
104  }
105 
106  mooseError("Shouldn't get here!");
107 }
Definition: NS.h:13
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
const VariableValue & _pressure
InputParameters validParams< NSKernel >()
Definition: NSKernel.C:20
InputParameters validParams< NSMomentumInviscidFlux >()
bool isNSVariable(unsigned var)
Helper functions for mapping Moose variable numberings into the "canonical" numbering for the compres...
Definition: NSKernel.C:76
NSMomentumInviscidFlux(const InputParameters &parameters)
const unsigned int _component
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
const std::string pressure
Definition: NS.h:24
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
unsigned mapVarNumber(unsigned var)
Definition: NSKernel.C:86
Real computeJacobianHelper(unsigned int m)