www.mooseframework.org
CNSFVRiemannInvariantBCUserObject.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  "Riemann invariant 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  const InputParameters & parameters)
38  : BCUserObject(parameters),
39  _fp(getUserObject<SinglePhaseFluidProperties>("fluid_properties")),
40  _inf_rho(getParam<Real>("infinity_density")),
41  _inf_uadv(getParam<Real>("infinity_x_velocity")),
42  _inf_vadv(getParam<Real>("infinity_y_velocity")),
43  _inf_wadv(getParam<Real>("infinity_z_velocity")),
44  _inf_pres(getParam<Real>("infinity_pressure"))
45 {
46 }
47 
48 std::vector<Real>
50  dof_id_type ielem,
51  const std::vector<Real> & uvec1,
52  const RealVectorValue & dwave) const
53 {
55 
56  Real rho1 = uvec1[0];
57  Real rhou1 = uvec1[1];
58  Real rhov1 = uvec1[2];
59  Real rhow1 = uvec1[3];
60  Real rhoe1 = uvec1[4];
61 
62  Real nx = dwave(0);
63  Real ny = dwave(1);
64  Real nz = dwave(2);
65 
66  std::vector<Real> urigh(5, 0.);
67 
69 
70  Real rhom1 = 1. / rho1;
71  Real uadv1 = rhou1 * rhom1;
72  Real vadv1 = rhov1 * rhom1;
73  Real wadv1 = rhow1 * rhom1;
74  Real vdov1 = uadv1 * uadv1 + vadv1 * vadv1 + wadv1 * wadv1;
75  Real eint1 = rhoe1 * rhom1 - 0.5 * vdov1;
76  Real csou1 = _fp.c(rhom1, eint1);
77  Real gamma = _fp.gamma(rhom1, eint1);
78  Real gamm1 = gamma - 1.;
79  Real mach1 = std::sqrt(vdov1) / csou1;
80 
82 
83  if (mach1 <= -1.)
84  {
86 
87  urigh[0] = _inf_rho;
88  urigh[1] = _inf_rho * _inf_uadv;
89  urigh[2] = _inf_rho * _inf_vadv;
90  urigh[3] = _inf_rho * _inf_wadv;
91  urigh[4] =
93  0.5 * (_inf_uadv * _inf_uadv + _inf_vadv * _inf_vadv + _inf_wadv * _inf_wadv));
94  }
95  else if (mach1 > -1. && mach1 <= 0.)
96  {
98 
99  Real inf_eint = _fp.e(_inf_pres, _inf_rho);
100  Real inf_csou = _fp.c(1. / _inf_rho, inf_eint);
101 
102  Real rplus = (uadv1 * nx + vadv1 * ny + wadv1 * nz) + 2. * csou1 / gamm1;
103 
104  Real rmins = (_inf_uadv * nx + _inf_vadv * ny + _inf_wadv * nz) - 2. * inf_csou / gamm1;
105 
106  Real velob = (rplus + rmins) * 0.5;
107 
108  Real csoub = (rplus - rmins) * 0.25 * gamm1;
109 
110  Real vdiff = velob - _inf_uadv * nx - _inf_vadv * ny - _inf_wadv * nz;
111 
112  Real uadvb = _inf_uadv + vdiff * nx;
113  Real vadvb = _inf_vadv + vdiff * ny;
114  Real wadvb = _inf_wadv + vdiff * nz;
115 
116  Real entrb = inf_csou * inf_csou / gamma / std::pow(_inf_rho, gamm1);
117 
118  Real rhob = std::pow(csoub * csoub / gamma / entrb, 1. / gamm1);
119 
120  Real presb = rhob * csoub * csoub / gamma;
121 
122  urigh[0] = rhob;
123  urigh[1] = rhob * uadvb;
124  urigh[2] = rhob * vadvb;
125  urigh[3] = rhob * wadvb;
126  urigh[4] =
127  rhob * _fp.e(presb, rhob) + rhob * 0.5 * (uadvb * uadvb + vadvb * vadvb + wadvb * wadvb);
128  }
129  else if (mach1 > 0. && mach1 < 1.)
130  {
132 
133  Real inf_eint = _fp.e(_inf_pres, _inf_rho);
134  Real inf_csou = _fp.c(1. / _inf_rho, inf_eint);
135 
136  Real rplus = (uadv1 * nx + vadv1 * ny + wadv1 * nz) + 2. * csou1 / gamm1;
137 
138  Real rmins = (_inf_uadv * nx + _inf_vadv * ny + _inf_wadv * nz) - 2. * inf_csou / gamm1;
139 
140  Real velob = (rplus + rmins) * 0.5;
141 
142  Real csoub = (rplus - rmins) * 0.25 * gamm1;
143 
144  Real vdiff = velob - uadv1 * nx - vadv1 * ny - wadv1 * nz;
145 
146  Real uadvb = uadv1 + vdiff * nx;
147  Real vadvb = vadv1 + vdiff * ny;
148  Real wadvb = wadv1 + vdiff * nz;
149 
150  Real entrb = csou1 * csou1 / gamma / std::pow(rho1, gamm1);
151 
152  Real rhob = std::pow(csoub * csoub / gamma / entrb, 1. / gamm1);
153 
154  Real presb = rhob * csoub * csoub / gamma;
155 
156  urigh[0] = rhob;
157  urigh[1] = rhob * uadvb;
158  urigh[2] = rhob * vadvb;
159  urigh[3] = rhob * wadvb;
160  urigh[4] =
161  rhob * _fp.e(presb, rhob) + rhob * 0.5 * (uadvb * uadvb + vadvb * vadvb + wadvb * wadvb);
162  }
163  else if (mach1 >= 1.)
164  {
166 
167  urigh[0] = rho1;
168  urigh[1] = rhou1;
169  urigh[2] = rhov1;
170  urigh[3] = rhow1;
171  urigh[4] = rhoe1;
172  }
173  else
174  mooseError("Something is wrong in ",
175  name(),
176  ": ",
177  __FUNCTION__,
178  "\n",
179  "ielem = ",
180  ielem,
181  "\n",
182  "iside = ",
183  iside,
184  "\n",
185  "mach1 = ",
186  mach1,
187  "\n");
188 
189  return urigh;
190 }
virtual Real c(Real v, Real u) const =0
Sound speed.
CNSFVRiemannInvariantBCUserObject(const InputParameters &parameters)
InputParameters validParams< BCUserObject >()
Definition: BCUserObject.C:12
InputParameters validParams< CNSFVRiemannInvariantBCUserObject >()
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
Common class for single phase fluid properties.
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
A base class of user object for calculating the variable values in ghost element according to specifi...
Definition: BCUserObject.h:42
virtual Real gamma(Real v, Real u) const
Compute the ratio of specific heats.
virtual Real e(Real pressure, Real rho) const =0
Computes internal energy from pressure and density.