www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
NSMomentumInviscidFluxWithGradP Class Reference

#include <NSMomentumInviscidFluxWithGradP.h>

Inheritance diagram for NSMomentumInviscidFluxWithGradP:
[legend]

Public Member Functions

 NSMomentumInviscidFluxWithGradP (const InputParameters &parameters)
 

Protected Member Functions

virtual Real computeQpResidual ()
 
virtual Real computeQpJacobian ()
 
virtual Real computeQpOffDiagJacobian (unsigned int jvar)
 
bool isNSVariable (unsigned var)
 Helper functions for mapping Moose variable numberings into the "canonical" numbering for the compressible NS equations. More...
 
unsigned mapVarNumber (unsigned var)
 

Protected Attributes

const VariableGradient & _grad_p
 
const unsigned int _component
 
const VariableValue & _u_vel
 
const VariableValue & _v_vel
 
const VariableValue & _w_vel
 
const VariableValue & _rho
 
const VariableValue & _rho_u
 
const VariableValue & _rho_v
 
const VariableValue & _rho_w
 
const VariableValue & _rho_E
 
const VariableGradient & _grad_rho
 
const VariableGradient & _grad_rho_u
 
const VariableGradient & _grad_rho_v
 
const VariableGradient & _grad_rho_w
 
const VariableGradient & _grad_rho_E
 
unsigned _rho_var_number
 
unsigned _rhou_var_number
 
unsigned _rhov_var_number
 
unsigned _rhow_var_number
 
unsigned _rhoE_var_number
 
const MaterialProperty< Real > & _dynamic_viscosity
 
const MaterialProperty< RealTensorValue > & _viscous_stress_tensor
 
const IdealGasFluidProperties_fp
 

Private Member Functions

Real pressureQpJacobianHelper (unsigned var_number)
 

Private Attributes

std::vector< const VariableGradient * > _gradU
 
NSPressureDerivs< NSMomentumInviscidFluxWithGradP_pressure_derivs
 

Friends

template<class U >
class NSPressureDerivs
 

Detailed Description

Definition at line 22 of file NSMomentumInviscidFluxWithGradP.h.

Constructor & Destructor Documentation

◆ NSMomentumInviscidFluxWithGradP()

NSMomentumInviscidFluxWithGradP::NSMomentumInviscidFluxWithGradP ( const InputParameters &  parameters)

Definition at line 28 of file NSMomentumInviscidFluxWithGradP.C.

29  : NSKernel(parameters),
30  _grad_p(coupledGradient(NS::pressure)),
31  _component(getParam<unsigned int>("component")),
32  _pressure_derivs(*this)
33 {
34  // Store pointers to all variable gradients in a single vector.
35  // This is needed for computing pressure Hessian values with a small
36  // amount of code.
37  _gradU.resize(5);
38  _gradU[0] = &_grad_rho;
39  _gradU[1] = &_grad_rho_u;
40  _gradU[2] = &_grad_rho_v;
41  _gradU[3] = &_grad_rho_w;
42  _gradU[4] = &_grad_rho_E;
43 }
const VariableGradient & _grad_rho_w
Definition: NSKernel.h:51
const VariableGradient & _grad_rho
Definition: NSKernel.h:48
const VariableGradient & _grad_rho_u
Definition: NSKernel.h:49
const VariableGradient & _grad_rho_v
Definition: NSKernel.h:50
const std::string pressure
Definition: NS.h:26
const VariableGradient & _grad_rho_E
Definition: NSKernel.h:52
std::vector< const VariableGradient * > _gradU
NSPressureDerivs< NSMomentumInviscidFluxWithGradP > _pressure_derivs
NSKernel(const InputParameters &parameters)
Definition: NSKernel.C:41

Member Function Documentation

◆ computeQpJacobian()

Real NSMomentumInviscidFluxWithGradP::computeQpJacobian ( )
protectedvirtual

Definition at line 60 of file NSMomentumInviscidFluxWithGradP.C.

