LCOV - code coverage report
Current view: top level - src/kernels - PorousFlowAdvectiveFlux.C (source / functions) Hit Total Coverage
Test: idaholab/moose porous_flow: #33380 (547b29) with base 8581c3 Lines: 31 36 86.1 %
Date: 2026-07-20 19:40:36 Functions: 7 8 87.5 %
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 "PorousFlowAdvectiveFlux.h"
      11             : 
      12             : registerMooseObject("PorousFlowApp", PorousFlowAdvectiveFlux);
      13             : registerMooseObject("PorousFlowApp", ADPorousFlowAdvectiveFlux);
      14             : 
      15             : template <bool is_ad>
      16             : InputParameters
      17        3595 : PorousFlowAdvectiveFluxTempl<is_ad>::validParams()
      18             : {
      19        3595 :   InputParameters params = PorousFlowDarcyBaseTempl<is_ad>::validParams();
      20        7190 :   params.addParam<unsigned int>(
      21        7190 :       "fluid_component", 0, "The index corresponding to the fluid component for this kernel");
      22        3595 :   params.addClassDescription(
      23             :       "Fully-upwinded advective flux of the component given by fluid_component");
      24        3595 :   return params;
      25           0 : }
      26             : 
      27             : template <bool is_ad>
      28        1913 : PorousFlowAdvectiveFluxTempl<is_ad>::PorousFlowAdvectiveFluxTempl(
      29             :     const InputParameters & parameters)
      30             :   : PorousFlowDarcyBaseTempl<is_ad>(parameters),
      31        1911 :     _mass_fractions(
      32        3822 :         this->template getGenericMaterialProperty<std::vector<std::vector<Real>>, is_ad>(
      33             :             "PorousFlow_mass_frac_nodal")),
      34        1911 :     _dmass_fractions_dvar(
      35             :         is_ad ? nullptr
      36        1904 :               : &this->template getMaterialProperty<std::vector<std::vector<std::vector<Real>>>>(
      37             :                     "dPorousFlow_mass_frac_nodal_dvar")),
      38        3822 :     _relative_permeability(this->template getGenericMaterialProperty<std::vector<Real>, is_ad>(
      39             :         "PorousFlow_relative_permeability_nodal")),
      40        1911 :     _drelative_permeability_dvar(
      41             :         is_ad ? nullptr
      42        1904 :               : &this->template getMaterialProperty<std::vector<std::vector<Real>>>(
      43             :                     "dPorousFlow_relative_permeability_nodal_dvar")),
      44        5735 :     _fluid_component(this->template getParam<unsigned int>("fluid_component"))
      45             : {
      46        1911 :   if (_fluid_component >= _dictator.numComponents())
      47           0 :     this->paramError(
      48             :         "fluid_component",
      49             :         "The Dictator proclaims that the maximum fluid component index in this simulation is ",
      50           0 :         _dictator.numComponents() - 1,
      51             :         " whereas you have used ",
      52           0 :         _fluid_component,
      53             :         ". Remember that indexing starts at 0. The Dictator does not take such mistakes lightly.");
      54        1911 : }
      55             : 
      56             : template <bool is_ad>
      57             : GenericReal<is_ad>
      58    11475715 : PorousFlowAdvectiveFluxTempl<is_ad>::mobility(unsigned nodenum, unsigned phase) const
      59             : {
      60    11475715 :   return _mass_fractions[nodenum][phase][_fluid_component] * _fluid_density_node[nodenum][phase] *
      61    11475887 :          _relative_permeability[nodenum][phase] / _fluid_viscosity[nodenum][phase];
      62             : }
      63             : 
      64             : template <bool is_ad>
      65             : Real
      66     6354872 : PorousFlowAdvectiveFluxTempl<is_ad>::dmobility(unsigned nodenum,
      67             :                                                unsigned phase,
      68             :                                                unsigned pvar) const
      69             : {
      70             :   if constexpr (!is_ad)
      71             :   {
      72     6354872 :     Real dm = (*_dmass_fractions_dvar)[nodenum][phase][_fluid_component][pvar] *
      73     6354872 :               _fluid_density_node[nodenum][phase] * _relative_permeability[nodenum][phase] /
      74     6354872 :               _fluid_viscosity[nodenum][phase];
      75     6354872 :     dm += _mass_fractions[nodenum][phase][_fluid_component] *
      76     6354872 :           (*_dfluid_density_node_dvar)[nodenum][phase][pvar] *
      77     6354872 :           _relative_permeability[nodenum][phase] / _fluid_viscosity[nodenum][phase];
      78     6354872 :     dm += _mass_fractions[nodenum][phase][_fluid_component] * _fluid_density_node[nodenum][phase] *
      79     6354872 :           (*_drelative_permeability_dvar)[nodenum][phase][pvar] / _fluid_viscosity[nodenum][phase];
      80     6354872 :     dm -= _mass_fractions[nodenum][phase][_fluid_component] * _fluid_density_node[nodenum][phase] *
      81     6354872 :           _relative_permeability[nodenum][phase] * (*_dfluid_viscosity_dvar)[nodenum][phase][pvar] /
      82             :           std::pow(_fluid_viscosity[nodenum][phase], 2);
      83             :     return dm;
      84             :   }
      85             :   else
      86             :     libmesh_ignore(nodenum, phase, pvar);
      87           0 :   return 0.0;
      88             : }
      89             : 
      90             : template class PorousFlowAdvectiveFluxTempl<false>;
      91             : template class PorousFlowAdvectiveFluxTempl<true>;

Generated by: LCOV version 1.14