www.mooseframework.org
NSKernel.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 
8 // Navier-Stokes includes
9 #include "NS.h"
10 #include "NSKernel.h"
11 
12 // FluidProperties includes
14 
15 // MOOSE includes
16 #include "MooseMesh.h"
17 
18 template <>
19 InputParameters
21 {
22  InputParameters params = validParams<Kernel>();
23  params.addClassDescription("This class couples together all the variables for the compressible "
24  "Navier-Stokes equations to allow them to be used in derived Kernel "
25  "classes.");
26  params.addRequiredCoupledVar(NS::velocity_x, "x-velocity");
27  params.addCoupledVar(NS::velocity_y, "y-velocity"); // only required in 2D and 3D
28  params.addCoupledVar(NS::velocity_z, "z-velocity"); // only required in 3D
29  params.addRequiredCoupledVar(NS::density, "density");
30  params.addRequiredCoupledVar(NS::momentum_x, "x-momentum");
31  params.addCoupledVar(NS::momentum_y, "y-momentum"); // only required in 2D and 3D
32  params.addCoupledVar(NS::momentum_z, "z-momentum"); // only required in 3D
33  params.addRequiredCoupledVar(NS::total_energy, "total energy");
34  params.addRequiredParam<UserObjectName>("fluid_properties",
35  "The name of the user object for fluid properties");
36  return params;
37 }
38 
39 NSKernel::NSKernel(const InputParameters & parameters)
40  : Kernel(parameters),
41  // Coupled variables
42  _u_vel(coupledValue(NS::velocity_x)),
43  _v_vel(_mesh.dimension() >= 2 ? coupledValue(NS::velocity_y) : _zero),
44  _w_vel(_mesh.dimension() == 3 ? coupledValue(NS::velocity_z) : _zero),
45 
46  _rho(coupledValue(NS::density)),
47  _rho_u(coupledValue(NS::momentum_x)),
48  _rho_v(_mesh.dimension() >= 2 ? coupledValue(NS::momentum_y) : _zero),
49  _rho_w(_mesh.dimension() == 3 ? coupledValue(NS::momentum_z) : _zero),
50  _rho_E(coupledValue(NS::total_energy)),
51 
52  // Gradients
53  _grad_rho(coupledGradient(NS::density)),
54  _grad_rho_u(coupledGradient(NS::momentum_x)),
55  _grad_rho_v(_mesh.dimension() >= 2 ? coupledGradient(NS::momentum_y) : _grad_zero),
56  _grad_rho_w(_mesh.dimension() == 3 ? coupledGradient(NS::momentum_z) : _grad_zero),
57  _grad_rho_E(coupledGradient(NS::total_energy)),
58 
59  // Variable numberings
60  _rho_var_number(coupled(NS::density)),
61  _rhou_var_number(coupled(NS::momentum_x)),
62  _rhov_var_number(_mesh.dimension() >= 2 ? coupled(NS::momentum_y) : libMesh::invalid_uint),
63  _rhow_var_number(_mesh.dimension() == 3 ? coupled(NS::momentum_z) : libMesh::invalid_uint),
64  _rhoE_var_number(coupled(NS::total_energy)),
65 
66  // Material properties
67  _dynamic_viscosity(getMaterialProperty<Real>("dynamic_viscosity")),
68  _viscous_stress_tensor(getMaterialProperty<RealTensorValue>("viscous_stress_tensor")),
69 
70  // FluidProperties UserObject
71  _fp(getUserObject<IdealGasFluidProperties>("fluid_properties"))
72 {
73 }
74 
75 bool
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 }
84 
85 unsigned
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 }
Definition: NS.h:13
const std::string momentum_x
Definition: NS.h:16
const std::string velocity_z
Definition: NS.h:23
const std::string density
Definition: NS.h:15
unsigned _rhov_var_number
Definition: NSKernel.h:54
InputParameters validParams< NSKernel >()
Definition: NSKernel.C:20
unsigned _rho_var_number
Definition: NSKernel.h:52
const std::string velocity_x
Definition: NS.h:21
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 std::string velocity_y
Definition: NS.h:22
unsigned _rhoE_var_number
Definition: NSKernel.h:56
const std::string momentum_y
Definition: NS.h:17
const std::string total_energy
Definition: NS.h:19
const std::string momentum_z
Definition: NS.h:18
Ideal gas fluid properties.
NSKernel(const InputParameters &parameters)
Definition: NSKernel.C:39
unsigned mapVarNumber(unsigned var)
Definition: NSKernel.C:86
unsigned _rhou_var_number
Definition: NSKernel.h:53