Line data Source code
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 "SlopeReconstructionGasMixMaterial.h" 11 : #include "THMIndicesGasMix.h" 12 : #include "FlowModelGasMixUtils.h" 13 : #include "THMNames.h" 14 : 15 : registerMooseObject("ThermalHydraulicsApp", SlopeReconstructionGasMixMaterial); 16 : 17 : InputParameters 18 85 : SlopeReconstructionGasMixMaterial::validParams() 19 : { 20 85 : InputParameters params = Material::validParams(); 21 85 : params += SlopeReconstruction1DInterface<true>::validParams(); 22 : 23 85 : params.addClassDescription("Computes reconstructed solution values for FlowModelGasMix."); 24 : 25 170 : params.addRequiredCoupledVar("A_elem", "Cross-sectional area, elemental"); 26 170 : params.addRequiredCoupledVar("A_linear", "Cross-sectional area, linear"); 27 170 : params.addRequiredCoupledVar("xirhoA", "Conserved variable xi*rho*A"); 28 170 : params.addRequiredCoupledVar("rhoA", "Conserved variable rho*A"); 29 170 : params.addRequiredCoupledVar("rhouA", "Conserved variable rho*u*A"); 30 170 : params.addRequiredCoupledVar("rhoEA", "Conserved variable rho*E*A"); 31 : 32 170 : params.addRequiredParam<UserObjectName>("fluid_properties", 33 : "The VaporMixtureFluidProperties object"); 34 : 35 85 : return params; 36 0 : } 37 : 38 66 : SlopeReconstructionGasMixMaterial::SlopeReconstructionGasMixMaterial( 39 66 : const InputParameters & parameters) 40 : : Material(parameters), 41 : SlopeReconstruction1DInterface<true>(this), 42 : 43 66 : _A_avg(adCoupledValue("A_elem")), 44 66 : _A_linear(adCoupledValue("A_linear")), 45 66 : _xirhoA_avg(adCoupledValue("xirhoA")), 46 66 : _rhoA_avg(adCoupledValue("rhoA")), 47 66 : _rhouA_avg(adCoupledValue("rhouA")), 48 66 : _rhoEA_avg(adCoupledValue("rhoEA")), 49 : 50 66 : _A_var(getVar("A_elem", 0)), 51 66 : _xirhoA_var(getVar("xirhoA", 0)), 52 66 : _rhoA_var(getVar("rhoA", 0)), 53 66 : _rhouA_var(getVar("rhouA", 0)), 54 66 : _rhoEA_var(getVar("rhoEA", 0)), 55 : 56 66 : _dir(getMaterialProperty<RealVectorValue>(THM::DIRECTION)), 57 : 58 66 : _xirhoA(declareADProperty<Real>(THM::XIRHOA)), 59 66 : _rhoA(declareADProperty<Real>(THM::RHOA)), 60 66 : _rhouA(declareADProperty<Real>(THM::RHOUA)), 61 66 : _rhoEA(declareADProperty<Real>(THM::RHOEA)), 62 : 63 132 : _fp(getUserObject<VaporMixtureFluidProperties>("fluid_properties")) 64 : { 65 66 : _U_vars.resize(THMGasMix1D::N_FLUX_INPUTS); 66 66 : _U_vars[THMGasMix1D::XIRHOA] = _xirhoA_var; 67 66 : _U_vars[THMGasMix1D::RHOA] = _rhoA_var; 68 66 : _U_vars[THMGasMix1D::RHOUA] = _rhouA_var; 69 66 : _U_vars[THMGasMix1D::RHOEA] = _rhoEA_var; 70 66 : _U_vars[THMGasMix1D::AREA] = _A_var; 71 66 : } 72 : 73 : void 74 39550 : SlopeReconstructionGasMixMaterial::computeQpProperties() 75 : { 76 39550 : if (_scheme == None) 77 : { 78 39550 : const auto A_ratio = _A_linear[_qp] / _A_avg[_qp]; 79 79100 : _xirhoA[_qp] = _xirhoA_avg[_qp] * A_ratio; 80 79100 : _rhoA[_qp] = _rhoA_avg[_qp] * A_ratio; 81 79100 : _rhouA[_qp] = _rhouA_avg[_qp] * A_ratio; 82 79100 : _rhoEA[_qp] = _rhoEA_avg[_qp] * A_ratio; 83 : } 84 : else 85 : { 86 : // compute primitive variables from the cell-average solution 87 0 : std::vector<ADReal> U_avg(THMGasMix1D::N_FLUX_INPUTS, 0.0); 88 0 : U_avg[THMGasMix1D::XIRHOA] = _xirhoA_avg[_qp]; 89 0 : U_avg[THMGasMix1D::RHOA] = _rhoA_avg[_qp]; 90 0 : U_avg[THMGasMix1D::RHOUA] = _rhouA_avg[_qp]; 91 0 : U_avg[THMGasMix1D::RHOEA] = _rhoEA_avg[_qp]; 92 0 : U_avg[THMGasMix1D::AREA] = _A_avg[_qp]; 93 0 : auto W = FlowModelGasMixUtils::computePrimitiveSolution<true>(U_avg, _fp); 94 : 95 : // compute and apply slopes to primitive variables 96 0 : const auto slopes = getElementSlopes(_current_elem); 97 0 : const auto delta_x = (_q_point[_qp] - _current_elem->vertex_average()) * _dir[_qp]; 98 0 : for (unsigned int m = 0; m < THMGasMix1D::N_PRIM_VARS; m++) 99 0 : W[m] = W[m] + slopes[m] * delta_x; 100 : 101 : // compute reconstructed conservative variables 102 0 : const auto U = FlowModelGasMixUtils::computeConservativeSolution<true>(W, _A_linear[_qp], _fp); 103 0 : _xirhoA[_qp] = U[THMGasMix1D::XIRHOA]; 104 0 : _rhoA[_qp] = U[THMGasMix1D::RHOA]; 105 0 : _rhouA[_qp] = U[THMGasMix1D::RHOUA]; 106 0 : _rhoEA[_qp] = U[THMGasMix1D::RHOEA]; 107 : } 108 39550 : } 109 : 110 : std::vector<ADReal> 111 0 : SlopeReconstructionGasMixMaterial::computeElementPrimitiveVariables(const Elem * elem) const 112 : { 113 : const auto U = 114 0 : FlowModelGasMixUtils::getElementalSolutionVector<true>(elem, _U_vars, _is_implicit); 115 0 : return FlowModelGasMixUtils::computePrimitiveSolution<true>(U, _fp); 116 : }