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 "ADBoundaryFlux3EqnGhostDensityVelocity.h" 11 : #include "SinglePhaseFluidProperties.h" 12 : #include "Numerics.h" 13 : #include "THMIndicesVACE.h" 14 : 15 : registerMooseObject("ThermalHydraulicsApp", ADBoundaryFlux3EqnGhostDensityVelocity); 16 : 17 : InputParameters 18 479 : ADBoundaryFlux3EqnGhostDensityVelocity::validParams() 19 : { 20 479 : InputParameters params = ADBoundaryFlux3EqnGhostBase::validParams(); 21 : 22 479 : params.addClassDescription("Computes boundary flux from density and velocity for the 3-equation " 23 : "model using a ghost cell approach."); 24 : 25 958 : params.addRequiredParam<Real>("rho", "Density"); 26 958 : params.addRequiredParam<Real>("vel", "Velocity"); 27 958 : params.addParam<bool>("reversible", true, "True for reversible, false for pure inlet"); 28 : 29 958 : params.addRequiredParam<UserObjectName>("fluid_properties", 30 : "1-phase fluid properties user object name"); 31 : 32 958 : params.declareControllable("rho vel"); 33 : 34 479 : return params; 35 0 : } 36 : 37 260 : ADBoundaryFlux3EqnGhostDensityVelocity::ADBoundaryFlux3EqnGhostDensityVelocity( 38 260 : const InputParameters & parameters) 39 : : ADBoundaryFlux3EqnGhostBase(parameters), 40 : 41 260 : _rho(getParam<Real>("rho")), 42 520 : _vel(getParam<Real>("vel")), 43 520 : _reversible(getParam<bool>("reversible")), 44 : 45 520 : _fp(getUserObjectByName<SinglePhaseFluidProperties>( 46 260 : getParam<UserObjectName>("fluid_properties"))) 47 : { 48 260 : } 49 : 50 : std::vector<ADReal> 51 20514 : ADBoundaryFlux3EqnGhostDensityVelocity::getGhostCellSolution( 52 : const std::vector<ADReal> & U_interior) const 53 : { 54 20514 : const ADReal rhoA = U_interior[THMVACE1D::RHOA]; 55 20514 : const ADReal rhouA = U_interior[THMVACE1D::RHOUA]; 56 20514 : const ADReal rhoEA = U_interior[THMVACE1D::RHOEA]; 57 20514 : const ADReal A = U_interior[THMVACE1D::AREA]; 58 : 59 20514 : std::vector<ADReal> U_ghost(THMVACE1D::N_FLUX_INPUTS); 60 20514 : if (!_reversible || THM::isInlet(_vel, _normal)) 61 : { 62 : // Get the pressure from the interior solution 63 : 64 : const ADReal rho = rhoA / A; 65 : const ADReal vel = rhouA / rhoA; 66 : const ADReal E = rhoEA / rhoA; 67 20514 : const ADReal e = E - 0.5 * vel * vel; 68 41028 : const ADReal p = _fp.p_from_v_e(1.0 / rho, e); 69 : 70 : // Compute remaining boundary quantities 71 : 72 20514 : const ADReal e_b = _fp.e_from_p_rho(p, _rho); 73 20514 : const ADReal E_b = e_b + 0.5 * _vel * _vel; 74 : 75 : // compute ghost solution 76 41028 : U_ghost[THMVACE1D::RHOA] = _rho * A; 77 41028 : U_ghost[THMVACE1D::RHOUA] = _rho * _vel * A; 78 41028 : U_ghost[THMVACE1D::RHOEA] = _rho * E_b * A; 79 20514 : U_ghost[THMVACE1D::AREA] = A; 80 : } 81 : else 82 : { 83 0 : U_ghost[THMVACE1D::RHOA] = rhoA; 84 0 : U_ghost[THMVACE1D::RHOUA] = rhoA * _vel; 85 0 : U_ghost[THMVACE1D::RHOEA] = rhoEA; 86 0 : U_ghost[THMVACE1D::AREA] = A; 87 : } 88 : 89 20514 : return U_ghost; 90 : }