www.mooseframework.org
NSIntegratedBC.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 "NSIntegratedBC.h"
11 
12 // FluidProperties includes
14 
15 // MOOSE includes
16 #include "MooseMesh.h"
17 
18 template <>
19 InputParameters
21 {
22  InputParameters params = validParams<IntegratedBC>();
23 
24  params.addClassDescription("This class couples together all the variables for the compressible "
25  "Navier-Stokes equations to allow them to be used in derived "
26  "IntegratedBC classes.");
27 
28  params.addRequiredCoupledVar(NS::velocity_x, "x-velocity");
29  params.addCoupledVar(NS::velocity_y, "y-velocity"); // only required in >= 2D
30  params.addCoupledVar(NS::velocity_z, "z-velocity"); // only required in 3D
31 
32  params.addRequiredCoupledVar(NS::density, "density");
33  params.addRequiredCoupledVar(NS::momentum_x, "x-momentum");
34  params.addCoupledVar(NS::momentum_y, "y-momentum"); // only required in >= 2D
35  params.addCoupledVar(NS::momentum_z, "z-momentum"); // only required in 3D
36  params.addRequiredCoupledVar(NS::total_energy, "total energy");
37  params.addRequiredParam<UserObjectName>("fluid_properties",
38  "The name of the user object for fluid properties");
39 
40  return params;
41 }
42 
43 NSIntegratedBC::NSIntegratedBC(const InputParameters & parameters)
44  : IntegratedBC(parameters),
45  _u_vel(coupledValue(NS::velocity_x)),
46  _v_vel(_mesh.dimension() >= 2 ? coupledValue(NS::velocity_y) : _zero),
47  _w_vel(_mesh.dimension() == 3 ? coupledValue(NS::velocity_z) : _zero),
48 
49  _rho(coupledValue(NS::density)),
50  _rho_u(coupledValue(NS::momentum_x)),
51  _rho_v(_mesh.dimension() >= 2 ? coupledValue(NS::momentum_y) : _zero),
52  _rho_w(_mesh.dimension() == 3 ? coupledValue(NS::momentum_z) : _zero),
53  _rho_E(coupledValue(NS::total_energy)),
54 
55  _grad_rho(coupledGradient(NS::density)),
56  _grad_rho_u(coupledGradient(NS::momentum_x)),
57  _grad_rho_v(_mesh.dimension() >= 2 ? coupledGradient(NS::momentum_y) : _grad_zero),
58  _grad_rho_w(_mesh.dimension() == 3 ? coupledGradient(NS::momentum_z) : _grad_zero),
59  _grad_rho_E(coupledGradient(NS::total_energy)),
60 
61  // Variable numberings
62  _rho_var_number(coupled(NS::density)),
63  _rhou_var_number(coupled(NS::momentum_x)),
64  _rhov_var_number(_mesh.dimension() >= 2 ? coupled(NS::momentum_y) : libMesh::invalid_uint),
65  _rhow_var_number(_mesh.dimension() == 3 ? coupled(NS::momentum_z) : libMesh::invalid_uint),
66  _rhoE_var_number(coupled(NS::total_energy)),
67 
68  _dynamic_viscosity(getMaterialProperty<Real>("dynamic_viscosity")),
69  _viscous_stress_tensor(getMaterialProperty<RealTensorValue>("viscous_stress_tensor")),
70 
71  // FluidProperties UserObject
72  _fp(getUserObject<IdealGasFluidProperties>("fluid_properties"))
73 {
74 }
75 
76 bool
78 {
79  if (var == _rho_var_number || var == _rhou_var_number || var == _rhov_var_number ||
80  var == _rhow_var_number || var == _rhoE_var_number)
81  return true;
82  else
83  return false;
84 }
85 
86 unsigned
88 {
89  // Convert the Moose numbering to:
90  // 0 for rho
91  // 1 for rho*u
92  // 2 for rho*v
93  // 3 for rho*w
94  // 4 for rho*e
95  // regardless of the problem dimension, etc.
96  unsigned int mapped_var_number;
97 
98  if (var == _rho_var_number)
99  mapped_var_number = 0;
100  else if (var == _rhou_var_number)
101  mapped_var_number = 1;
102  else if (var == _rhov_var_number)
103  mapped_var_number = 2;
104  else if (var == _rhow_var_number)
105  mapped_var_number = 3;
106  else if (var == _rhoE_var_number)
107  mapped_var_number = 4;
108  else
109  mooseError("Invalid var!");
110 
111  return mapped_var_number;
112 }
unsigned _rhov_var_number
Definition: NS.h:13
const std::string momentum_x
Definition: NS.h:16
bool isNSVariable(unsigned var)
const std::string velocity_z
Definition: NS.h:23
const std::string density
Definition: NS.h:15
unsigned _rhou_var_number
const std::string velocity_x
Definition: NS.h:21
NSIntegratedBC(const InputParameters &parameters)
unsigned _rhow_var_number
unsigned _rho_var_number
unsigned _rhoE_var_number
InputParameters validParams< NSIntegratedBC >()
const std::string velocity_y
Definition: NS.h:22
const std::string momentum_y
Definition: NS.h:17
unsigned mapVarNumber(unsigned var)
const std::string total_energy
Definition: NS.h:19
const std::string momentum_z
Definition: NS.h:18
Ideal gas fluid properties.