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