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