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 "ADBoundaryFlux3EqnGhostVelocityTemperature.h" 11 : #include "THMIndicesVACE.h" 12 : #include "SinglePhaseFluidProperties.h" 13 : #include "Numerics.h" 14 : 15 : registerMooseObject("ThermalHydraulicsApp", ADBoundaryFlux3EqnGhostVelocityTemperature); 16 : 17 : InputParameters 18 398 : ADBoundaryFlux3EqnGhostVelocityTemperature::validParams() 19 : { 20 398 : InputParameters params = ADBoundaryFlux3EqnGhostBase::validParams(); 21 : 22 398 : params.addClassDescription( 23 : "Computes a boundary flux from a specified velocity and temperature for the 1-D, " 24 : "1-phase, variable-area Euler equations using a ghost cell"); 25 : 26 796 : params.addRequiredParam<Real>("vel", "Specified velocity"); 27 796 : params.addRequiredParam<Real>("T", "Specified temperature"); 28 796 : params.addParam<bool>("reversible", true, "True for reversible, false for pure inlet"); 29 : 30 796 : params.addRequiredParam<UserObjectName>("fluid_properties", 31 : "Name of single-phase fluid properties user object"); 32 : 33 796 : params.declareControllable("vel T"); 34 398 : return params; 35 0 : } 36 : 37 221 : ADBoundaryFlux3EqnGhostVelocityTemperature::ADBoundaryFlux3EqnGhostVelocityTemperature( 38 221 : const InputParameters & parameters) 39 : : ADBoundaryFlux3EqnGhostBase(parameters), 40 : 41 221 : _vel(getParam<Real>("vel")), 42 442 : _T(getParam<Real>("T")), 43 442 : _reversible(getParam<bool>("reversible")), 44 442 : _fp(getUserObject<SinglePhaseFluidProperties>("fluid_properties")) 45 : { 46 221 : } 47 : 48 : std::vector<ADReal> 49 13052 : ADBoundaryFlux3EqnGhostVelocityTemperature::getGhostCellSolution( 50 : const std::vector<ADReal> & U) const 51 : { 52 13052 : const ADReal rhoA = U[THMVACE1D::RHOA]; 53 13052 : const ADReal rhouA = U[THMVACE1D::RHOUA]; 54 13052 : const ADReal rhoEA = U[THMVACE1D::RHOEA]; 55 13052 : const ADReal A = U[THMVACE1D::AREA]; 56 : 57 : const ADReal rho = rhoA / A; 58 13052 : std::vector<ADReal> U_ghost(THMVACE1D::N_FLUX_INPUTS); 59 13052 : if (!_reversible || THM::isInlet(_vel, _normal)) 60 : { 61 : // Pressure is the only quantity coming from the interior 62 : const ADReal vel = rhouA / rhoA; 63 : const ADReal E = rhoEA / rhoA; 64 12399 : const ADReal e = E - 0.5 * vel * vel; 65 24798 : const ADReal p = _fp.p_from_v_e(1.0 / rho, e); 66 : 67 12399 : const ADReal rho_b = _fp.rho_from_p_T(p, _T); 68 12399 : const ADReal rhouA_b = rho_b * _vel * A; 69 12399 : const ADReal e_b = _fp.e_from_p_rho(p, rho_b); 70 12399 : const ADReal E_b = e_b + 0.5 * _vel * _vel; 71 : 72 12399 : U_ghost[THMVACE1D::RHOA] = rho_b * A; 73 12399 : U_ghost[THMVACE1D::RHOUA] = rhouA_b; 74 12399 : U_ghost[THMVACE1D::RHOEA] = rho_b * E_b * A; 75 12399 : U_ghost[THMVACE1D::AREA] = A; 76 : } 77 : else 78 : { 79 653 : U_ghost[THMVACE1D::RHOA] = rhoA; 80 1306 : U_ghost[THMVACE1D::RHOUA] = rhoA * _vel; 81 653 : U_ghost[THMVACE1D::RHOEA] = rhoEA; 82 653 : U_ghost[THMVACE1D::AREA] = A; 83 : } 84 : 85 13052 : return U_ghost; 86 : }