www.mooseframework.org
NSSUPGEnergy.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 #include "NSSUPGEnergy.h"
11 
12 // FluidProperties includes
14 
15 registerMooseObject("NavierStokesApp", NSSUPGEnergy);
16 
17 template <>
18 InputParameters
20 {
21  InputParameters params = validParams<NSSUPGBase>();
22  params.addClassDescription(
23  "Compute residual and Jacobian terms form the SUPG terms in the energy equation.");
24  return params;
25 }
26 
27 NSSUPGEnergy::NSSUPGEnergy(const InputParameters & parameters) : NSSUPGBase(parameters) {}
28 
29 Real
31 {
32  // See "Component SUPG contributions" section of notes for details.
33 
34  // Values to be summed up and returned
35  Real mass_term = 0.0;
36  Real mom_term = 0.0;
37  Real energy_term = 0.0;
38 
39  // Ratio of specific heats
40  const Real gam = _fp.gamma();
41 
42  // Velocity vector
43  RealVectorValue vel(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
44 
45  // Velocity vector magnitude squared
46  Real velmag2 = vel.norm_sq();
47 
48  // Velocity vector, dotted with the test function gradient
49  Real U_grad_phi = vel * _grad_test[_i][_qp];
50 
51  // Vector object of momentum equation strong residuals
52  RealVectorValue Ru(
53  _strong_residuals[_qp][1], _strong_residuals[_qp][2], _strong_residuals[_qp][3]);
54 
55  // 1.) The mass-residual term:
56  Real mass_coeff = (0.5 * (gam - 1.0) * velmag2 - _enthalpy[_qp]) * U_grad_phi;
57 
58  mass_term = _tauc[_qp] * mass_coeff * _strong_residuals[_qp][0];
59 
60  // 2.) The momentum-residual term:
61  Real mom_term1 = _enthalpy[_qp] * (_grad_test[_i][_qp] * Ru);
62  Real mom_term2 = (1.0 - gam) * U_grad_phi * (vel * Ru);
63 
64  mom_term = _taum[_qp] * (mom_term1 + mom_term2);
65 
66  // 3.) The energy-residual term:
67  energy_term = _taue[_qp] * gam * U_grad_phi * _strong_residuals[_qp][4];
68 
69  // For printing purposes only
70  Real result = mass_term + mom_term + energy_term;
71  // Moose::out << "result[" << _qp << "]=" << result << std::endl;
72 
73  return result;
74 }
75 
76 Real
78 {
79  // This is the energy equation, so pass the on-diagonal variable number.
81 }
82 
83 Real
85 {
86  return computeJacobianHelper(jvar);
87 }
88 
89 Real
91 {
92  if (isNSVariable(var))
93  {
94  // Convert the Moose numbering to canonical NS variable numbering.
95  unsigned mapped_var_number = mapVarNumber(var);
96 
97  // Convenience vars
98 
99  // Velocity vector
100  RealVectorValue vel(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
101 
102  // Velocity vector magnitude squared
103  Real velmag2 = vel.norm_sq();
104 
105  // Ratio of specific heats
106  const Real gam = _fp.gamma();
107 
108  // Shortcuts for shape function gradients at current qp.
109  RealVectorValue grad_test_i = _grad_test[_i][_qp];
110  RealVectorValue grad_phi_j = _grad_phi[_j][_qp];
111 
112  // ...
113 
114  // 1.) taum- and taue-proportional terms present for any variable:
115 
116  //
117  // Art. Diffusion matrix for taum-proportional term = (diag(H) + (1-gam)*S) * A_{ell}
118  //
119  RealTensorValue mom_mat;
120  mom_mat(0, 0) = mom_mat(1, 1) = mom_mat(2, 2) = _enthalpy[_qp]; // (diag(H)
121  mom_mat += (1. - gam) * _calC[_qp][0] * _calC[_qp][0].transpose(); // + (1-gam)*S)
122  mom_mat = mom_mat * _calA[_qp][mapped_var_number]; // * A_{ell}
123  Real mom_term = _taum[_qp] * grad_test_i * (mom_mat * grad_phi_j);
124 
125  //
126  // Art. Diffusion matrix for taue-proportinal term = gam * E_{ell},
127  // where E_{ell} = C_k * E_{k ell} for any k, summation over k *not* implied.
128  //
129  RealTensorValue ene_mat = gam * _calC[_qp][0] * _calE[_qp][0][mapped_var_number];
130  Real ene_term = _taue[_qp] * grad_test_i * (ene_mat * grad_phi_j);
131 
132  // 2.) Terms only present if the variable is one of the momentums
133  Real mass_term = 0.;
134 
135  switch (mapped_var_number)
136  {
137  case 1:
138  case 2:
139  case 3:
140  {
141  // Variable for zero-based indexing into local matrices and vectors.
142  unsigned m_local = mapped_var_number - 1;
143 
144  //
145  // Art. Diffusion matrix for tauc-proportional term = (0.5*(gam-1.)*velmag2 - H)*C_m
146  //
147  RealTensorValue mass_mat =
148  (0.5 * (gam - 1.) * velmag2 - _enthalpy[_qp]) * _calC[_qp][m_local];
149  mass_term = _tauc[_qp] * grad_test_i * (mass_mat * grad_phi_j);
150 
151  // Don't even need to break, no other cases to fall through to...
152  break;
153  }
154  }
155 
156  // Sum up values and return
157  return mass_term + mom_term + ene_term;
158  }
159  else
160  return 0.0;
161 }
NSKernel::isNSVariable
bool isNSVariable(unsigned var)
Helper functions for mapping Moose variable numberings into the "canonical" numbering for the compres...
Definition: NSKernel.C:78
IdealGasFluidProperties.h
NSSUPGEnergy::computeQpJacobian
virtual Real computeQpJacobian()
Definition: NSSUPGEnergy.C:77
registerMooseObject
registerMooseObject("NavierStokesApp", NSSUPGEnergy)
NSSUPGBase::_calE
const MaterialProperty< std::vector< std::vector< RealTensorValue > > > & _calE
Definition: NSSUPGBase.h:50
NSSUPGBase::_enthalpy
const VariableValue & _enthalpy
Definition: NSSUPGBase.h:71
NSSUPGBase::_taum
const MaterialProperty< Real > & _taum
Definition: NSSUPGBase.h:39
validParams< NSSUPGBase >
InputParameters validParams< NSSUPGBase >()
Definition: NSSUPGBase.C:19
NSSUPGBase::_calA
const MaterialProperty< std::vector< RealTensorValue > > & _calA
Definition: NSSUPGBase.h:44
NSKernel::_rhoE_var_number
unsigned _rhoE_var_number
Definition: NSKernel.h:58
IdealGasFluidProperties::gamma
virtual Real gamma() const
Definition: IdealGasFluidProperties.h:117
NSSUPGBase
This class acts as a base class for stabilization kernels.
Definition: NSSUPGBase.h:25
NSSUPGEnergy.h
NSKernel::_v_vel
const VariableValue & _v_vel
Definition: NSKernel.h:37
NSKernel::_u_vel
const VariableValue & _u_vel
Definition: NSKernel.h:36
NSSUPGEnergy::computeJacobianHelper
Real computeJacobianHelper(unsigned var)
Definition: NSSUPGEnergy.C:90
NSSUPGBase::_calC
const MaterialProperty< std::vector< RealTensorValue > > & _calC
Definition: NSSUPGBase.h:47
NSSUPGBase::_strong_residuals
const MaterialProperty< std::vector< Real > > & _strong_residuals
Definition: NSSUPGBase.h:41
NSSUPGEnergy::NSSUPGEnergy
NSSUPGEnergy(const InputParameters &parameters)
Definition: NSSUPGEnergy.C:27
validParams< NSSUPGEnergy >
InputParameters validParams< NSSUPGEnergy >()
Definition: NSSUPGEnergy.C:19
NSSUPGEnergy::computeQpOffDiagJacobian
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
Definition: NSSUPGEnergy.C:84
NSSUPGEnergy
Compute residual and Jacobian terms form the SUPG terms in the energy equation.
Definition: NSSUPGEnergy.h:24
NSKernel::_w_vel
const VariableValue & _w_vel
Definition: NSKernel.h:38
NSKernel::_fp
const IdealGasFluidProperties & _fp
Definition: NSKernel.h:65
NSSUPGEnergy::computeQpResidual
virtual Real computeQpResidual()
Definition: NSSUPGEnergy.C:30
NSSUPGBase::_taue
const MaterialProperty< Real > & _taue
Definition: NSSUPGBase.h:40
NSSUPGBase::_tauc
const MaterialProperty< Real > & _tauc
Definition: NSSUPGBase.h:38
NSKernel::mapVarNumber
unsigned mapVarNumber(unsigned var)
Definition: NSKernel.C:88