https://mooseframework.inl.gov
RDG3EqnMaterial.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "RDG3EqnMaterial.h"
12 
13 registerMooseObject("ThermalHydraulicsApp", RDG3EqnMaterial);
14 
17 {
20 
21  params.addClassDescription(
22  "Reconstructed solution values for the 1-D, 1-phase, variable-area Euler equations");
23 
24  params.addRequiredCoupledVar("A_elem", "Cross-sectional area, elemental");
25  params.addRequiredCoupledVar("A_linear", "Cross-sectional area, linear");
26  params.addRequiredCoupledVar("rhoA", "Conserved variable: rho*A");
27  params.addRequiredCoupledVar("rhouA", "Conserved variable: rho*u*A");
28  params.addRequiredCoupledVar("rhoEA", "Conserved variable: rho*E*A");
29 
30  params.addRequiredParam<MaterialPropertyName>("direction",
31  "Flow channel direction material property name");
32 
33  params.addRequiredParam<UserObjectName>("fluid_properties",
34  "Name of fluid properties user object");
35 
36  return params;
37 }
38 
40  : Material(parameters),
41  SlopeReconstruction1DInterface<false>(this),
42 
43  _A_avg(coupledValue("A_elem")),
44  _A_linear(coupledValue("A_linear")),
45  _rhoA_avg(coupledValue("rhoA")),
46  _rhouA_avg(coupledValue("rhouA")),
47  _rhoEA_avg(coupledValue("rhoEA")),
48 
49  _A_var(getVar("A_elem", 0)),
50  _rhoA_var(getVar("rhoA", 0)),
51  _rhouA_var(getVar("rhouA", 0)),
52  _rhoEA_var(getVar("rhoEA", 0)),
53 
54  _dir(getMaterialProperty<RealVectorValue>("direction")),
55 
56  _rhoA(declareProperty<Real>("rhoA")),
57  _rhouA(declareProperty<Real>("rhouA")),
58  _rhoEA(declareProperty<Real>("rhoEA")),
59 
60  _fp(getUserObject<SinglePhaseFluidProperties>("fluid_properties"))
61 {
62 }
63 
64 void
66 {
67  // Get the limited slopes of the primitive variables: {p, u, T}.
68  const auto slopes = getElementSlopes(_current_elem);
69  const Real p_slope = slopes[PRESSURE];
70  const Real vel_slope = slopes[VELOCITY];
71  const Real T_slope = slopes[TEMPERATURE];
72 
73  // compute primitive variables from the cell-average solution
74  const Real rho_avg = _rhoA_avg[_qp] / _A_avg[_qp];
75  const Real vel_avg = _rhouA_avg[_qp] / _rhoA_avg[_qp];
76  const Real v_avg = 1.0 / rho_avg;
77  const Real e_avg = _rhoEA_avg[_qp] / _rhoA_avg[_qp] - 0.5 * vel_avg * vel_avg;
78  const Real p_avg = _fp.p_from_v_e(v_avg, e_avg);
79  const Real T_avg = _fp.T_from_v_e(v_avg, e_avg);
80 
81  // apply slopes to primitive variables
82  const Real delta_x = (_q_point[_qp] - _current_elem->vertex_average()) * _dir[_qp];
83  const Real p = p_avg + p_slope * delta_x;
84  const Real vel = vel_avg + vel_slope * delta_x;
85  const Real T = T_avg + T_slope * delta_x;
86 
87  // compute reconstructed conserved variables
88  const Real rho = _fp.rho_from_p_T(p, T);
89  const Real e = _fp.e_from_p_rho(p, rho);
90  const Real E = e + 0.5 * vel * vel;
91 
92  _rhoA[_qp] = rho * _A_linear[_qp];
93  _rhouA[_qp] = _rhoA[_qp] * vel;
94  _rhoEA[_qp] = _rhoA[_qp] * E;
95 }
96 
97 std::vector<Real>
99 {
100  // get the cell-average conserved variables
101  Real A, rhoA, rhouA, rhoEA;
102  if (_is_implicit)
103  {
104  A = _A_var->getElementalValue(elem);
105  rhoA = _rhoA_var->getElementalValue(elem);
106  rhouA = _rhouA_var->getElementalValue(elem);
107  rhoEA = _rhoEA_var->getElementalValue(elem);
108  }
109  else
110  {
111  A = _A_var->getElementalValueOld(elem);
112  rhoA = _rhoA_var->getElementalValueOld(elem);
113  rhouA = _rhouA_var->getElementalValueOld(elem);
114  rhoEA = _rhoEA_var->getElementalValueOld(elem);
115  }
116 
117  // compute primitive variables
118 
119  const Real rho = rhoA / A;
120  const Real vel = rhouA / rhoA;
121  const Real v = 1.0 / rho;
122  const Real e = rhoEA / rhoA - 0.5 * vel * vel;
123 
124  std::vector<Real> W(_n_slopes);
125  W[PRESSURE] = _fp.p_from_v_e(v, e);
126  W[VELOCITY] = vel;
127  W[TEMPERATURE] = _fp.T_from_v_e(v, e);
128 
129  return W;
130 }
const MooseArray< Point > & _q_point
RDG3EqnMaterial(const InputParameters &parameters)
const VariableValue & _A_avg
Cross-sectional area, piecewise constant.
Reconstructed solution values for the 1-D, 1-phase, variable-area Euler equations.
virtual void computeQpProperties() override
MooseVariable * _rhouA_var
MaterialProperty< Real > & _rhouA
void addRequiredParam(const std::string &name, const std::string &doc_string)
OutputData getElementalValue(const Elem *elem, unsigned int idx=0) const
MooseVariable * _rhoA_var
unsigned int _qp
const VariableValue & _A_linear
Cross-sectional area, linear.
static InputParameters validParams()
const VariableValue & _rhouA_avg
MooseVariable * _A_var
Common class for single phase fluid properties.
const SinglePhaseFluidProperties & _fp
fluid properties user object
const VariableValue & _rhoA_avg
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const unsigned int _n_slopes
Number of slopes.
static const std::string v
Definition: NS.h:84
static InputParameters validParams()
OutputData getElementalValueOld(const Elem *elem, unsigned int idx=0) const
Interface class for 1-D slope reconstruction.
virtual std::vector< Real > computeElementPrimitiveVariables(const Elem *elem) const override
Computes the cell-average primitive variable values for an element.
MaterialProperty< Real > & _rhoA
void addClassDescription(const std::string &doc_string)
std::vector< GenericReal< is_ad > > getElementSlopes(const Elem *elem) const
Gets limited slopes for the primitive variables in the 1-D direction.
registerMooseObject("ThermalHydraulicsApp", RDG3EqnMaterial)
const VariableValue & _rhoEA_avg
bool _is_implicit
MooseVariable * _rhoEA_var
const Elem *const & _current_elem
MaterialProperty< Real > & _rhoEA
const MaterialProperty< RealVectorValue > & _dir
Flow channel direction.