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