LCOV - code coverage report
Current view: top level - src/userobjects - ADBoundaryFlux3EqnGhostMassFlowRateTemperature.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 38 39 97.4 %
Date: 2025-07-30 13:02:48 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14