LCOV - code coverage report
Current view: top level - src/materials - PorousFlowFluidPropertiesBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose porous_flow: #33359 (04c914) with base 7b3324 Lines: 109 111 98.2 %
Date: 2026-07-16 14:32:57 Functions: 4 6 66.7 %
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 "PorousFlowFluidPropertiesBase.h"
      11             : 
      12             : template <bool is_ad>
      13             : InputParameters
      14       27340 : PorousFlowFluidPropertiesBaseTempl<is_ad>::validParams()
      15             : {
      16       27340 :   InputParameters params = PorousFlowMaterialBase::validParams();
      17       54680 :   MooseEnum unit_choice("Kelvin=0 Celsius=1", "Kelvin");
      18       54680 :   params.addParam<MooseEnum>(
      19             :       "temperature_unit", unit_choice, "The unit of the temperature variable");
      20       54680 :   MooseEnum p_unit_choice("Pa MPa", "Pa");
      21       54680 :   params.addParam<MooseEnum>("pressure_unit",
      22             :                              p_unit_choice,
      23             :                              "The unit of the pressure variable used everywhere in the input file "
      24             :                              "except for in the FluidProperties-module objects");
      25       54680 :   MooseEnum time_unit_choice("seconds hours days years", "seconds");
      26       54680 :   params.addParam<MooseEnum>("time_unit",
      27             :                              time_unit_choice,
      28             :                              "The unit of time used everywhere in the input file except for in the "
      29             :                              "FluidProperties-module objects");
      30       54680 :   params.addParam<bool>(
      31       54680 :       "compute_density_and_viscosity", true, "Compute the fluid density and viscosity");
      32       54680 :   params.addParam<bool>("compute_internal_energy", true, "Compute the fluid internal energy");
      33       54680 :   params.addParam<bool>("compute_enthalpy", true, "Compute the fluid enthalpy");
      34       54680 :   params.addPrivateParam<std::string>("pf_material_type", "fluid_properties");
      35       27340 :   params.addPrivateParam<bool>("is_ad", is_ad);
      36       27340 :   params.addClassDescription("Base class for PorousFlow fluid materials");
      37       27340 :   return params;
      38       27340 : }
      39             : 
      40             : template <bool is_ad>
      41       21195 : PorousFlowFluidPropertiesBaseTempl<is_ad>::PorousFlowFluidPropertiesBaseTempl(
      42             :     const InputParameters & parameters)
      43             :   : PorousFlowMaterialBase(parameters),
      44       21195 :     _porepressure(
      45       21195 :         _nodal_material
      46       10923 :             ? getGenericMaterialProperty<std::vector<Real>, is_ad>("PorousFlow_porepressure_nodal")
      47       31467 :             : getGenericMaterialProperty<std::vector<Real>, is_ad>("PorousFlow_porepressure_qp")),
      48       42390 :     _temperature(_nodal_material
      49       21195 :                      ? getGenericMaterialProperty<Real, is_ad>("PorousFlow_temperature_nodal")
      50       31467 :                      : getGenericMaterialProperty<Real, is_ad>("PorousFlow_temperature_qp")),
      51       43134 :     _t_c2k(getParam<MooseEnum>("temperature_unit") == 0 ? 0.0 : 273.15),
      52       21195 :     _R(8.3144598),
      53       21195 :     _p_unit(
      54       21195 :         this->template getParam<MooseEnum>("pressure_unit").template getEnum<PressureUnitEnum>()),
      55       21195 :     _pressure_to_Pascals(_p_unit == PressureUnitEnum::Pa ? 1.0 : 1.0E6),
      56       42390 :     _time_unit(this->template getParam<MooseEnum>("time_unit").template getEnum<TimeUnitEnum>()),
      57       21195 :     _time_to_seconds(_time_unit == TimeUnitEnum::seconds ? 1.0
      58         360 :                      : _time_unit == TimeUnitEnum::hours ? 3600.0
      59         330 :                      : _time_unit == TimeUnitEnum::days  ? 3600.0 * 24
      60             :                                                          : 3600 * 24 * 365.25),
      61       42390 :     _compute_rho_mu(this->template getParam<bool>("compute_density_and_viscosity")),
      62       42390 :     _compute_internal_energy(this->template getParam<bool>("compute_internal_energy")),
      63       42390 :     _compute_enthalpy(this->template getParam<bool>("compute_enthalpy")),
      64       42390 :     _density(_compute_rho_mu
      65       21195 :                  ? (_nodal_material ? &this->template declareGenericProperty<Real, is_ad>(
      66       10833 :                                           "PorousFlow_fluid_phase_density_nodal" + _phase)
      67       31467 :                                     : &this->template declareGenericProperty<Real, is_ad>(
      68       10272 :                                           "PorousFlow_fluid_phase_density_qp" + _phase))
      69             :                  : nullptr),
      70       21195 :     _ddensity_dp(
      71       20541 :         (_compute_rho_mu && !is_ad)
      72       20541 :             ? (_nodal_material
      73       62658 :                    ? &this->template declarePropertyDerivative<Real>(
      74       10833 :                          "PorousFlow_fluid_phase_density_nodal" + _phase, _pressure_variable_name)
      75       59013 :                    : &this->template declarePropertyDerivative<Real>(
      76        9618 :                          "PorousFlow_fluid_phase_density_qp" + _phase, _pressure_variable_name))
      77             :             : nullptr),
      78       41736 :     _ddensity_dT((_compute_rho_mu && !is_ad)
      79       62748 :                      ? (_nodal_material ? &this->template declarePropertyDerivative<Real>(
      80       10833 :                                               "PorousFlow_fluid_phase_density_nodal" + _phase,
      81             :                                               _temperature_variable_name)
      82       59013 :                                         : &this->template declarePropertyDerivative<Real>(
      83        9618 :                                               "PorousFlow_fluid_phase_density_qp" + _phase,
      84             :                                               _temperature_variable_name))
      85             :                      : nullptr),
      86             : 
      87       42390 :     _viscosity(_compute_rho_mu
      88       21195 :                    ? (_nodal_material ? &this->template declareGenericProperty<Real, is_ad>(
      89       10833 :                                             "PorousFlow_viscosity_nodal" + _phase)
      90       31467 :                                       : &this->template declareGenericProperty<Real, is_ad>(
      91       10272 :                                             "PorousFlow_viscosity_qp" + _phase))
      92             :                    : nullptr),
      93       41736 :     _dviscosity_dp((_compute_rho_mu && !is_ad)
      94       20541 :                        ? (_nodal_material
      95       62658 :                               ? &this->template declarePropertyDerivative<Real>(
      96       10833 :                                     "PorousFlow_viscosity_nodal" + _phase, _pressure_variable_name)
      97       59013 :                               : &this->template declarePropertyDerivative<Real>(
      98        9618 :                                     "PorousFlow_viscosity_qp" + _phase, _pressure_variable_name))
      99             :                        : nullptr),
     100       21195 :     _dviscosity_dT(
     101       20541 :         (_compute_rho_mu && !is_ad)
     102       20541 :             ? (_nodal_material
     103       62658 :                    ? &this->template declarePropertyDerivative<Real>(
     104       10833 :                          "PorousFlow_viscosity_nodal" + _phase, _temperature_variable_name)
     105       59013 :                    : &this->template declarePropertyDerivative<Real>(
     106        9618 :                          "PorousFlow_viscosity_qp" + _phase, _temperature_variable_name))
     107             :             : nullptr),
     108             : 
     109       42390 :     _internal_energy(_compute_internal_energy
     110       21195 :                          ? (_nodal_material
     111       17367 :                                 ? &this->template declareGenericProperty<Real, is_ad>(
     112        9651 :                                       "PorousFlow_fluid_phase_internal_energy_nodal" + _phase)
     113       28911 :                                 : &this->template declareGenericProperty<Real, is_ad>(
     114        7716 :                                       "PorousFlow_fluid_phase_internal_energy_qp" + _phase))
     115             :                          : nullptr),
     116       41736 :     _dinternal_energy_dp((_compute_internal_energy && !is_ad)
     117       20541 :                              ? (_nodal_material
     118       56556 :                                     ? &this->template declarePropertyDerivative<Real>(
     119        9651 :                                           "PorousFlow_fluid_phase_internal_energy_nodal" + _phase,
     120             :                                           _pressure_variable_name)
     121       48789 :                                     : &this->template declarePropertyDerivative<Real>(
     122        7062 :                                           "PorousFlow_fluid_phase_internal_energy_qp" + _phase,
     123             :                                           _pressure_variable_name))
     124             :                              : nullptr),
     125       41736 :     _dinternal_energy_dT((_compute_internal_energy && !is_ad)
     126       20541 :                              ? (_nodal_material
     127       56556 :                                     ? &this->template declarePropertyDerivative<Real>(
     128        9651 :                                           "PorousFlow_fluid_phase_internal_energy_nodal" + _phase,
     129             :                                           _temperature_variable_name)
     130       48789 :                                     : &this->template declarePropertyDerivative<Real>(
     131        7062 :                                           "PorousFlow_fluid_phase_internal_energy_qp" + _phase,
     132             :                                           _temperature_variable_name))
     133             :                              : nullptr),
     134             : 
     135       42390 :     _enthalpy(_compute_enthalpy
     136       21195 :                   ? (_nodal_material ? &this->template declareGenericProperty<Real, is_ad>(
     137        9711 :                                            "PorousFlow_fluid_phase_enthalpy_nodal" + _phase)
     138       29196 :                                      : &this->template declareGenericProperty<Real, is_ad>(
     139        8001 :                                            "PorousFlow_fluid_phase_enthalpy_qp" + _phase))
     140             :                   : nullptr),
     141       21195 :     _denthalpy_dp(
     142       20541 :         (_compute_enthalpy && !is_ad)
     143       20541 :             ? (_nodal_material
     144       57021 :                    ? &this->template declarePropertyDerivative<Real>(
     145        9711 :                          "PorousFlow_fluid_phase_enthalpy_nodal" + _phase, _pressure_variable_name)
     146       49929 :                    : &this->template declarePropertyDerivative<Real>(
     147        7347 :                          "PorousFlow_fluid_phase_enthalpy_qp" + _phase, _pressure_variable_name))
     148             :             : nullptr),
     149       41736 :     _denthalpy_dT((_compute_enthalpy && !is_ad)
     150       60504 :                       ? (_nodal_material ? &this->template declarePropertyDerivative<Real>(
     151        9711 :                                                "PorousFlow_fluid_phase_enthalpy_nodal" + _phase,
     152             :                                                _temperature_variable_name)
     153       49929 :                                          : &this->template declarePropertyDerivative<Real>(
     154        7347 :                                                "PorousFlow_fluid_phase_enthalpy_qp" + _phase,
     155             :                                                _temperature_variable_name))
     156       21195 :                       : nullptr)
     157             : {
     158       21195 : }
     159             : 
     160             : template <bool is_ad>
     161             : void
     162           0 : PorousFlowFluidPropertiesBaseTempl<is_ad>::computeQpProperties()
     163             : {
     164           0 :   mooseError("computeQpProperties() must be overriden in materials derived from "
     165             :              "PorousFlowFluidPropertiesBase");
     166             : }
     167             : 
     168             : template class PorousFlowFluidPropertiesBaseTempl<false>;
     169             : template class PorousFlowFluidPropertiesBaseTempl<true>;

Generated by: LCOV version 1.14