LCOV - code coverage report
Current view: top level - src/functions - SaturationDensityFunction.C (source / functions) Hit Total Coverage
Test: idaholab/moose fluid_properties: #31405 (292dce) with base fef103 Lines: 22 23 95.7 %
Date: 2025-09-04 07:53:14 Functions: 4 4 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 "SaturationDensityFunction.h"
      11             : #include "TwoPhaseFluidProperties.h"
      12             : #include "SinglePhaseFluidProperties.h"
      13             : 
      14             : registerMooseObject("FluidPropertiesApp", SaturationDensityFunction);
      15             : 
      16             : InputParameters
      17          82 : SaturationDensityFunction::validParams()
      18             : {
      19          82 :   InputParameters params = Function::validParams();
      20             : 
      21         164 :   params.addRequiredParam<FunctionName>("T", "Temperature function");
      22         164 :   params.addRequiredParam<UserObjectName>("fp_2phase", "2-phase fluid properties");
      23         164 :   params.addRequiredParam<bool>("use_liquid", "Set true to use liquid phase; else use vapor phase");
      24             : 
      25          82 :   params.addClassDescription("Computes saturation density from temperature function");
      26             : 
      27          82 :   return params;
      28           0 : }
      29             : 
      30          44 : SaturationDensityFunction::SaturationDensityFunction(const InputParameters & parameters)
      31             :   : Function(parameters),
      32             :     FunctionInterface(this),
      33             : 
      34          44 :     _T_fn(getFunction("T")),
      35         132 :     _use_liquid(getParam<bool>("use_liquid"))
      36             : {
      37          44 : }
      38             : 
      39             : void
      40          44 : SaturationDensityFunction::initialSetup()
      41             : {
      42          44 :   _fp_2phase = &getUserObject<TwoPhaseFluidProperties>("fp_2phase");
      43          44 :   _fp_liquid = &getUserObjectByName<SinglePhaseFluidProperties>(_fp_2phase->getLiquidName());
      44          44 :   _fp_vapor = &getUserObjectByName<SinglePhaseFluidProperties>(_fp_2phase->getVaporName());
      45          44 : }
      46             : 
      47             : Real
      48          28 : SaturationDensityFunction::value(Real t, const Point & point) const
      49             : {
      50          28 :   const Real T = _T_fn.value(t, point);
      51          28 :   const Real p = _fp_2phase->p_sat(T);
      52             : 
      53          28 :   if (_use_liquid)
      54          14 :     return _fp_liquid->rho_from_p_T(p, T);
      55             :   else
      56          14 :     return _fp_vapor->rho_from_p_T(p, T);
      57             : }

Generated by: LCOV version 1.14