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 
19 template <>
20 InputParameters
22 {
23  InputParameters params = validParams<NSKernel>();
24  params.addClassDescription(
25  "The inviscid flux (convective + pressure terms) for the momentum conservation equations.");
26  params.addRequiredCoupledVar(NS::pressure, "pressure");
27  params.addRequiredParam<unsigned int>(
28  "component",
29  "0,1,2 depending on if we are solving the x,y,z component of the momentum equation");
30  return params;
31 }
32 
33 NSMomentumInviscidFlux::NSMomentumInviscidFlux(const InputParameters & parameters)
34  : NSKernel(parameters),
35  _pressure(coupledValue(NS::pressure)),
36  _component(getParam<unsigned int>("component"))
37 {
38 }
39 
40 Real
42 {
43  // For _component = k,
44 
45  // (rho*u) * u_k = (rho*u_k) * u <- we write it this way
46  RealVectorValue vec(_u[_qp] * _u_vel[_qp], // (U_k) * u_1
47  _u[_qp] * _v_vel[_qp], // (U_k) * u_2
48  _u[_qp] * _w_vel[_qp]); // (U_k) * u_3
49 
50  // (rho*u_k) * u + e_k * P [ e_k = unit vector in k-direction ]
51  vec(_component) += _pressure[_qp];
52 
53  // -((rho*u_k) * u + e_k * P) * grad(phi)
54  return -(vec * _grad_test[_i][_qp]);
55 }
56 
57 Real
59 {
60  // The on-diagonal entry corresponds to variable number _component+1.
62 }
63 
64 Real
66 {
67  if (isNSVariable(jvar))
68  return computeJacobianHelper(mapVarNumber(jvar));
69  else
70  return 0.0;
71 }
72 
73 Real
75 {
76  const RealVectorValue vel(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
77 
78  // Ratio of specific heats
79  const Real gam = _fp.gamma();
80 
81  switch (m)
82  {
83  case 0: // density
84  {
85  const Real V2 = vel.norm_sq();
86  return vel(_component) * (vel * _grad_test[_i][_qp]) -
87  0.5 * (gam - 1.0) * V2 * _grad_test[_i][_qp](_component);
88  }
89 
90  case 1:
91  case 2:
92  case 3: // momentums
93  {
94  // Map m into m_local = {0,1,2}
95  unsigned int m_local = m - 1;
96 
97  // Kronecker delta
98  const Real delta_kl = (_component == m_local ? 1. : 0.);
99 
100  return -1.0 * (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 }
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
registerMooseObject
registerMooseObject("NavierStokesApp", NSMomentumInviscidFlux)
NSMomentumInviscidFlux::computeQpOffDiagJacobian
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
Definition: NSMomentumInviscidFlux.C:65
NSMomentumInviscidFlux
The inviscid flux (convective + pressure terms) for the momentum conservation equations.
Definition: NSMomentumInviscidFlux.h:24
IdealGasFluidProperties::gamma
virtual Real gamma() const
Definition: IdealGasFluidProperties.h:117
NS
Definition: NS.h:14
NSMomentumInviscidFlux.h
NSMomentumInviscidFlux::computeQpJacobian
virtual Real computeQpJacobian()
Definition: NSMomentumInviscidFlux.C:58
NSKernel::_v_vel
const VariableValue & _v_vel
Definition: NSKernel.h:37
NSKernel::_u_vel
const VariableValue & _u_vel
Definition: NSKernel.h:36
NSKernel
This class couples together all the variables for the compressible Navier-Stokes equations to allow t...
Definition: NSKernel.h:29
NSMomentumInviscidFlux::computeJacobianHelper
Real computeJacobianHelper(unsigned int m)
Definition: NSMomentumInviscidFlux.C:74
NSMomentumInviscidFlux::computeQpResidual
virtual Real computeQpResidual()
Definition: NSMomentumInviscidFlux.C:41
NSMomentumInviscidFlux::_pressure
const VariableValue & _pressure
Definition: NSMomentumInviscidFlux.h:35
NSKernel::_w_vel
const VariableValue & _w_vel
Definition: NSKernel.h:38
NS.h
NSKernel::_fp
const IdealGasFluidProperties & _fp
Definition: NSKernel.h:65
NSMomentumInviscidFlux::NSMomentumInviscidFlux
NSMomentumInviscidFlux(const InputParameters &parameters)
Definition: NSMomentumInviscidFlux.C:33
validParams< NSMomentumInviscidFlux >
InputParameters validParams< NSMomentumInviscidFlux >()
Definition: NSMomentumInviscidFlux.C:21
NSMomentumInviscidFlux::_component
const unsigned int _component
Definition: NSMomentumInviscidFlux.h:38
NSKernel::mapVarNumber
unsigned mapVarNumber(unsigned var)
Definition: NSKernel.C:88
NS::pressure
const std::string pressure
Definition: NS.h:25