https://mooseframework.inl.gov
ADRDG3EqnMaterial.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 "ADRDG3EqnMaterial.h"
12 #include "THMIndicesVACE.h"
13 #include "FlowModel1PhaseUtils.h"
14 
15 registerMooseObject("ThermalHydraulicsApp", ADRDG3EqnMaterial);
16 
19 {
22 
23  params.addClassDescription(
24  "Reconstructed solution values for the 1-D, 1-phase, variable-area Euler equations");
25 
26  params.addRequiredCoupledVar("A_elem", "Cross-sectional area, elemental");
27  params.addRequiredCoupledVar("A_linear", "Cross-sectional area, linear");
28  params.addRequiredCoupledVar("rhoA", "Conserved variable: rho*A");
29  params.addRequiredCoupledVar("rhouA", "Conserved variable: rho*u*A");
30  params.addRequiredCoupledVar("rhoEA", "Conserved variable: rho*E*A");
31 
32  params.addRequiredParam<MaterialPropertyName>("direction",
33  "Flow channel direction material property name");
34 
35  params.addRequiredParam<UserObjectName>("fluid_properties",
36  "Name of fluid properties user object");
37 
38  return params;
39 }
40 
42  : Material(parameters),
44 
45  _A_avg(adCoupledValue("A_elem")),
46  _A_linear(adCoupledValue("A_linear")),
47  _rhoA_avg(adCoupledValue("rhoA")),
48  _rhouA_avg(adCoupledValue("rhouA")),
49  _rhoEA_avg(adCoupledValue("rhoEA")),
50 
51  _A_var(getVar("A_elem", 0)),
52  _rhoA_var(getVar("rhoA", 0)),
53  _rhouA_var(getVar("rhouA", 0)),
54  _rhoEA_var(getVar("rhoEA", 0)),
55 
56  _dir(getMaterialProperty<RealVectorValue>("direction")),
57 
58  _rhoA(declareADProperty<Real>("rhoA")),
59  _rhouA(declareADProperty<Real>("rhouA")),
60  _rhoEA(declareADProperty<Real>("rhoEA")),
61 
62  _fp(getUserObject<SinglePhaseFluidProperties>("fluid_properties"))
63 {
69 }
70 
71 void
73 {
74  if (_scheme == None)
75  {
76  const auto A_ratio = _A_linear[_qp] / _A_avg[_qp];
77  _rhoA[_qp] = _rhoA_avg[_qp] * A_ratio;
78  _rhouA[_qp] = _rhouA_avg[_qp] * A_ratio;
79  _rhoEA[_qp] = _rhoEA_avg[_qp] * A_ratio;
80  }
81  else
82  {
83  // compute primitive variables from the cell-average solution
84  std::vector<ADReal> U_avg(THMVACE1D::N_FLUX_INPUTS, 0.0);
85  U_avg[THMVACE1D::RHOA] = _rhoA_avg[_qp];
88  U_avg[THMVACE1D::AREA] = _A_avg[_qp];
89  auto W = FlowModel1PhaseUtils::computePrimitiveSolutionVector<true>(U_avg, _fp);
90 
91  // compute and apply slopes to primitive variables
92  const auto slopes = getElementSlopes(_current_elem);
93  const auto delta_x = (_q_point[_qp] - _current_elem->vertex_average()) * _dir[_qp];
94  for (unsigned int m = 0; m < THMVACE1D::N_PRIM_VARS; m++)
95  W[m] = W[m] + slopes[m] * delta_x;
96 
97  // compute reconstructed conservative variables
98  const auto U =
99  FlowModel1PhaseUtils::computeConservativeSolutionVector<true>(W, _A_linear[_qp], _fp);
100  _rhoA[_qp] = U[THMVACE1D::RHOA];
103  }
104 }
105 
106 std::vector<ADReal>
108 {
109  const auto U =
110  FlowModel1PhaseUtils::getElementalSolutionVector<true>(elem, _U_vars, _is_implicit);
111  return FlowModel1PhaseUtils::computePrimitiveSolutionVector<true>(U, _fp);
112 }
const MooseArray< Point > & _q_point
ADMaterialProperty< Real > & _rhoA
virtual void computeQpProperties() override
ADMaterialProperty< Real > & _rhouA
const ADVariableValue & _rhoA_avg
static InputParameters validParams()
registerMooseObject("ThermalHydraulicsApp", ADRDG3EqnMaterial)
const ADVariableValue & _A_avg
Cross-sectional area, piecewise constant.
void addRequiredParam(const std::string &name, const std::string &doc_string)
const ESlopeReconstructionType _scheme
Slope reconstruction scheme.
unsigned int _qp
static InputParameters validParams()
virtual std::vector< ADReal > computeElementPrimitiveVariables(const Elem *elem) const override
Computes the cell-average primitive variable values for an element.
const MaterialProperty< RealVectorValue > & _dir
Flow channel direction.
Common class for single phase fluid properties.
const ADVariableValue & _rhoEA_avg
static const unsigned int N_FLUX_INPUTS
Number of numerical flux function inputs for 1D.
MooseVariable * _rhouA_var
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
static const unsigned int N_PRIM_VARS
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
ADRDG3EqnMaterial(const InputParameters &parameters)
std::vector< MooseVariable * > _U_vars
Solution variables vector.
Interface class for 1-D slope reconstruction.
MooseVariable * _A_var
MooseVariable * _rhoA_var
const ADVariableValue & _A_linear
Cross-sectional area, linear.
void addClassDescription(const std::string &doc_string)
MooseVariable * _rhoEA_var
const SinglePhaseFluidProperties & _fp
fluid properties user object
const ADVariableValue & _rhouA_avg
std::vector< GenericReal< is_ad > > getElementSlopes(const Elem *elem) const
Gets limited slopes for the primitive variables in the 1-D direction.
bool _is_implicit
Reconstructed solution values for the 1-D, 1-phase, variable-area Euler equations.
const Elem *const & _current_elem
ADMaterialProperty< Real > & _rhoEA