LCOV - code coverage report
Current view: top level - src/materials - PorousFlowSingleComponentFluid.C (source / functions) Hit Total Coverage
Test: porous_flow Test Coverage Lines: 112 112 100.0 %
Date: 2017-11-21 14:47:27 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /****************************************************************/
       2             : /* MOOSE - Multiphysics Object Oriented Simulation Environment  */
       3             : /*                                                              */
       4             : /*          All contents are licensed under LGPL V2.1           */
       5             : /*             See LICENSE for full restrictions                */
       6             : /****************************************************************/
       7             : 
       8             : #include "PorousFlowSingleComponentFluid.h"
       9             : 
      10             : template <>
      11             : InputParameters
      12         351 : validParams<PorousFlowSingleComponentFluid>()
      13             : {
      14         351 :   InputParameters params = validParams<PorousFlowFluidPropertiesBase>();
      15        1053 :   params.addParam<bool>(
      16         351 :       "compute_density_and_viscosity", true, "Compute the fluid density and viscosity");
      17        1053 :   params.addParam<bool>("compute_internal_energy", true, "Compute the fluid internal energy");
      18        1053 :   params.addParam<bool>("compute_enthalpy", true, "Compute the fluid enthalpy");
      19        1053 :   params.addRequiredParam<UserObjectName>("fp", "The name of the user object for fluid properties");
      20         702 :   params.addClassDescription(
      21         351 :       "This Material calculates fluid properties at the quadpoints for a single component fluid");
      22         351 :   return params;
      23             : }
      24             : 
      25        1053 : PorousFlowSingleComponentFluid::PorousFlowSingleComponentFluid(const InputParameters & parameters)
      26             :   : PorousFlowFluidPropertiesBase(parameters),
      27        3159 :     _compute_rho_mu(getParam<bool>("compute_density_and_viscosity")),
      28        3159 :     _compute_internal_energy(getParam<bool>("compute_internal_energy")),
      29        3159 :     _compute_enthalpy(getParam<bool>("compute_enthalpy")),
      30        1053 :     _density(_compute_rho_mu
      31        1053 :                  ? (_nodal_material
      32        3159 :                         ? &declareProperty<Real>("PorousFlow_fluid_phase_density_nodal" + _phase)
      33        1869 :                         : &declareProperty<Real>("PorousFlow_fluid_phase_density_qp" + _phase))
      34             :                  : nullptr),
      35             :     _ddensity_dp(
      36        1053 :         _compute_rho_mu
      37        1053 :             ? (_nodal_material
      38        2106 :                    ? &declarePropertyDerivative<Real>(
      39        3633 :                          "PorousFlow_fluid_phase_density_nodal" + _phase, _pressure_variable_name)
      40        1869 :                    : &declarePropertyDerivative<Real>("PorousFlow_fluid_phase_density_qp" + _phase,
      41        2685 :                                                       _pressure_variable_name))
      42             :             : nullptr),
      43             :     _ddensity_dT(
      44        1053 :         _compute_rho_mu
      45        1053 :             ? (_nodal_material
      46        4449 :                    ? &declarePropertyDerivative<Real>("PorousFlow_fluid_phase_density_nodal" +
      47             :                                                           _phase,
      48        3633 :                                                       _temperature_variable_name)
      49        1869 :                    : &declarePropertyDerivative<Real>("PorousFlow_fluid_phase_density_qp" + _phase,
      50        2685 :                                                       _temperature_variable_name))
      51             :             : nullptr),
      52             : 
      53        1053 :     _viscosity(_compute_rho_mu
      54        1053 :                    ? (_nodal_material
      55        3159 :                           ? &declareProperty<Real>("PorousFlow_viscosity_nodal" + _phase)
      56        1869 :                           : &declareProperty<Real>("PorousFlow_viscosity_qp" + _phase))
      57             :                    : nullptr),
      58        1053 :     _dviscosity_dp(_compute_rho_mu
      59        1053 :                        ? (_nodal_material
      60        2106 :                               ? &declarePropertyDerivative<Real>(
      61        3633 :                                     "PorousFlow_viscosity_nodal" + _phase, _pressure_variable_name)
      62        1869 :                               : &declarePropertyDerivative<Real>("PorousFlow_viscosity_qp" + _phase,
      63        2685 :                                                                  _pressure_variable_name))
      64             :                        : nullptr),
      65             :     _dviscosity_dT(
      66        1053 :         _compute_rho_mu
      67        1053 :             ? (_nodal_material
      68        4449 :                    ? &declarePropertyDerivative<Real>("PorousFlow_viscosity_nodal" + _phase,
      69        3633 :                                                       _temperature_variable_name)
      70        1869 :                    : &declarePropertyDerivative<Real>("PorousFlow_viscosity_qp" + _phase,
      71        2685 :                                                       _temperature_variable_name))
      72             :             : nullptr),
      73             : 
      74             :     _internal_energy(
      75        1053 :         _compute_internal_energy
      76        1053 :             ? (_nodal_material
      77        2991 :                    ? &declareProperty<Real>("PorousFlow_fluid_phase_internal_energy_nodal" + _phase)
      78        1773 :                    : &declareProperty<Real>("PorousFlow_fluid_phase_internal_energy_qp" + _phase))
      79             :             : nullptr),
      80        1053 :     _dinternal_energy_dp(_compute_internal_energy
      81        1053 :                              ? (_nodal_material
      82        1938 :                                     ? &declarePropertyDerivative<Real>(
      83        2271 :                                           "PorousFlow_fluid_phase_internal_energy_nodal" + _phase,
      84        3489 :                                           _pressure_variable_name)
      85             :                                     : &declarePropertyDerivative<Real>(
      86        1773 :                                           "PorousFlow_fluid_phase_internal_energy_qp" + _phase,
      87        2493 :                                           _pressure_variable_name))
      88             :                              : nullptr),
      89        1053 :     _dinternal_energy_dT(_compute_internal_energy
      90        1053 :                              ? (_nodal_material
      91        1938 :                                     ? &declarePropertyDerivative<Real>(
      92        2271 :                                           "PorousFlow_fluid_phase_internal_energy_nodal" + _phase,
      93        3489 :                                           _temperature_variable_name)
      94             :                                     : &declarePropertyDerivative<Real>(
      95        1773 :                                           "PorousFlow_fluid_phase_internal_energy_qp" + _phase,
      96        2493 :                                           _temperature_variable_name))
      97             :                              : nullptr),
      98             : 
      99        1053 :     _enthalpy(_compute_enthalpy
     100        1053 :                   ? (_nodal_material
     101        2985 :                          ? &declareProperty<Real>("PorousFlow_fluid_phase_enthalpy_nodal" + _phase)
     102        1773 :                          : &declareProperty<Real>("PorousFlow_fluid_phase_enthalpy_qp" + _phase))
     103             :                   : nullptr),
     104             :     _denthalpy_dp(
     105        1053 :         _compute_enthalpy
     106        1053 :             ? (_nodal_material
     107        1932 :                    ? &declarePropertyDerivative<Real>(
     108        3477 :                          "PorousFlow_fluid_phase_enthalpy_nodal" + _phase, _pressure_variable_name)
     109        1773 :                    : &declarePropertyDerivative<Real>("PorousFlow_fluid_phase_enthalpy_qp" + _phase,
     110        2493 :                                                       _pressure_variable_name))
     111             :             : nullptr),
     112             :     _denthalpy_dT(
     113        1053 :         _compute_enthalpy
     114        1053 :             ? (_nodal_material
     115        4197 :                    ? &declarePropertyDerivative<Real>("PorousFlow_fluid_phase_enthalpy_nodal" +
     116             :                                                           _phase,
     117        3477 :                                                       _temperature_variable_name)
     118        1773 :                    : &declarePropertyDerivative<Real>("PorousFlow_fluid_phase_enthalpy_qp" + _phase,
     119        2493 :                                                       _temperature_variable_name))
     120             :             : nullptr),
     121             : 
     122       24075 :     _fp(getUserObject<SinglePhaseFluidPropertiesPT>("fp"))
     123             : {
     124        1053 : }
     125             : 
     126             : void
     127      156736 : PorousFlowSingleComponentFluid::initQpStatefulProperties()
     128             : {
     129      156736 :   if (_compute_rho_mu)
     130      626944 :     (*_density)[_qp] = _fp.rho(_porepressure[_qp][_phase_num], _temperature[_qp] + _t_c2k);
     131      156736 :   if (_compute_internal_energy)
     132      379744 :     (*_internal_energy)[_qp] = _fp.e(_porepressure[_qp][_phase_num], _temperature[_qp] + _t_c2k);
     133      156736 :   if (_compute_enthalpy)
     134      379680 :     (*_enthalpy)[_qp] = _fp.h(_porepressure[_qp][_phase_num], _temperature[_qp] + _t_c2k);
     135      156736 : }
     136             : 
     137             : void
     138     8307794 : PorousFlowSingleComponentFluid::computeQpProperties()
     139             : {
     140    16615588 :   const Real Tk = _temperature[_qp] + _t_c2k;
     141             : 
     142     8307794 :   if (_compute_rho_mu)
     143             :   {
     144             :     // Density and derivatives wrt pressure and temperature at the qps
     145             :     Real rho, drho_dp, drho_dT;
     146    16615588 :     _fp.rho_dpT(_porepressure[_qp][_phase_num], Tk, rho, drho_dp, drho_dT);
     147    16615588 :     (*_density)[_qp] = rho;
     148    16615588 :     (*_ddensity_dp)[_qp] = drho_dp;
     149    16615588 :     (*_ddensity_dT)[_qp] = drho_dT;
     150             : 
     151             :     // Viscosity and derivatives wrt pressure and temperature at the nodes.
     152             :     // Note that dmu_dp = dmu_drho * drho_dp
     153             :     Real mu, dmu_drho, dmu_dT;
     154     8307794 :     _fp.mu_drhoT_from_rho_T(rho, Tk, drho_dT, mu, dmu_drho, dmu_dT);
     155    16615588 :     (*_viscosity)[_qp] = mu;
     156    16615588 :     (*_dviscosity_dp)[_qp] = dmu_drho * drho_dp;
     157    16615588 :     (*_dviscosity_dT)[_qp] = dmu_dT;
     158             :   }
     159             : 
     160             :   // Internal energy and derivatives wrt pressure and temperature at the qps
     161     8307794 :   if (_compute_internal_energy)
     162             :   {
     163             :     Real e, de_dp, de_dT;
     164     7879036 :     _fp.e_dpT(_porepressure[_qp][_phase_num], Tk, e, de_dp, de_dT);
     165     7879036 :     (*_internal_energy)[_qp] = e;
     166     7879036 :     (*_dinternal_energy_dp)[_qp] = de_dp;
     167     7879036 :     (*_dinternal_energy_dT)[_qp] = de_dT;
     168             :   }
     169             : 
     170             :   // Enthalpy and derivatives wrt pressure and temperature at the qps
     171     8307794 :   if (_compute_enthalpy)
     172             :   {
     173             :     Real h, dh_dp, dh_dT;
     174     7877596 :     _fp.h_dpT(_porepressure[_qp][_phase_num], Tk, h, dh_dp, dh_dT);
     175     7877596 :     (*_enthalpy)[_qp] = h;
     176     7877596 :     (*_denthalpy_dp)[_qp] = dh_dp;
     177     7877596 :     (*_denthalpy_dT)[_qp] = dh_dT;
     178             :   }
     179     8310293 : }

Generated by: LCOV version 1.11