LCOV - code coverage report
Current view: top level - src/materials - PorousFlowDiffusivityBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose porous_flow: #33359 (04c914) with base 7b3324 Lines: 32 35 91.4 %
Date: 2026-07-16 14:32:57 Functions: 6 6 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 "PorousFlowDiffusivityBase.h"
      11             : 
      12             : template <bool is_ad>
      13             : InputParameters
      14         871 : PorousFlowDiffusivityBaseTempl<is_ad>::validParams()
      15             : {
      16         871 :   InputParameters params = PorousFlowMaterialVectorBase::validParams();
      17        1742 :   params.addRequiredParam<std::vector<Real>>(
      18             :       "diffusion_coeff",
      19             :       "List of diffusion coefficients.  Order is i) component 0 in phase 0; ii) "
      20             :       "component 1 in phase 0 ...; component 0 in phase 1; ... component k in "
      21             :       "phase n (m^2/s");
      22         871 :   params.addClassDescription("Base class for effective diffusivity for each phase");
      23         871 :   params.set<bool>("at_nodes") = false;
      24        1742 :   params.addPrivateParam<std::string>("pf_material_type", "diffusivity");
      25         871 :   return params;
      26           0 : }
      27             : 
      28             : template <bool is_ad>
      29         672 : PorousFlowDiffusivityBaseTempl<is_ad>::PorousFlowDiffusivityBaseTempl(
      30             :     const InputParameters & parameters)
      31             :   : PorousFlowMaterialVectorBase(parameters),
      32             : 
      33         672 :     _tortuosity(declareGenericProperty<std::vector<Real>, is_ad>("PorousFlow_tortuosity_qp")),
      34         672 :     _dtortuosity_dvar(
      35             :         is_ad ? nullptr
      36         582 :               : &declareProperty<std::vector<std::vector<Real>>>("dPorousFlow_tortuosity_qp_dvar")),
      37         672 :     _diffusion_coeff(
      38         672 :         declareProperty<std::vector<std::vector<Real>>>("PorousFlow_diffusion_coeff_qp")),
      39         672 :     _ddiffusion_coeff_dvar(is_ad ? nullptr
      40         582 :                                  : &declareProperty<std::vector<std::vector<std::vector<Real>>>>(
      41             :                                        "dPorousFlow_diffusion_coeff_qp_dvar")),
      42        2688 :     _input_diffusion_coeff(getParam<std::vector<Real>>("diffusion_coeff"))
      43             : {
      44             :   // Also, the number of diffusion coefficients must be equal to the num_phases * num_components
      45         672 :   if (_input_diffusion_coeff.size() != _num_phases * _num_components)
      46           0 :     this->paramError(
      47             :         "diffusion_coeff",
      48             :         "The number of diffusion coefficients entered is not equal to the number of phases "
      49             :         "multiplied by the number of fluid components");
      50             : 
      51         672 :   if (_nodal_material == true)
      52           0 :     mooseError("PorousFlowRelativeDiffusivity classes are only defined for at_nodes = false");
      53         672 : }
      54             : 
      55             : template <bool is_ad>
      56             : void
      57     1395916 : PorousFlowDiffusivityBaseTempl<is_ad>::computeQpProperties()
      58             : {
      59     1395916 :   _diffusion_coeff[_qp].resize(_num_phases);
      60     1395916 :   _tortuosity[_qp].resize(_num_phases);
      61             : 
      62             :   if (!is_ad)
      63             :   {
      64     1142276 :     (*_ddiffusion_coeff_dvar)[_qp].resize(_num_phases);
      65     1142276 :     (*_dtortuosity_dvar)[_qp].resize(_num_phases);
      66             :   }
      67             : 
      68     3022388 :   for (unsigned int ph = 0; ph < _num_phases; ++ph)
      69             :   {
      70     1626472 :     _diffusion_coeff[_qp][ph].resize(_num_components);
      71             : 
      72             :     if (!is_ad)
      73             :     {
      74     1203992 :       (*_ddiffusion_coeff_dvar)[_qp][ph].resize(_num_components);
      75     1203992 :       (*_dtortuosity_dvar)[_qp][ph].assign(_num_var, 0.0);
      76             :     }
      77             : 
      78     5252376 :     for (unsigned int comp = 0; comp < _num_components; ++comp)
      79             :     {
      80     3625904 :       _diffusion_coeff[_qp][ph][comp] = _input_diffusion_coeff[ph * _num_components + comp];
      81             : 
      82             :       if (!is_ad)
      83     2780944 :         (*_ddiffusion_coeff_dvar)[_qp][ph][comp].assign(_num_var, 0.0);
      84             :     }
      85             :   }
      86     1395916 : }
      87             : 
      88             : template class PorousFlowDiffusivityBaseTempl<false>;
      89             : template class PorousFlowDiffusivityBaseTempl<true>;

Generated by: LCOV version 1.14