NSSUPGMomentum.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 #include "NSSUPGMomentum.h"
8
9 // FluidProperties includes
11
12 template <>
13 InputParameters
15 {
16  InputParameters params = validParams<NSSUPGBase>();
18  "Compute residual and Jacobian terms form the SUPG terms in the momentum equation.");
20  return params;
21 }
22
23 NSSUPGMomentum::NSSUPGMomentum(const InputParameters & parameters)
24  : NSSUPGBase(parameters), _component(getParam<unsigned>("component"))
25 {
26 }
27
28 Real
30 {
31  // See "Component SUPG contributions" section of notes for details.
32
33  // Values to be summed up and returned
34  Real mass_term = 0.0;
35  Real mom_term = 0.0;
36  Real energy_term = 0.0;
37
38  // Velocity vector
39  RealVectorValue vel(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
40
41  // Velocity vector magnitude squared
42  Real velmag2 = vel.norm_sq();
43
44  // Ratio of specific heats
45  const Real gam = _fp.gamma();
46
47  // Velocity vector, dotted with the test function gradient
49
50  // _component'th entry of test function gradient
52
53  // Vector object of momentum equation strong residuals
54  RealVectorValue Ru(
55  _strong_residuals[_qp][1], _strong_residuals[_qp][2], _strong_residuals[_qp][3]);
56
57  // 1.) The mass-residual term:
58  Real mass_coeff = 0.5 * (gam - 1.0) * velmag2 * dphi_dxk - vel(_component) * U_grad_phi;
59
60  mass_term = _tauc[_qp] * mass_coeff * _strong_residuals[_qp][0];
61  // Moose::out << "mass_term[" << _qp << "]=" << mass_term << std::endl;
62
63  // 2.) The momentum-residual term:
64  Real mom_term1 =
66  _strong_residuals[_qp][_component + 1]; // <- momentum indices are 1,2,3, _component is 0,1,2
67  Real mom_term2 = (1. - gam) * dphi_dxk * (vel * Ru);
68  Real mom_term3 = vel(_component) * (_grad_test[_i][_qp] * Ru);
69
70  mom_term = _taum[_qp] * (mom_term1 + mom_term2 + mom_term3);
71  // Moose::out << "mom_term[" << _qp << "]=" << mom_term << std::endl;
72
73  // 3.) The energy-residual term:
74  energy_term = _taue[_qp] * (gam - 1.0) * dphi_dxk * _strong_residuals[_qp][4];
75
76  // For printing purposes only
77  Real result = mass_term + mom_term + energy_term;
78
79  return result;
80 }
81
82 Real
84 {
85  // Set variable number for the computeJacobianHelper() function based on the
86  // _component and the knowledge that this is the on-diagonal entry.
87  unsigned int var_number[3] = {_rhou_var_number, _rhov_var_number, _rhow_var_number};
88
89  // Call the common computeJacobianHelper() function
90  return computeJacobianHelper(var_number[_component]);
91 }
92
93 Real
95 {
96  return computeJacobianHelper(jvar);
97 }
98
99 Real
101 {
102  if (isNSVariable(var))
103  {
104  // Convert the Moose numbering to canonical NS variable numbering.
105  unsigned mapped_var_number = mapVarNumber(var);
106
107  // Convenience vars
108
109  // Velocity vector
110  RealVectorValue vel(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
111
112  // Velocity vector magnitude squared
113  Real velmag2 = vel.norm_sq();
114
115  // Ratio of specific heats
116  const Real gam = _fp.gamma();
117
118  // Shortcuts for shape function gradients at current qp.
121
122  // ...
123
124  // 1.) taum- and taue-proportional terms present for any variable:
125
126  //
127  // Art. Diffusion matrix for taum-proportional term = ( C_k + (1-gam)*C_k^T + diag(u_k) ) *
128  // calA_{ell}
129  //
130  RealTensorValue mom_mat;
131  mom_mat(0, 0) = mom_mat(1, 1) = mom_mat(2, 2) = vel(_component); // (diag(u_k)
132  mom_mat += _calC[_qp][_component]; // + C_k
133  mom_mat += (1.0 - gam) * _calC[_qp][_component].transpose(); // + (1-gam)*C_k^T)
134  mom_mat = mom_mat * _calA[_qp][mapped_var_number]; // * calA_{ell}
135  Real mom_term =
137
138  //
139  // Art. Diffusion matrix for taue-proportional term = (gam-1) * calE_km
140  //
141  RealTensorValue ene_mat = (gam - 1) * _calE[_qp][_component][mapped_var_number];
142  Real ene_term =
144
145  // 2.) Terms only present if the variable is one of the momentums
146  Real mass_term = 0.0;
147
148  switch (mapped_var_number)
149  {
150  case 1:
151  case 2:
152  case 3:
153  {
154  // Variable for zero-based indexing into local matrices and vectors.
155  unsigned m_local = mapped_var_number - 1;
156
157  //
158  // Art. Diffusion matrix for tauc-proportional term = 0.5*(gam - 1.0)*velmag2*D_km -
159  // vel(_component)*C_m
160  //
161  RealTensorValue mass_mat;
162  mass_mat(_component, m_local) = 0.5 * (gam - 1.0) * velmag2; // 0.5*(gam - 1.0)*velmag2*D_km
163  mass_mat -= vel(_component) * _calC[_qp][m_local]; // vel(_component)*C_m
164  mass_term = _tauc[_qp] * grad_test_i *
166  }
167  // Nothing else to do if we are not a momentum...
168  }
169
170  // Sum up values and return
171  return mass_term + mom_term + ene_term;
172  }
173  else
174  return 0.0;
175 }
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
const IdealGasFluidProperties & _fp
Definition: NSKernel.h:63
const VariableValue & _w_vel
Definition: NSKernel.h:36
virtual Real computeQpJacobian()
InputParameters validParams< NSSUPGBase >()
Definition: NSSUPGBase.C:17
unsigned _rhov_var_number
Definition: NSKernel.h:54
const MaterialProperty< std::vector< RealTensorValue > > & _calC
Definition: NSSUPGBase.h:45
NSSUPGMomentum(const InputParameters &parameters)
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
const MaterialProperty< Real > & _taum
Definition: NSSUPGBase.h:37
Real computeJacobianHelper(unsigned int var)
virtual Real computeQpResidual()
unsigned int _component
const VariableValue & _u_vel
Definition: NSKernel.h:34
virtual Real gamma(Real v=0., Real u=0.) const override
Compute the ratio of specific heats.
const MaterialProperty< std::vector< RealTensorValue > > & _calA
Definition: NSSUPGBase.h:42
const VariableValue & _v_vel
Definition: NSKernel.h:35
const MaterialProperty< std::vector< Real > > & _strong_residuals
Definition: NSSUPGBase.h:39
const MaterialProperty< Real > & _tauc
Definition: NSSUPGBase.h:36
This class acts as a base class for stabilization kernels.
Definition: NSSUPGBase.h:23
InputParameters validParams< NSSUPGMomentum >()
const MaterialProperty< std::vector< std::vector< RealTensorValue > > > & _calE
Definition: NSSUPGBase.h:48
unsigned mapVarNumber(unsigned var)
Definition: NSKernel.C:86
unsigned _rhou_var_number
Definition: NSKernel.h:53
const MaterialProperty< Real > & _taue
Definition: NSSUPGBase.h:38