https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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"
14
15registerMooseObject("ThermalHydraulicsApp", ADRDG3EqnMaterial);
16
19{
22
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 params.addCoupledVar("passives_times_area", "Passive transport solution variables");
32
33 params.addRequiredParam<MaterialPropertyName>("direction",
34 "Flow channel direction material property name");
35
36 params.addRequiredParam<UserObjectName>("fluid_properties",
37 "Name of fluid properties user object");
38
39 return params;
40}
41
43 : Material(parameters),
45
46 _A_avg(adCoupledValue("A_elem")),
47 _A_linear(adCoupledValue("A_linear")),
48 _rhoA_avg(adCoupledValue("rhoA")),
49 _rhouA_avg(adCoupledValue("rhouA")),
50 _rhoEA_avg(adCoupledValue("rhoEA")),
51
52 _A_var(getVar("A_elem", 0)),
53 _rhoA_var(getVar("rhoA", 0)),
54 _rhouA_var(getVar("rhouA", 0)),
55 _rhoEA_var(getVar("rhoEA", 0)),
56
57 _n_passives(isParamValid("passives_times_area") ? coupledComponents("passives_times_area") : 0),
58
59 _dir(getMaterialProperty<RealVectorValue>("direction")),
60
61 _rhoA(declareADProperty<Real>("rhoA")),
62 _rhouA(declareADProperty<Real>("rhouA")),
63 _rhoEA(declareADProperty<Real>("rhoEA")),
64 _passives_times_area(declareADProperty<std::vector<Real>>("passives_times_area")),
65
66 _fp(getUserObject<SinglePhaseFluidProperties>("fluid_properties"))
67{
73 for (const auto i : make_range(_n_passives))
74 {
75 _U_vars[THMVACE1D::N_FLUX_INPUTS + i] = getVar("passives_times_area", i);
76 _passives_times_area_avg.push_back(&adCoupledValue("passives_times_area", i));
77 }
78}
79
80void
82{
83 if (_scheme == None)
84 {
85 const auto A_ratio = _A_linear[_qp] / _A_avg[_qp];
86 _rhoA[_qp] = _rhoA_avg[_qp] * A_ratio;
87 _rhouA[_qp] = _rhouA_avg[_qp] * A_ratio;
88 _rhoEA[_qp] = _rhoEA_avg[_qp] * A_ratio;
89
91 for (const auto i : make_range(_n_passives))
93 }
94 else
95 {
96 // compute primitive variables from the cell-average solution
97 std::vector<ADReal> U_avg(THMVACE1D::N_FLUX_INPUTS + _n_passives, 0.0);
101 U_avg[THMVACE1D::AREA] = _A_avg[_qp];
102 for (const auto i : make_range(_n_passives))
104 auto W = FlowModel1PhaseUtils::computePrimitiveSolutionVector<true>(U_avg, _fp);
105
106 // compute and apply slopes to primitive variables
107 const auto slopes = getElementSlopes(_current_elem);
108 const auto delta_x = (_q_point[_qp] - _current_elem->vertex_average()) * _dir[_qp];
109 for (const auto m : make_range(W.size()))
110 W[m] = W[m] + slopes[m] * delta_x;
111
112 // compute reconstructed conservative variables
113 const auto U =
114 FlowModel1PhaseUtils::computeConservativeSolutionVector<true>(W, _A_linear[_qp], _fp);
118 for (const auto i : make_range(_n_passives))
120 }
121}
122
123std::vector<ADReal>
125{
126 const auto U =
127 FlowModel1PhaseUtils::getElementalSolutionVector<true>(elem, _U_vars, _is_implicit);
128 return FlowModel1PhaseUtils::computePrimitiveSolutionVector<true>(U, _fp);
129}
registerMooseObject("ThermalHydraulicsApp", ADRDG3EqnMaterial)
Reconstructed solution values for the 1-D, 1-phase, variable-area Euler equations.
std::vector< MooseVariable * > _U_vars
Solution variables vector.
virtual std::vector< ADReal > computeElementPrimitiveVariables(const Elem *elem) const override
Computes the cell-average primitive variable values for an element.
ADMaterialProperty< Real > & _rhoA
const SinglePhaseFluidProperties & _fp
fluid properties user object
const MaterialProperty< RealVectorValue > & _dir
Flow channel direction.
MooseVariable * _A_var
const unsigned int _n_passives
Number of passive transport variables.
MooseVariable * _rhouA_var
ADMaterialProperty< Real > & _rhouA
ADMaterialProperty< Real > & _rhoEA
const ADVariableValue & _A_linear
Cross-sectional area, linear.
virtual void computeQpProperties() override
MooseVariable * _rhoA_var
const ADVariableValue & _rhoEA_avg
const ADVariableValue & _rhoA_avg
ADMaterialProperty< std::vector< Real > > & _passives_times_area
const ADVariableValue & _A_avg
Cross-sectional area, piecewise constant.
const ADVariableValue & _rhouA_avg
std::vector< const ADVariableValue * > _passives_times_area_avg
MooseVariable * _rhoEA_var
static InputParameters validParams()
ADRDG3EqnMaterial(const InputParameters &parameters)
const ADVariableValue & adCoupledValue(const std::string &var_name, unsigned int comp=0) const
MooseVariable * getVar(const std::string &var_name, unsigned int comp)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void addCoupledVar(const std::string &name, const std::string &doc_string)
unsigned int _qp
virtual void resize(const std::size_t size) override final
static InputParameters validParams()
const Elem *const & _current_elem
const MooseArray< Point > & _q_point
Common class for single phase fluid properties.
Interface class for 1-D slope reconstruction.
const ESlopeReconstructionType _scheme
Slope reconstruction scheme.
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
static const unsigned int N_FLUX_INPUTS
Number of numerical flux function inputs for 1D.