LCOV - code coverage report
Current view: top level - src/ics - PorousFlowFluidPropertyIC.C (source / functions) Hit Total Coverage
Test: idaholab/moose porous_flow: #31405 (292dce) with base fef103 Lines: 32 32 100.0 %
Date: 2025-09-04 07:55:56 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 "PorousFlowFluidPropertyIC.h"
      11             : #include "SinglePhaseFluidProperties.h"
      12             : 
      13             : registerMooseObject("PorousFlowApp", PorousFlowFluidPropertyIC);
      14             : 
      15             : InputParameters
      16         369 : PorousFlowFluidPropertyIC::validParams()
      17             : {
      18         369 :   InputParameters params = InitialCondition::validParams();
      19         738 :   params.addRequiredCoupledVar("porepressure", "Fluid porepressure");
      20         738 :   params.addRequiredCoupledVar("temperature", "Fluid temperature");
      21         738 :   MooseEnum unit_choice("Kelvin=0 Celsius=1", "Kelvin");
      22         738 :   params.addParam<MooseEnum>(
      23             :       "temperature_unit", unit_choice, "The unit of the temperature variable");
      24         738 :   params.addRequiredParam<UserObjectName>("fp", "The name of the user object for the fluid");
      25         738 :   MooseEnum property_enum("enthalpy internal_energy density");
      26         738 :   params.addRequiredParam<MooseEnum>(
      27             :       "property", property_enum, "The fluid property that this initial condition is to calculate");
      28         369 :   params.addClassDescription("An initial condition to calculate one fluid property (such as "
      29             :                              "enthalpy) from pressure and temperature");
      30         369 :   return params;
      31         369 : }
      32             : 
      33         198 : PorousFlowFluidPropertyIC::PorousFlowFluidPropertyIC(const InputParameters & parameters)
      34             :   : InitialCondition(parameters),
      35         198 :     _porepressure(coupledValue("porepressure")),
      36         198 :     _temperature(coupledValue("temperature")),
      37         396 :     _property_enum(getParam<MooseEnum>("property").getEnum<PropertyEnum>()),
      38         198 :     _fp(getUserObject<SinglePhaseFluidProperties>("fp")),
      39         726 :     _T_c2k(getParam<MooseEnum>("temperature_unit") == 0 ? 0.0 : 273.15)
      40             : {
      41         198 : }
      42             : 
      43             : Real
      44        1638 : PorousFlowFluidPropertyIC::value(const Point & /*p*/)
      45             : {
      46             :   // The FluidProperties userobject uses temperature in K
      47        1638 :   const Real Tk = _temperature[_qp] + _T_c2k;
      48             : 
      49             :   // The fluid property
      50             :   Real property = 0.0;
      51             : 
      52        1638 :   switch (_property_enum)
      53             :   {
      54        1494 :     case PropertyEnum::ENTHALPY:
      55        1494 :       property = _fp.h_from_p_T(_porepressure[_qp], Tk);
      56        1494 :       break;
      57             : 
      58          72 :     case PropertyEnum::INTERNAL_ENERGY:
      59          72 :       property = _fp.e_from_p_T(_porepressure[_qp], Tk);
      60          72 :       break;
      61             : 
      62          72 :     case PropertyEnum::DENSITY:
      63          72 :       property = _fp.rho_from_p_T(_porepressure[_qp], Tk);
      64          72 :       break;
      65             :   }
      66             : 
      67        1638 :   return property;
      68             : }

Generated by: LCOV version 1.14