https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NSMomentumInviscidFlux.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
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"
13
14// FluidProperties includes
16
18
21{
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
39Real
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
56Real
58{
59 // The on-diagonal entry corresponds to variable number _component+1.
61}
62
63Real
65{
66 if (isNSVariable(jvar))
68 else
69 return 0.0;
70}
71
72Real
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}
registerMooseObject("NavierStokesApp", NSMomentumInviscidFlux)
void ErrorVector unsigned int
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
unsigned int _qp
unsigned int _j
unsigned int _i
const VariablePhiValue & _phi
const VariableTestGradient & _grad_test
const VariableValue & _u
void mooseError(Args &&... args) const
This class couples together all the variables for the compressible Navier-Stokes equations to allow t...
Definition NSKernel.h:26
unsigned mapVarNumber(unsigned var)
Definition NSKernel.C:89
bool isNSVariable(unsigned var)
Helper functions for mapping Moose variable numberings into the "canonical" numbering for the compres...
Definition NSKernel.C:79
static InputParameters validParams()
Definition NSKernel.C:23
const VariableValue & _u_vel
Definition NSKernel.h:34
const VariableValue & _v_vel
Definition NSKernel.h:35
const VariableValue & _w_vel
Definition NSKernel.h:36
const IdealGasFluidProperties & _fp
Definition NSKernel.h:63
The inviscid flux (convective + pressure terms) for the momentum conservation equations.
static InputParameters validParams()
Real computeJacobianHelper(unsigned int m)
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
const VariableValue & _pressure
NSMomentumInviscidFlux(const InputParameters &parameters)
static const std::string pressure
Definition NS.h:57