LCOV - code coverage report
Current view: top level - src/materials - PorousFlowDiffusivityBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose porous_flow: #32971 (54bef8) with base c6cf66 Lines: 32 35 91.4 %
Date: 2026-05-29 20:38:56 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         832 : PorousFlowDiffusivityBaseTempl<is_ad>::validParams()
      15             : {
      16         832 :   InputParameters params = PorousFlowMaterialVectorBase::validParams();
      17        1664 :   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         832 :   params.addClassDescription("Base class for effective diffusivity for each phase");
      23         832 :   params.set<bool>("at_nodes") = false;
      24        1664 :   params.addPrivateParam<std::string>("pf_material_type", "diffusivity");
      25         832 :   return params;
      26           0 : }
      27             : 
      28             : template <bool is_ad>
      29         642 : PorousFlowDiffusivityBaseTempl<is_ad>::PorousFlowDiffusivityBaseTempl(
      30             :     const InputParameters & parameters)
      31             :   : PorousFlowMaterialVectorBase(parameters),
      32             : 
      33         642 :     _tortuosity(declareGenericProperty<std::vector<Real>, is_ad>("PorousFlow_tortuosity_qp")),
      34         642 :     _dtortuosity_dvar(
      35             :         is_ad ? nullptr
      36         552 :               : &declareProperty<std::vector<std::vector<Real>>>("dPorousFlow_tortuosity_qp_dvar")),
      37         642 :     _diffusion_coeff(
      38         642 :         declareProperty<std::vector<std::vector<Real>>>("PorousFlow_diffusion_coeff_qp")),
      39         642 :     _ddiffusion_coeff_dvar(is_ad ? nullptr
      40         552 :                                  : &declareProperty<std::vector<std::vector<std::vector<Real>>>>(
      41             :                                        "dPorousFlow_diffusion_coeff_qp_dvar")),
      42        2568 :     _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         642 :   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         642 :   if (_nodal_material == true)
      52           0 :     mooseError("PorousFlowRelativeDiffusivity classes are only defined for at_nodes = false");
      53         642 : }
      54             : 
      55             : template <bool is_ad>
      56             : void
      57     1395496 : PorousFlowDiffusivityBaseTempl<is_ad>::computeQpProperties()
      58             : {
      59     1395496 :   _diffusion_coeff[_qp].resize(_num_phases);
      60     1395496 :   _tortuosity[_qp].resize(_num_phases);
      61             : 
      62             :   if (!is_ad)
      63             :   {
      64     1141856 :     (*_ddiffusion_coeff_dvar)[_qp].resize(_num_phases);
      65     1141856 :     (*_dtortuosity_dvar)[_qp].resize(_num_phases);
      66             :   }
      67             : 
      68     3021128 :   for (unsigned int ph = 0; ph < _num_phases; ++ph)
      69             :   {
      70     1625632 :     _diffusion_coeff[_qp][ph].resize(_num_components);
      71             : 
      72             :     if (!is_ad)
      73             :     {
      74     1203152 :       (*_ddiffusion_coeff_dvar)[_qp][ph].resize(_num_components);
      75     1203152 :       (*_dtortuosity_dvar)[_qp][ph].assign(_num_var, 0.0);
      76             :     }
      77             : 
      78     5249856 :     for (unsigned int comp = 0; comp < _num_components; ++comp)
      79             :     {
      80     3624224 :       _diffusion_coeff[_qp][ph][comp] = _input_diffusion_coeff[ph + comp];
      81             : 
      82             :       if (!is_ad)
      83     2779264 :         (*_ddiffusion_coeff_dvar)[_qp][ph][comp].assign(_num_var, 0.0);
      84             :     }
      85             :   }
      86     1395496 : }
      87             : 
      88             : template class PorousFlowDiffusivityBaseTempl<false>;
      89             : template class PorousFlowDiffusivityBaseTempl<true>;

Generated by: LCOV version 1.14