https://mooseframework.inl.gov
NumericalFluxGasMixHLLC.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 
12 #include "THMIndicesGasMix.h"
13 #include "Numerics.h"
14 
15 registerMooseObject("ThermalHydraulicsApp", NumericalFluxGasMixHLLC);
16 
19 {
21  params += NaNInterface::validParams();
22  params.addRequiredParam<UserObjectName>("fluid_properties",
23  "Name for fluid properties user object");
24  params.addClassDescription("Computes internal side flux for the 1-D, 1-phase, variable-area "
25  "Euler equations using the HLLC approximate Riemann solver.");
26  return params;
27 }
28 
30  : NumericalFluxGasMixBase(parameters),
31  NaNInterface(this),
32  _fp(getUserObject<VaporMixtureFluidProperties>("fluid_properties"))
33 {
34 }
35 
36 void
37 NumericalFluxGasMixHLLC::calcFlux(const std::vector<ADReal> & UL,
38  const std::vector<ADReal> & UR,
39  const RealVectorValue & nLR,
40  const RealVectorValue & t1,
41  const RealVectorValue & t2,
42  std::vector<ADReal> & FL,
43  std::vector<ADReal> & FR) const
44 {
45  // extract the conserved variables and area
46 
47  const ADReal xirhoAL = UL[THMGasMix3D::XIRHOA];
48  const ADReal rhoAL = UL[THMGasMix3D::RHOA];
49  const ADReal rhouAL = UL[THMGasMix3D::RHOUA];
50  const ADReal rhovAL = UL[THMGasMix3D::RHOVA];
51  const ADReal rhowAL = UL[THMGasMix3D::RHOWA];
52  const ADReal rhoEAL = UL[THMGasMix3D::RHOEA];
53  const ADReal AL = UL[THMGasMix3D::AREA];
54 
55  const ADReal xirhoAR = UR[THMGasMix3D::XIRHOA];
56  const ADReal rhoAR = UR[THMGasMix3D::RHOA];
57  const ADReal rhouAR = UR[THMGasMix3D::RHOUA];
58  const ADReal rhovAR = UR[THMGasMix3D::RHOVA];
59  const ADReal rhowAR = UR[THMGasMix3D::RHOWA];
60  const ADReal rhoEAR = UR[THMGasMix3D::RHOEA];
61  const ADReal AR = UR[THMGasMix3D::AREA];
62 
63  // compute the primitive variables
64 
65  const ADReal rhoL = rhoAL / AL;
66  const ADRealVectorValue uvecL(rhouAL / rhoAL, rhovAL / rhoAL, rhowAL / rhoAL);
67  const ADReal unL = uvecL * nLR;
68  const ADReal ut1L = uvecL * t1;
69  const ADReal ut2L = uvecL * t2;
70  const ADReal rhoEL = rhoEAL / AL;
71  const ADReal vL = 1.0 / rhoL;
72  const ADReal EL = rhoEAL / rhoAL;
73  const ADReal eL = EL - 0.5 * uvecL * uvecL;
74  const ADReal xiL = xirhoAL / rhoAL;
75  const ADReal pL = _fp.p_from_v_e(vL, eL, {xiL});
76  const ADReal TL = _fp.T_from_v_e(vL, eL, {xiL});
77  const ADReal cL = _fp.c_from_p_T(pL, TL, {xiL});
78 
79  const ADReal rhoR = rhoAR / AR;
80  const ADRealVectorValue uvecR(rhouAR / rhoAR, rhovAR / rhoAR, rhowAR / rhoAR);
81  const ADReal unR = uvecR * nLR;
82  const ADReal ut1R = uvecR * t1;
83  const ADReal ut2R = uvecR * t2;
84  const ADReal rhoER = rhoEAR / AR;
85  const ADReal vR = 1.0 / rhoR;
86  const ADReal ER = rhoEAR / rhoAR;
87  const ADReal eR = ER - 0.5 * uvecR * uvecR;
88  const ADReal xiR = xirhoAR / rhoAR;
89  const ADReal pR = _fp.p_from_v_e(vR, eR, {xiR});
90  const ADReal TR = _fp.T_from_v_e(vR, eR, {xiR});
91  const ADReal cR = _fp.c_from_p_T(pR, TR, {xiR});
92 
93  // compute wave speeds
94  const ADReal sL = std::min(unL - cL, unR - cR);
95  const ADReal sR = std::max(unL + cL, unR + cR);
96  const ADReal sm = (rhoR * unR * (sR - unR) - rhoL * unL * (sL - unL) + pL - pR) /
97  (rhoR * (sR - unR) - rhoL * (sL - unL));
98 
99  // compute Omega_L, Omega_R
100  const ADReal omegL = 1.0 / (sL - sm);
101  const ADReal omegR = 1.0 / (sR - sm);
102 
103  // compute p^*
104  const ADReal ps = rhoL * (sL - unL) * (sm - unL) + pL;
105 
106  // compute U_L^*, U_R^*
107 
108  const ADReal rhoLs = omegL * (sL - unL) * rhoL;
109  const ADReal rhounLs = omegL * ((sL - unL) * rhoL * unL + ps - pL);
110  const ADReal rhoELs = omegL * ((sL - unL) * rhoEL - pL * unL + ps * sm);
111 
112  const ADReal rhoRs = omegR * (sR - unR) * rhoR;
113  const ADReal rhounRs = omegR * ((sR - unR) * rhoR * unR + ps - pR);
114  const ADReal rhoERs = omegR * ((sR - unR) * rhoER - pR * unR + ps * sm);
115 
116  std::vector<ADReal> UL_1d(THMGasMix1D::N_FLUX_INPUTS);
122 
123  std::vector<ADReal> UR_1d(THMGasMix1D::N_FLUX_INPUTS);
129 
130  const ADReal A_flow = computeFlowArea(UL_1d, UR_1d);
131 
132  // compute the fluxes
133  FL.resize(THMGasMix3D::N_FLUX_OUTPUTS);
134  if (sL > 0.0)
135  {
136  FL[THMGasMix3D::SPECIES] = unL * xiL * rhoL * A_flow;
137  FL[THMGasMix3D::MASS] = unL * rhoL * A_flow;
138  FL[THMGasMix3D::MOM_NORM] = (unL * rhoL * unL + pL) * A_flow;
139  FL[THMGasMix3D::MOM_TAN1] = rhoL * unL * ut1L * A_flow;
140  FL[THMGasMix3D::MOM_TAN2] = rhoL * unL * ut2L * A_flow;
141  FL[THMGasMix3D::ENERGY] = unL * (rhoEL + pL) * A_flow;
142 
143  _last_region_index = 0;
144  }
145  else if (sL <= 0.0 && sm > 0.0)
146  {
147  FL[THMGasMix3D::SPECIES] = sm * xiL * rhoLs * A_flow;
148  FL[THMGasMix3D::MASS] = sm * rhoLs * A_flow;
149  FL[THMGasMix3D::MOM_NORM] = (sm * rhounLs + ps) * A_flow;
150  FL[THMGasMix3D::MOM_TAN1] = rhounLs * ut1L * A_flow;
151  FL[THMGasMix3D::MOM_TAN2] = rhounLs * ut2L * A_flow;
152  FL[THMGasMix3D::ENERGY] = sm * (rhoELs + ps) * A_flow;
153 
154  _last_region_index = 1;
155  }
156  else if (sm <= 0.0 && sR >= 0.0)
157  {
158  FL[THMGasMix3D::SPECIES] = sm * xiR * rhoRs * A_flow;
159  FL[THMGasMix3D::MASS] = sm * rhoRs * A_flow;
160  FL[THMGasMix3D::MOM_NORM] = (sm * rhounRs + ps) * A_flow;
161  FL[THMGasMix3D::MOM_TAN1] = rhounRs * ut1R * A_flow;
162  FL[THMGasMix3D::MOM_TAN2] = rhounRs * ut2R * A_flow;
163  FL[THMGasMix3D::ENERGY] = sm * (rhoERs + ps) * A_flow;
164 
165  _last_region_index = 2;
166  }
167  else if (sR < 0.0)
168  {
169  FL[THMGasMix3D::SPECIES] = unR * xiR * rhoR * A_flow;
170  FL[THMGasMix3D::MASS] = unR * rhoR * A_flow;
171  FL[THMGasMix3D::MOM_NORM] = (unR * rhoR * unR + pR) * A_flow;
172  FL[THMGasMix3D::MOM_TAN1] = rhoR * unR * ut1R * A_flow;
173  FL[THMGasMix3D::MOM_TAN2] = rhoR * unR * ut2R * A_flow;
174  FL[THMGasMix3D::ENERGY] = unR * (rhoER + pR) * A_flow;
175 
176  _last_region_index = 3;
177  }
178  else
179  std::fill(FL.begin(), FL.end(), getNaN());
180 
181  FR = FL;
182 
183  const ADReal A_wall_L = AL - A_flow;
184  FL[THMGasMix3D::MOM_NORM] += pL * A_wall_L;
185 
186  const ADReal A_wall_R = AR - A_flow;
187  FR[THMGasMix3D::MOM_NORM] += pR * A_wall_R;
188 }
189 
190 ADReal
191 NumericalFluxGasMixHLLC::computeFlowArea(const std::vector<ADReal> & UL,
192  const std::vector<ADReal> & UR) const
193 {
194  return std::min(UL[THMGasMix1D::AREA], UR[THMGasMix1D::AREA]);
195 }
Base class for fluid properties of vapor mixtures.
registerMooseObject("ThermalHydraulicsApp", NumericalFluxGasMixHLLC)
Base class for computing numerical fluxes for FlowModelGasMix.
Real getNaN() const
Throws an error or returns a NaN with or without a warning, with a default message.
Definition: NaNInterface.h:46
virtual void calcFlux(const std::vector< ADReal > &UL, const std::vector< ADReal > &UR, const RealVectorValue &nLR, const RealVectorValue &t1, const RealVectorValue &t2, std::vector< ADReal > &FL, std::vector< ADReal > &FR) const override
Calculates the 3D flux vectors given "left" and "right" states.
DualNumber< Real, DNDerivativeType, true > ADReal
unsigned int _last_region_index
Index describing the region last entered, which is useful for testing and debugging.
void addRequiredParam(const std::string &name, const std::string &doc_string)
virtual ADReal computeFlowArea(const std::vector< ADReal > &UL, const std::vector< ADReal > &UR) const
Computes the flow area that is used in the numerical flux.
Computes the numerical flux for FlowModelGasMix using the HLLC approximate Riemann solver...
static InputParameters validParams()
NumericalFluxGasMixHLLC(const InputParameters &parameters)
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
Definition: NaNInterface.C:15
static const unsigned int N_FLUX_INPUTS
Number of numerical flux function inputs.
const VaporMixtureFluidProperties & _fp
fluid properties user object
Interface class for producing errors, warnings, or just quiet NaNs.
Definition: NaNInterface.h:22
static const std::string cL
Definition: NS.h:111
static const unsigned int N_FLUX_OUTPUTS
Number of numerical flux function outputs for 3D.
static InputParameters validParams()