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 19 of file NSMomentumInviscidFluxWithGradP.h.

Constructor & Destructor Documentation

NSMomentumInviscidFluxWithGradP::NSMomentumInviscidFluxWithGradP ( const InputParameters &  parameters)

Definition at line 24 of file NSMomentumInviscidFluxWithGradP.C.

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

Member Function Documentation

Real NSMomentumInviscidFluxWithGradP::computeQpJacobian ( )
protectedvirtual

Definition at line 56 of file NSMomentumInviscidFluxWithGradP.C.

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

Definition at line 76 of file NSMomentumInviscidFluxWithGradP.C.

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

Definition at line 42 of file NSMomentumInviscidFluxWithGradP.C.

43 {
44  // For _component = k,
45 
46  // (rho*u) * u_k = (rho*u_k) * u <- we write it this way
47  RealVectorValue vec(_u[_qp] * _u_vel[_qp], // (U_k) * u_1
48  _u[_qp] * _v_vel[_qp], // (U_k) * u_2
49  _u[_qp] * _w_vel[_qp]); // (U_k) * u_3
50 
51  // -((rho*u_k) * u) * grad(phi) + dp/dx_k * phi
52  return -(vec * _grad_test[_i][_qp]) + _grad_p[_qp](_component) * _test[_i][_qp];
53 }
const VariableValue & _w_vel
Definition: NSKernel.h:36
const VariableValue & _u_vel
Definition: NSKernel.h:34
const VariableValue & _v_vel
Definition: NSKernel.h:35
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 76 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().

77 {
78  if (var == _rho_var_number || var == _rhou_var_number || var == _rhov_var_number ||
79  var == _rhow_var_number || var == _rhoE_var_number)
80  return true;
81  else
82  return false;
83 }
unsigned _rhov_var_number
Definition: NSKernel.h:54
unsigned _rho_var_number
Definition: NSKernel.h:52
unsigned _rhow_var_number
Definition: NSKernel.h:55
unsigned _rhoE_var_number
Definition: NSKernel.h:56
unsigned _rhou_var_number
Definition: NSKernel.h:53
unsigned NSKernel::mapVarNumber ( unsigned  var)
protectedinherited

Definition at line 86 of file NSKernel.C.

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

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

Definition at line 143 of file NSMomentumInviscidFluxWithGradP.C.

Referenced by computeQpJacobian(), and computeQpOffDiagJacobian().

144 {
145  // Make sure our local gradient and Hessian data
146  // structures are up-to-date for this quadrature point
147  // this->recalculate_gradient_and_hessian();
148 
149  Real hessian_sum = 0.0;
150  for (unsigned int n = 0; n < 5; ++n)
151  hessian_sum += _pressure_derivs.get_hess(var_number, n) * (*_gradU[n])[_qp](_component);
152 
153  // Hit hessian_sum with phij, then add to dp/dU_m * dphij/dx_k, finally return the result
154  return _pressure_derivs.get_grad(var_number) * _grad_phi[_j][_qp](_component) +
155  hessian_sum * _phi[_j][_qp];
156 }
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

template<class U >
friend class NSPressureDerivs
friend

Definition at line 51 of file NSMomentumInviscidFluxWithGradP.h.

Member Data Documentation

const unsigned int NSMomentumInviscidFluxWithGradP::_component
protected
const MaterialProperty<Real>& NSKernel::_dynamic_viscosity
protectedinherited

Definition at line 59 of file NSKernel.h.

const IdealGasFluidProperties& NSKernel::_fp
protectedinherited
const VariableGradient& NSMomentumInviscidFluxWithGradP::_grad_p
protected

Definition at line 30 of file NSMomentumInviscidFluxWithGradP.h.

Referenced by computeQpResidual().

const VariableGradient& NSKernel::_grad_rho
protectedinherited
const VariableGradient& NSKernel::_grad_rho_E
protectedinherited
const VariableGradient& NSKernel::_grad_rho_u
protectedinherited
const VariableGradient& NSKernel::_grad_rho_v
protectedinherited
const VariableGradient& NSKernel::_grad_rho_w
protectedinherited
std::vector<const VariableGradient *> NSMomentumInviscidFluxWithGradP::_gradU
private
NSPressureDerivs<NSMomentumInviscidFluxWithGradP> NSMomentumInviscidFluxWithGradP::_pressure_derivs
private

Definition at line 47 of file NSMomentumInviscidFluxWithGradP.h.

Referenced by pressureQpJacobianHelper().

const VariableValue& NSKernel::_rho
protectedinherited
const VariableValue& NSKernel::_rho_E
protectedinherited

Definition at line 42 of file NSKernel.h.

const VariableValue& NSKernel::_rho_u
protectedinherited
const VariableValue& NSKernel::_rho_v
protectedinherited
unsigned NSKernel::_rho_var_number
protectedinherited
const VariableValue& NSKernel::_rho_w
protectedinherited
unsigned NSKernel::_rhoE_var_number
protectedinherited
unsigned NSKernel::_rhou_var_number
protectedinherited
unsigned NSKernel::_rhov_var_number
protectedinherited
unsigned NSKernel::_rhow_var_number
protectedinherited
const VariableValue& NSKernel::_u_vel
protectedinherited
const VariableValue& NSKernel::_v_vel
protectedinherited
const MaterialProperty<RealTensorValue>& NSKernel::_viscous_stress_tensor
protectedinherited
const VariableValue& NSKernel::_w_vel
protectedinherited

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