www.mooseframework.org
CNSFVMaterial.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 #include "CNSFVMaterial.h"
9 #include "MooseMesh.h"
10 
11 #include "libmesh/quadrature.h"
12 
13 template <>
14 InputParameters
16 {
17  InputParameters params = validParams<Material>();
18 
19  params.addClassDescription("A material kernel for the CNS equations.");
20 
21  params.addRequiredCoupledVar("rho", "Conserved variable: rho");
22 
23  params.addRequiredCoupledVar("rhou", "Conserved variable: rhou");
24 
25  params.addCoupledVar("rhov", "Conserved variable: rhov");
26 
27  params.addCoupledVar("rhow", "Conserved variable: rhow");
28 
29  params.addRequiredCoupledVar("rhoe", "Conserved variable: rhoe");
30 
31  params.addRequiredParam<UserObjectName>("slope_limiting", "Name for slope limiting user object");
32 
33  params.addRequiredParam<UserObjectName>("fluid_properties",
34  "Name for fluid properties user object");
35 
36  return params;
37 }
38 
39 CNSFVMaterial::CNSFVMaterial(const InputParameters & parameters)
40  : Material(parameters),
41  _rhoc(coupledValue("rho")),
42  _rhouc(coupledValue("rhou")),
43  _rhovc(isCoupled("rhov") ? coupledValue("rhov") : _zero),
44  _rhowc(isCoupled("rhow") ? coupledValue("rhow") : _zero),
45  _rhoec(coupledValue("rhoe")),
46  _lslope(getUserObject<SlopeLimitingBase>("slope_limiting")),
47  _fp(getUserObject<SinglePhaseFluidProperties>("fluid_properties")),
48  _rho(declareProperty<Real>("rho")),
49  _rhou(declareProperty<Real>("rhou")),
50  _rhov(declareProperty<Real>("rhov")),
51  _rhow(declareProperty<Real>("rhow")),
52  _rhoe(declareProperty<Real>("rhoe")),
53  _vmag(declareProperty<Real>("velocity_magnitude")),
54  _pres(declareProperty<Real>("pressure")),
55  _temp(declareProperty<Real>("temperature")),
56  _enth(declareProperty<Real>("enthalpy")),
57  _csou(declareProperty<Real>("speed_of_sound")),
58  _mach(declareProperty<Real>("mach_number")),
59  _uadv(declareProperty<Real>("vel_x")),
60  _vadv(declareProperty<Real>("vel_y")),
61  _wadv(declareProperty<Real>("vel_z")),
62  _gamma(declareProperty<Real>("gamma"))
63 {
64 }
65 
67 
68 void
70 {
72  _rho[_qp] = _rhoc[_qp];
73  _rhou[_qp] = _rhouc[_qp];
74  _rhov[_qp] = _rhovc[_qp];
75  _rhow[_qp] = _rhowc[_qp];
76  _rhoe[_qp] = _rhoec[_qp];
77 
79  _uadv[_qp] = _rhou[_qp] / _rho[_qp];
80  _vadv[_qp] = _rhov[_qp] / _rho[_qp];
81  _wadv[_qp] = _rhow[_qp] / _rho[_qp];
82 
83  Real vdov = _uadv[_qp] * _uadv[_qp] + _vadv[_qp] * _vadv[_qp] + _wadv[_qp] * _wadv[_qp];
84 
85  Real v = 1. / _rho[_qp];
86  Real e = _rhoe[_qp] / _rho[_qp] - 0.5 * vdov;
87 
88  _pres[_qp] = _fp.pressure(v, e);
89  _temp[_qp] = _fp.temperature(v, e);
90  _gamma[_qp] = _fp.gamma(v, e);
91 
93  if (_bnd)
94  {
96 
97  unsigned int nvars = 5;
98  std::vector<RealGradient> ugrad(nvars, RealGradient(0., 0., 0.));
99  ugrad = _lslope.getElementSlope(_current_elem->id());
100 
102 
103  RealGradient dvec = _q_point[_qp] - _current_elem->centroid();
104 
106 
107  _pres[_qp] += ugrad[0] * dvec;
108  _uadv[_qp] += ugrad[1] * dvec;
109  _vadv[_qp] += ugrad[2] * dvec;
110  _wadv[_qp] += ugrad[3] * dvec;
111  _temp[_qp] += ugrad[4] * dvec;
112 
113  _rho[_qp] = _fp.rho(_pres[_qp], _temp[_qp]);
114 
115  _rhou[_qp] = _rho[_qp] * _uadv[_qp];
116 
117  _rhov[_qp] = _rho[_qp] * _vadv[_qp];
118 
119  _rhow[_qp] = _rho[_qp] * _wadv[_qp];
120 
121  _rhoe[_qp] = _rho[_qp] * _fp.e(_pres[_qp], _rho[_qp]) +
122  _rho[_qp] * 0.5 *
123  (_uadv[_qp] * _uadv[_qp] + _vadv[_qp] * _vadv[_qp] + _wadv[_qp] * _wadv[_qp]);
124 
126 
127  ugrad.clear();
128  }
129 
131  else if (!_bnd)
132  {
133  _vmag[_qp] = std::sqrt(vdov);
134 
135  _csou[_qp] = _fp.c(v, e);
136 
137  _enth[_qp] = (_rhoe[_qp] + _pres[_qp]) / _rho[_qp];
138 
139  _mach[_qp] = std::sqrt(vdov) / _csou[_qp];
140  }
141 }
virtual void computeQpProperties()
Definition: CNSFVMaterial.C:69
MaterialProperty< Real > & _wadv
z-velocity
MaterialProperty< Real > & _rho
rho
Definition: CNSFVMaterial.h:74
MaterialProperty< Real > & _rhov
rhov
Definition: CNSFVMaterial.h:78
MaterialProperty< Real > & _csou
speed of sound
Definition: CNSFVMaterial.h:92
MaterialProperty< Real > & _pres
pressure
Definition: CNSFVMaterial.h:86
const VariableValue & _rhovc
y-component of momentum
Definition: CNSFVMaterial.h:58
MaterialProperty< Real > & _rhow
rhow
Definition: CNSFVMaterial.h:80
MaterialProperty< Real > & _rhoe
rhoe
Definition: CNSFVMaterial.h:82
virtual Real temperature(Real v, Real u) const =0
Temperature as a function of specific internal energy and specific volume.
MaterialProperty< Real > & _rhou
rhou
Definition: CNSFVMaterial.h:76
virtual Real c(Real v, Real u) const =0
Sound speed.
const VariableValue & _rhoec
total energy
Definition: CNSFVMaterial.h:62
virtual ~CNSFVMaterial()
Definition: CNSFVMaterial.C:66
const VariableValue & _rhouc
x-component of momentum
Definition: CNSFVMaterial.h:56
MaterialProperty< Real > & _gamma
gamma
virtual const std::vector< RealGradient > & getElementSlope(dof_id_type elementid) const
accessor function call
virtual Real rho(Real pressure, Real temperature) const =0
Computes density from pressure and temperature.
MaterialProperty< Real > & _enth
specific total enthalpy
Definition: CNSFVMaterial.h:90
MaterialProperty< Real > & _vadv
y-velocity
Definition: CNSFVMaterial.h:98
Common class for single phase fluid properties.
CNSFVMaterial(const InputParameters &parameters)
Definition: CNSFVMaterial.C:39
const VariableValue & _rhowc
z-component pf momentum
Definition: CNSFVMaterial.h:60
MaterialProperty< Real > & _vmag
velocity magnitude
Definition: CNSFVMaterial.h:84
Base class for slope limiting to limit the slopes of cell average variables.
MaterialProperty< Real > & _mach
Mach number.
Definition: CNSFVMaterial.h:94
const SinglePhaseFluidProperties & _fp
fluid properties
Definition: CNSFVMaterial.h:69
MaterialProperty< Real > & _temp
temperature
Definition: CNSFVMaterial.h:88
const VariableValue & _rhoc
density
Definition: CNSFVMaterial.h:54
virtual Real gamma(Real v, Real u) const
Compute the ratio of specific heats.
InputParameters validParams< CNSFVMaterial >()
Definition: CNSFVMaterial.C:15
virtual Real pressure(Real v, Real u) const =0
Pressure as a function of specific internal energy and specific volume.
MaterialProperty< Real > & _uadv
x-velocity
Definition: CNSFVMaterial.h:96
const SlopeLimitingBase & _lslope
slope limiting
Definition: CNSFVMaterial.h:67
virtual Real e(Real pressure, Real rho) const =0
Computes internal energy from pressure and density.