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

Compute residual and Jacobian terms form the SUPG terms in the momentum equation. More...

#include <NSSUPGMomentum.h>

Inheritance diagram for NSSUPGMomentum:
[legend]

Public Member Functions

 NSSUPGMomentum (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

unsigned int _component
 
const MaterialProperty< RealTensorValue > & _viscous_stress_tensor
 
const MaterialProperty< Real > & _dynamic_viscosity
 
const MaterialProperty< Real > & _thermal_conductivity
 
const MaterialProperty< Real > & _hsupg
 
const MaterialProperty< Real > & _tauc
 
const MaterialProperty< Real > & _taum
 
const MaterialProperty< Real > & _taue
 
const MaterialProperty< std::vector< Real > > & _strong_residuals
 
const MaterialProperty< std::vector< RealTensorValue > > & _calA
 
const MaterialProperty< std::vector< RealTensorValue > > & _calC
 
const MaterialProperty< std::vector< std::vector< RealTensorValue > > > & _calE
 
const VariableValue & _d_rhodot_du
 
const VariableValue & _d_rhoudot_du
 
const VariableValue & _d_rhovdot_du
 
const VariableValue & _d_rhowdot_du
 
const VariableValue & _d_rhoEdot_du
 
const VariableValue & _temperature
 
const VariableValue & _enthalpy
 
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 IdealGasFluidProperties_fp
 

Private Member Functions

Real computeJacobianHelper (unsigned int var)
 

Detailed Description

Compute residual and Jacobian terms form the SUPG terms in the momentum equation.

Definition at line 25 of file NSSUPGMomentum.h.

Constructor & Destructor Documentation

◆ NSSUPGMomentum()

NSSUPGMomentum::NSSUPGMomentum ( const InputParameters &  parameters)

Definition at line 28 of file NSSUPGMomentum.C.

29  : NSSUPGBase(parameters), _component(getParam<unsigned>("component"))
30 {
31 }
unsigned int _component
NSSUPGBase(const InputParameters &parameters)
Definition: NSSUPGBase.C:28

Member Function Documentation

◆ computeJacobianHelper()

Real NSSUPGMomentum::computeJacobianHelper ( unsigned int  var)
private

Definition at line 105 of file NSSUPGMomentum.C.

Referenced by computeQpJacobian(), and computeQpOffDiagJacobian().

106 {
107  if (isNSVariable(var))
108  {
109  // Convert the Moose numbering to canonical NS variable numbering.
110  unsigned mapped_var_number = mapVarNumber(var);
111 
112  // Convenience vars
113 
114  // Velocity vector
115  RealVectorValue vel(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
116 
117  // Velocity vector magnitude squared
118  Real velmag2 = vel.norm_sq();
119 
120  // Ratio of specific heats
121  const Real gam = _fp.gamma();
122 
123  // Shortcuts for shape function gradients at current qp.
124  RealVectorValue grad_test_i = _grad_test[_i][_qp];
125  RealVectorValue grad_phi_j = _grad_phi[_j][_qp];
126 
127  // ...
128 
129  // 1.) taum- and taue-proportional terms present for any variable:
130 
131  //
132  // Art. Diffusion matrix for taum-proportional term = ( C_k + (1-gam)*C_k^T + diag(u_k) ) *
133  // calA_{ell}
134  //
135  RealTensorValue mom_mat;
136  mom_mat(0, 0) = mom_mat(1, 1) = mom_mat(2, 2) = vel(_component); // (diag(u_k)
137  mom_mat += _calC[_qp][_component]; // + C_k
138  mom_mat += (1.0 - gam) * _calC[_qp][_component].transpose(); // + (1-gam)*C_k^T)
139  mom_mat = mom_mat * _calA[_qp][mapped_var_number]; // * calA_{ell}
140  Real mom_term =
141  _taum[_qp] * grad_test_i * (mom_mat * grad_phi_j); // taum * grad(phi_i) * (M*grad(phi_j))
142 
143  //
144  // Art. Diffusion matrix for taue-proportional term = (gam-1) * calE_km
145  //
146  RealTensorValue ene_mat = (gam - 1) * _calE[_qp][_component][mapped_var_number];
147  Real ene_term =
148  _taue[_qp] * grad_test_i * (ene_mat * grad_phi_j); // taue * grad(phi_i) * (M*grad(phi_j))
149 
150  // 2.) Terms only present if the variable is one of the momentums
151  Real mass_term = 0.0;
152 
153  switch (mapped_var_number)
154  {
155  case 1:
156  case 2:
157  case 3:
158  {
159  // Variable for zero-based indexing into local matrices and vectors.
160  unsigned m_local = mapped_var_number - 1;
161 
162  //
163  // Art. Diffusion matrix for tauc-proportional term = 0.5*(gam - 1.0)*velmag2*D_km -
164  // vel(_component)*C_m
165  //
166  RealTensorValue mass_mat;
167  mass_mat(_component, m_local) = 0.5 * (gam - 1.0) * velmag2; // 0.5*(gam - 1.0)*velmag2*D_km
168  mass_mat -= vel(_component) * _calC[_qp][m_local]; // vel(_component)*C_m
169  mass_term = _tauc[_qp] * grad_test_i *
170  (mass_mat * grad_phi_j); // tauc * grad(phi_i) * (M*grad(phi_j))
171  }
172  // Nothing else to do if we are not a momentum...
173  }
174 
175  // Sum up values and return
176  return mass_term + mom_term + ene_term;
177  }
178  else
179  return 0.0;
180 }
const IdealGasFluidProperties & _fp
Definition: NSKernel.h:66
const VariableValue & _w_vel
Definition: NSKernel.h:39
const MaterialProperty< std::vector< RealTensorValue > > & _calC
Definition: NSSUPGBase.h:48
bool isNSVariable(unsigned var)
Helper functions for mapping Moose variable numberings into the "canonical" numbering for the compres...
Definition: NSKernel.C:78
const MaterialProperty< Real > & _taum
Definition: NSSUPGBase.h:40
unsigned int _component
const VariableValue & _u_vel
Definition: NSKernel.h:37
const MaterialProperty< std::vector< RealTensorValue > > & _calA
Definition: NSSUPGBase.h:45
const VariableValue & _v_vel
Definition: NSKernel.h:38
const MaterialProperty< Real > & _tauc
Definition: NSSUPGBase.h:39
const MaterialProperty< std::vector< std::vector< RealTensorValue > > > & _calE
Definition: NSSUPGBase.h:51
unsigned mapVarNumber(unsigned var)
Definition: NSKernel.C:88
const MaterialProperty< Real > & _taue
Definition: NSSUPGBase.h:41

◆ computeQpJacobian()

Real NSSUPGMomentum::computeQpJacobian ( )
protectedvirtual

Definition at line 88 of file NSSUPGMomentum.C.

89 {
90  // Set variable number for the computeJacobianHelper() function based on the
91  // _component and the knowledge that this is the on-diagonal entry.
92  unsigned int var_number[3] = {_rhou_var_number, _rhov_var_number, _rhow_var_number};
93 
94  // Call the common computeJacobianHelper() function
95  return computeJacobianHelper(var_number[_component]);
96 }
unsigned _rhov_var_number
Definition: NSKernel.h:57
unsigned _rhow_var_number
Definition: NSKernel.h:58
Real computeJacobianHelper(unsigned int var)
unsigned int _component
unsigned _rhou_var_number
Definition: NSKernel.h:56

◆ computeQpOffDiagJacobian()

Real NSSUPGMomentum::computeQpOffDiagJacobian ( unsigned int  jvar)
protectedvirtual

Definition at line 99 of file NSSUPGMomentum.C.

100 {
101  return computeJacobianHelper(jvar);
102 }
Real computeJacobianHelper(unsigned int var)

◆ computeQpResidual()

Real NSSUPGMomentum::computeQpResidual ( )
protectedvirtual

Definition at line 34 of file NSSUPGMomentum.C.

35 {
36  // See "Component SUPG contributions" section of notes for details.
37 
38  // Values to be summed up and returned
39  Real mass_term = 0.0;
40  Real mom_term = 0.0;
41  Real energy_term = 0.0;
42 
43  // Velocity vector
44  RealVectorValue vel(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
45 
46  // Velocity vector magnitude squared
47  Real velmag2 = vel.norm_sq();
48 
49  // Ratio of specific heats
50  const Real gam = _fp.gamma();
51 
52  // Velocity vector, dotted with the test function gradient
53  Real U_grad_phi = vel * _grad_test[_i][_qp];
54 
55  // _component'th entry of test function gradient
56  Real dphi_dxk = _grad_test[_i][_qp](_component);
57 
58  // Vector object of momentum equation strong residuals
59  RealVectorValue Ru(
60  _strong_residuals[_qp][1], _strong_residuals[_qp][2], _strong_residuals[_qp][3]);
61 
62  // 1.) The mass-residual term:
63  Real mass_coeff = 0.5 * (gam - 1.0) * velmag2 * dphi_dxk - vel(_component) * U_grad_phi;
64 
65  mass_term = _tauc[_qp] * mass_coeff * _strong_residuals[_qp][0];
66  // Moose::out << "mass_term[" << _qp << "]=" << mass_term << std::endl;
67 
68  // 2.) The momentum-residual term:
69  Real mom_term1 =
70  U_grad_phi *
71  _strong_residuals[_qp][_component + 1]; // <- momentum indices are 1,2,3, _component is 0,1,2
72  Real mom_term2 = (1. - gam) * dphi_dxk * (vel * Ru);
73  Real mom_term3 = vel(_component) * (_grad_test[_i][_qp] * Ru);
74 
75  mom_term = _taum[_qp] * (mom_term1 + mom_term2 + mom_term3);
76  // Moose::out << "mom_term[" << _qp << "]=" << mom_term << std::endl;
77 
78  // 3.) The energy-residual term:
79  energy_term = _taue[_qp] * (gam - 1.0) * dphi_dxk * _strong_residuals[_qp][4];
80 
81  // For printing purposes only
82  Real result = mass_term + mom_term + energy_term;
83 
84  return result;
85 }
const IdealGasFluidProperties & _fp
Definition: NSKernel.h:66
const VariableValue & _w_vel
Definition: NSKernel.h:39
const MaterialProperty< Real > & _taum
Definition: NSSUPGBase.h:40
unsigned int _component
const VariableValue & _u_vel
Definition: NSKernel.h:37
const VariableValue & _v_vel
Definition: NSKernel.h:38
const MaterialProperty< std::vector< Real > > & _strong_residuals
Definition: NSSUPGBase.h:42
const MaterialProperty< Real > & _tauc
Definition: NSSUPGBase.h:39
const MaterialProperty< Real > & _taue
Definition: NSSUPGBase.h:41

◆ 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(), computeJacobianHelper(), NSMassInviscidFlux::computeQpOffDiagJacobian(), NSEnergyInviscidFlux::computeQpOffDiagJacobian(), NSMomentumInviscidFluxWithGradP::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(), computeJacobianHelper(), NSMassInviscidFlux::computeQpOffDiagJacobian(), NSMomentumInviscidFluxWithGradP::computeQpOffDiagJacobian(), NSMomentumInviscidFlux::computeQpOffDiagJacobian(), NSEnergyViscousFlux::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

Member Data Documentation

◆ _calA

const MaterialProperty<std::vector<RealTensorValue> >& NSSUPGBase::_calA
protectedinherited

◆ _calC

const MaterialProperty<std::vector<RealTensorValue> >& NSSUPGBase::_calC
protectedinherited

Definition at line 48 of file NSSUPGBase.h.

Referenced by NSSUPGEnergy::computeJacobianHelper(), and computeJacobianHelper().

◆ _calE

const MaterialProperty<std::vector<std::vector<RealTensorValue> > >& NSSUPGBase::_calE
protectedinherited

Definition at line 51 of file NSSUPGBase.h.

Referenced by NSSUPGEnergy::computeJacobianHelper(), and computeJacobianHelper().

◆ _component

unsigned int NSSUPGMomentum::_component
protected

Definition at line 38 of file NSSUPGMomentum.h.

Referenced by computeJacobianHelper(), computeQpJacobian(), and computeQpResidual().

◆ _d_rhodot_du

const VariableValue& NSSUPGBase::_d_rhodot_du
protectedinherited

Definition at line 62 of file NSSUPGBase.h.

◆ _d_rhoEdot_du

const VariableValue& NSSUPGBase::_d_rhoEdot_du
protectedinherited

Definition at line 66 of file NSSUPGBase.h.

◆ _d_rhoudot_du

const VariableValue& NSSUPGBase::_d_rhoudot_du
protectedinherited

Definition at line 63 of file NSSUPGBase.h.

Referenced by NSSUPGMass::computeJacobianHelper().

◆ _d_rhovdot_du

const VariableValue& NSSUPGBase::_d_rhovdot_du
protectedinherited

Definition at line 64 of file NSSUPGBase.h.

Referenced by NSSUPGMass::computeJacobianHelper().

◆ _d_rhowdot_du

const VariableValue& NSSUPGBase::_d_rhowdot_du
protectedinherited

Definition at line 65 of file NSSUPGBase.h.

Referenced by NSSUPGMass::computeJacobianHelper().

◆ _dynamic_viscosity

const MaterialProperty<Real>& NSSUPGBase::_dynamic_viscosity
protectedinherited

Definition at line 34 of file NSSUPGBase.h.

◆ _enthalpy

const VariableValue& NSSUPGBase::_enthalpy
protectedinherited

◆ _fp

const IdealGasFluidProperties& NSKernel::_fp
protectedinherited

◆ _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

◆ _hsupg

const MaterialProperty<Real>& NSSUPGBase::_hsupg
protectedinherited

Definition at line 38 of file NSSUPGBase.h.

◆ _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

◆ _strong_residuals

const MaterialProperty<std::vector<Real> >& NSSUPGBase::_strong_residuals
protectedinherited

◆ _tauc

const MaterialProperty<Real>& NSSUPGBase::_tauc
protectedinherited

◆ _taue

const MaterialProperty<Real>& NSSUPGBase::_taue
protectedinherited

◆ _taum

const MaterialProperty<Real>& NSSUPGBase::_taum
protectedinherited

◆ _temperature

const VariableValue& NSSUPGBase::_temperature
protectedinherited

Definition at line 69 of file NSSUPGBase.h.

◆ _thermal_conductivity

const MaterialProperty<Real>& NSSUPGBase::_thermal_conductivity
protectedinherited

Definition at line 35 of file NSSUPGBase.h.

◆ _u_vel

const VariableValue& NSKernel::_u_vel
protectedinherited

◆ _v_vel

const VariableValue& NSKernel::_v_vel
protectedinherited

◆ _viscous_stress_tensor

const MaterialProperty<RealTensorValue>& NSSUPGBase::_viscous_stress_tensor
protectedinherited

Definition at line 33 of file NSSUPGBase.h.

◆ _w_vel

const VariableValue& NSKernel::_w_vel
protectedinherited

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