www.mooseframework.org
CNSFVCharacteristicBCUserObject.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 
9 
10 template <>
11 InputParameters
13 {
14  InputParameters params = validParams<BCUserObject>();
15 
16  params.addClassDescription("A user object that computes the ghost cell values based on the "
17  "characteristic boundary condition.");
18 
19  params.addRequiredParam<UserObjectName>("fluid_properties",
20  "Name for fluid properties user object");
21 
22  params.addRequiredParam<Real>("infinity_density", "Infinity density");
23 
24  params.addRequiredParam<Real>("infinity_x_velocity",
25  "Infinity velocity component in x-direction");
26 
27  params.addParam<Real>("infinity_y_velocity", 0., "Infinity velocity component in y-direction");
28 
29  params.addParam<Real>("infinity_z_velocity", 0., "Infinity velocity component in z-direction");
30 
31  params.addRequiredParam<Real>("infinity_pressure", "Infinity pressure");
32 
33  return params;
34 }
35 
37  : BCUserObject(parameters),
38  _fp(getUserObject<SinglePhaseFluidProperties>("fluid_properties")),
39  _inf_rho(getParam<Real>("infinity_density")),
40  _inf_uadv(getParam<Real>("infinity_x_velocity")),
41  _inf_vadv(getParam<Real>("infinity_y_velocity")),
42  _inf_wadv(getParam<Real>("infinity_z_velocity")),
43  _inf_pres(getParam<Real>("infinity_pressure"))
44 {
45 }
46 
47 std::vector<Real>
49  dof_id_type ielem,
50  const std::vector<Real> & uvec1,
51  const RealVectorValue & /*dwave*/) const
52 {
54 
55  Real rho1 = uvec1[0];
56  Real rhou1 = uvec1[1];
57  Real rhov1 = uvec1[2];
58  Real rhow1 = uvec1[3];
59  Real rhoe1 = uvec1[4];
60 
61  std::vector<Real> urigh(5, 0.);
62 
64 
65  Real rhom1 = 1. / rho1;
66  Real uadv1 = rhou1 * rhom1;
67  Real vadv1 = rhov1 * rhom1;
68  Real wadv1 = rhow1 * rhom1;
69  Real vdov1 = uadv1 * uadv1 + vadv1 * vadv1 + wadv1 * wadv1;
70  Real eint1 = rhoe1 * rhom1 - 0.5 * vdov1;
71  Real mach1 = std::sqrt(vdov1) / _fp.c(rhom1, eint1);
72 
73  if (mach1 > -1. && mach1 < 0.)
74  {
80 
81  urigh[0] = _inf_rho;
82  urigh[1] = _inf_rho * _inf_uadv;
83  urigh[2] = _inf_rho * _inf_vadv;
84  urigh[3] = _inf_rho * _inf_wadv;
85  urigh[4] =
87  0.5 * (_inf_uadv * _inf_uadv + _inf_vadv * _inf_vadv + _inf_wadv * _inf_wadv));
88  }
89  else if (mach1 >= 0. && mach1 < 1.)
90  {
96 
97  urigh[0] = rho1;
98  urigh[1] = rhou1;
99  urigh[2] = rhov1;
100  urigh[3] = rhow1;
101  urigh[4] = rho1 * _fp.e(_inf_pres, rho1) +
102  0.5 * (rhou1 * rhou1 + rhov1 * rhov1 + rhow1 * rhow1) / rho1;
103  }
104  else if (mach1 <= -1.)
105  {
111 
112  urigh[0] = _inf_rho;
113  urigh[1] = _inf_rho * _inf_uadv;
114  urigh[2] = _inf_rho * _inf_vadv;
115  urigh[3] = _inf_rho * _inf_wadv;
116  urigh[4] =
118  0.5 * (_inf_uadv * _inf_uadv + _inf_vadv * _inf_vadv + _inf_wadv * _inf_wadv));
119  }
120  else if (mach1 >= 1.)
121  {
127 
128  urigh[0] = rho1;
129  urigh[1] = rhou1;
130  urigh[2] = rhov1;
131  urigh[3] = rhow1;
132  urigh[4] = rhoe1;
133  }
134  else
135  mooseError("Something is wrong in ",
136  name(),
137  ": ",
138  __FUNCTION__,
139  "\n",
140  "ielem = ",
141  ielem,
142  "\n",
143  "iside = ",
144  iside,
145  "\n",
146  "mach1 = ",
147  mach1,
148  "\n");
149 
150  return urigh;
151 }
const SinglePhaseFluidProperties & _fp
virtual Real c(Real v, Real u) const =0
Sound speed.
InputParameters validParams< BCUserObject >()
Definition: BCUserObject.C:12
InputParameters validParams< CNSFVCharacteristicBCUserObject >()
Common class for single phase fluid properties.
CNSFVCharacteristicBCUserObject(const InputParameters &parameters)
A base class of user object for calculating the variable values in ghost element according to specifi...
Definition: BCUserObject.h:42
virtual std::vector< Real > getGhostCellValue(unsigned int iside, dof_id_type ielem, const std::vector< Real > &uvec1, const RealVectorValue &dwave) const
compute the ghost cell variable values
virtual Real e(Real pressure, Real rho) const =0
Computes internal energy from pressure and density.