61 {
62  RealVectorValue vec(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
63 
64  // The component'th entry of the on-diagonal Jacobian value is 2*u_i without the pressure
65  // contribution.
66  vec(_component) = 2. * vec(_component);
67 
68  // The Jacobian contribution due to grad(p) for the on-diagonal
69  // variable, which is equal to _component+1.
70  Real dFdp = pressureQpJacobianHelper(_component + 1);
71 
72  return
73  // Convective terms Jacobian
74  -(vec * _grad_test[_i][_qp]) * _phi[_j][_qp]
75  // Pressure term Jacobian
76  + dFdp * _test[_i][_qp];
77 }
const VariableValue & _w_vel
Definition: NSKernel.h:39
const VariableValue & _u_vel
Definition: NSKernel.h:37
const VariableValue & _v_vel
Definition: NSKernel.h:38

◆ computeQpOffDiagJacobian()

Real NSMomentumInviscidFluxWithGradP::computeQpOffDiagJacobian ( unsigned int  jvar)
protectedvirtual

Definition at line 80 of file NSMomentumInviscidFluxWithGradP.C.

81 {
82  if (isNSVariable(jvar))
83  {
84 
85  // Map jvar into the numbering expected by this->compute_pressure_jacobain_value()
86  unsigned int var_number = mapVarNumber(jvar);
87 
88  // The Jacobian contribution due to differentiating the grad(p)
89  // term wrt variable var_number.
90  Real dFdp = pressureQpJacobianHelper(var_number);
91 
92  if (jvar == _rho_var_number)
93  {
94  // Derivative of inviscid flux convective terms wrt density:
95  // x-mom: (-u_1^2 , -u_1*u_2 , -u_1*u_3 ) * grad(phi_i) * phi_j
96  // y-mom: (-u_2*u_1 , -u_2^2 , -u_2*u_3 ) * grad(phi_i) * phi_j
97  // z-mom: (-u_3*u_1 , -u_3*u_2 , -u_3^2 ) * grad(phi_i) * phi_j
98 
99  // Start with the velocity vector
100  RealVectorValue vec(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
101 
102  // Scale velocity vector by -1 * vec(_component)
103  vec *= -vec(_component);
104 
105  return
106  // Convective terms Jacobian
107  -(vec * _grad_test[_i][_qp]) * _phi[_j][_qp]
108  // Pressure term Jacobian
109  + dFdp * _test[_i][_qp];
110  }
111 
112  // Handle off-diagonal derivatives wrt momentums
113  else if (jvar == _rhou_var_number || jvar == _rhov_var_number || jvar == _rhow_var_number)
114  {
115  // Start with the velocity vector
116  RealVectorValue vel(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
117 
118  // Map jvar into jlocal = {0,1,2}, regardless of how Moose has numbered things.
119  // Can't do a case statement here since _rhou_var_number, etc. are not constants...
120  unsigned int jlocal = 0;
121 
122  if (jvar == _rhov_var_number)
123  jlocal = 1;
124  else if (jvar == _rhow_var_number)
125  jlocal = 2;
126 
127  return
128  // Convective terms Jacobian
129  -vel(_component) * _grad_test[_i][_qp](jlocal) * _phi[_j][_qp]
130  // Pressure term Jacobian
131  + dFdp * _test[_i][_qp];
132  }
133 
134  else if (jvar == _rhoE_var_number)
135  {
136  // Pressure term Jacobian
137  return dFdp * _test[_i][_qp];
138  }
139  else
140  return 0.0;
141  }
142  else
143  return 0.0;
144 }
const VariableValue & _w_vel
Definition: NSKernel.h:39
unsigned _rhov_var_number
Definition: NSKernel.h:57
unsigned _rho_var_number
Definition: NSKernel.h:55
unsigned _rhow_var_number
Definition: NSKernel.h:58
bool isNSVariable(unsigned var)
Helper functions for mapping Moose variable numberings into the "canonical" numbering for the compres...
Definition: NSKernel.C:78
unsigned _rhoE_var_number
Definition: NSKernel.h:59
const VariableValue & _u_vel
Definition: NSKernel.h:37
const VariableValue & _v_vel
Definition: NSKernel.h:38
unsigned mapVarNumber(unsigned var)
Definition: NSKernel.C:88
unsigned _rhou_var_number
Definition: NSKernel.h:56

◆ computeQpResidual()

Real NSMomentumInviscidFluxWithGradP::computeQpResidual ( )
protectedvirtual

Definition at line 46 of file NSMomentumInviscidFluxWithGradP.C.

47 {
48  // For _component = k,
49 
50  // (rho*u) * u_k = (rho*u_k) * u <- we write it this way
51  RealVectorValue vec(_u[_qp] * _u_vel[_qp], // (U_k) * u_1
52  _u[_qp] * _v_vel[_qp], // (U_k) * u_2
53  _u[_qp] * _w_vel[_qp]); // (U_k) * u_3
54 
55  // -((rho*u_k) * u) * grad(phi) + dp/dx_k * phi
56  return -(vec * _grad_test[_i][_qp]) + _grad_p[_qp](_component) * _test[_i][_qp];
57 }
const VariableValue & _w_vel
Definition: NSKernel.h:39
const VariableValue & _u_vel
Definition: NSKernel.h:37
const VariableValue & _v_vel
Definition: NSKernel.h:38

◆ isNSVariable()

bool NSKernel::isNSVariable ( unsigned  var)
protectedinherited

Helper functions for mapping Moose variable numberings into the "canonical" numbering for the compressible NS equations.

Definition at line 78 of file NSKernel.C.

Referenced by NSSUPGEnergy::computeJacobianHelper(), NSSUPGMass::computeJacobianHelper(), NSSUPGMomentum::computeJacobianHelper(), NSMassInviscidFlux::computeQpOffDiagJacobian(), NSEnergyInviscidFlux::computeQpOffDiagJacobian(), computeQpOffDiagJacobian(), NSMomentumInviscidFlux::computeQpOffDiagJacobian(), NSEnergyViscousFlux::computeQpOffDiagJacobian(), NSMomentumViscousFlux::computeQpOffDiagJacobian(), and NSEnergyThermalFlux::computeQpOffDiagJacobian().

79 {
80  if (var == _rho_var_number || var == _rhou_var_number || var == _rhov_var_number ||
81  var == _rhow_var_number || var == _rhoE_var_number)
82  return true;
83  else
84  return false;
85 }
unsigned _rhov_var_number
Definition: NSKernel.h:57
unsigned _rho_var_number
Definition: NSKernel.h:55
unsigned _rhow_var_number
Definition: NSKernel.h:58
unsigned _rhoE_var_number
Definition: NSKernel.h:59
unsigned _rhou_var_number
Definition: NSKernel.h:56

◆ mapVarNumber()

unsigned NSKernel::mapVarNumber ( unsigned  var)
protectedinherited

Definition at line 88 of file NSKernel.C.

Referenced by NSSUPGEnergy::computeJacobianHelper(), NSSUPGMass::computeJacobianHelper(), NSSUPGMomentum::computeJacobianHelper(), NSMassInviscidFlux::computeQpOffDiagJacobian(), computeQpOffDiagJacobian(), NSEnergyViscousFlux::computeQpOffDiagJacobian(), NSMomentumInviscidFlux::computeQpOffDiagJacobian(), NSMomentumViscousFlux::computeQpOffDiagJacobian(), and NSEnergyThermalFlux::computeQpOffDiagJacobian().

89 {
90  // Convert the Moose numbering to:
91  // 0 for rho
92  // 1 for rho*u
93  // 2 for rho*v
94  // 3 for rho*w
95  // 4 for rho*e
96  // regardless of the problem dimension, etc.
97  unsigned mapped_var_number = 99;
98 
99  if (var == _rho_var_number)
100  mapped_var_number = 0;
101  else if (var == _rhou_var_number)
102  mapped_var_number = 1;
103  else if (var == _rhov_var_number)
104  mapped_var_number = 2;
105  else if (var == _rhow_var_number)
106  mapped_var_number = 3;
107  else if (var == _rhoE_var_number)
108  mapped_var_number = 4;
109  else
110  mooseError("Invalid var!");
111 
112  return mapped_var_number;
113 }
unsigned _rhov_var_number
Definition: NSKernel.h:57
unsigned _rho_var_number
Definition: NSKernel.h:55
unsigned _rhow_var_number
Definition: NSKernel.h:58
unsigned _rhoE_var_number
Definition: NSKernel.h:59
unsigned _rhou_var_number
Definition: NSKernel.h:56

◆ pressureQpJacobianHelper()

Real NSMomentumInviscidFluxWithGradP::pressureQpJacobianHelper ( unsigned  var_number)
private

Definition at line 147 of file NSMomentumInviscidFluxWithGradP.C.

Referenced by computeQpJacobian(), and computeQpOffDiagJacobian().

148 {
149  // Make sure our local gradient and Hessian data
150  // structures are up-to-date for this quadrature point
151  // this->recalculate_gradient_and_hessian();
152 
153  Real hessian_sum = 0.0;
154  for (unsigned int n = 0; n < 5; ++n)
155  hessian_sum += _pressure_derivs.get_hess(var_number, n) * (*_gradU[n])[_qp](_component);
156 
157  // Hit hessian_sum with phij, then add to dp/dU_m * dphij/dx_k, finally return the result
158  return _pressure_derivs.get_grad(var_number) * _grad_phi[_j][_qp](_component) +
159  hessian_sum * _phi[_j][_qp];
160 }
Real get_grad(unsigned i)
The primary interfaces for computing pressure derivatives.
Real get_hess(unsigned i, unsigned j)
std::vector< const VariableGradient * > _gradU
NSPressureDerivs< NSMomentumInviscidFluxWithGradP > _pressure_derivs

Friends And Related Function Documentation

◆ NSPressureDerivs

template<class U >
friend class NSPressureDerivs
friend

Definition at line 54 of file NSMomentumInviscidFluxWithGradP.h.

Member Data Documentation

◆ _component

const unsigned int NSMomentumInviscidFluxWithGradP::_component
protected

◆ _dynamic_viscosity

const MaterialProperty<Real>& NSKernel::_dynamic_viscosity
protectedinherited

Definition at line 62 of file NSKernel.h.

◆ _fp

const IdealGasFluidProperties& NSKernel::_fp
protectedinherited

◆ _grad_p

const VariableGradient& NSMomentumInviscidFluxWithGradP::_grad_p
protected

Definition at line 33 of file NSMomentumInviscidFluxWithGradP.h.

Referenced by computeQpResidual().

◆ _grad_rho

const VariableGradient& NSKernel::_grad_rho
protectedinherited

◆ _grad_rho_E

const VariableGradient& NSKernel::_grad_rho_E
protectedinherited

◆ _grad_rho_u

const VariableGradient& NSKernel::_grad_rho_u
protectedinherited

◆ _grad_rho_v

const VariableGradient& NSKernel::_grad_rho_v
protectedinherited

◆ _grad_rho_w

const VariableGradient& NSKernel::_grad_rho_w
protectedinherited

◆ _gradU

std::vector<const VariableGradient *> NSMomentumInviscidFluxWithGradP::_gradU
private

◆ _pressure_derivs

NSPressureDerivs<NSMomentumInviscidFluxWithGradP> NSMomentumInviscidFluxWithGradP::_pressure_derivs
private

Definition at line 50 of file NSMomentumInviscidFluxWithGradP.h.

Referenced by pressureQpJacobianHelper().

◆ _rho

const VariableValue& NSKernel::_rho
protectedinherited

◆ _rho_E

const VariableValue& NSKernel::_rho_E
protectedinherited

Definition at line 45 of file NSKernel.h.

◆ _rho_u

const VariableValue& NSKernel::_rho_u
protectedinherited

◆ _rho_v

const VariableValue& NSKernel::_rho_v
protectedinherited

◆ _rho_var_number

unsigned NSKernel::_rho_var_number
protectedinherited

◆ _rho_w

const VariableValue& NSKernel::_rho_w
protectedinherited

◆ _rhoE_var_number

unsigned NSKernel::_rhoE_var_number
protectedinherited

◆ _rhou_var_number

unsigned NSKernel::_rhou_var_number
protectedinherited

◆ _rhov_var_number

unsigned NSKernel::_rhov_var_number
protectedinherited

◆ _rhow_var_number

unsigned NSKernel::_rhow_var_number
protectedinherited

◆ _u_vel

const VariableValue& NSKernel::_u_vel
protectedinherited

◆ _v_vel

const VariableValue& NSKernel::_v_vel
protectedinherited

◆ _viscous_stress_tensor

const MaterialProperty<RealTensorValue>& NSKernel::_viscous_stress_tensor
protectedinherited

◆ _w_vel

const VariableValue& NSKernel::_w_vel
protectedinherited

The documentation for this class was generated from the following files: