LCOV - code coverage report
Current view: top level - src/kernels - PorousFlowBasicAdvection.C (source / functions) Hit Total Coverage
Test: idaholab/moose porous_flow: #31405 (292dce) with base fef103 Lines: 32 33 97.0 %
Date: 2025-09-04 07:55:56 Functions: 5 5 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 "PorousFlowBasicAdvection.h"
      11             : 
      12             : registerMooseObject("PorousFlowApp", PorousFlowBasicAdvection);
      13             : 
      14             : InputParameters
      15         200 : PorousFlowBasicAdvection::validParams()
      16             : {
      17         200 :   InputParameters params = Kernel::validParams();
      18         400 :   params.addRequiredParam<UserObjectName>(
      19             :       "PorousFlowDictator", "The UserObject that holds the list of PorousFlow variable names.");
      20         400 :   params.addParam<unsigned int>("phase", 0, "Use the Darcy velocity of this fluid phase");
      21         200 :   params.addClassDescription(
      22             :       "Advective flux of a Variable using the Darcy velocity of the fluid phase");
      23         200 :   return params;
      24           0 : }
      25             : 
      26         112 : PorousFlowBasicAdvection::PorousFlowBasicAdvection(const InputParameters & parameters)
      27             :   : Kernel(parameters),
      28         112 :     _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")),
      29         224 :     _ph(getParam<unsigned int>("phase")),
      30         112 :     _darcy_velocity(
      31         112 :         getMaterialProperty<std::vector<RealVectorValue>>("PorousFlow_darcy_velocity_qp")),
      32         224 :     _ddarcy_velocity_dvar(getMaterialProperty<std::vector<std::vector<RealVectorValue>>>(
      33             :         "dPorousFlow_darcy_velocity_qp_dvar")),
      34         112 :     _ddarcy_velocity_dgradvar(
      35         112 :         getMaterialProperty<std::vector<std::vector<std::vector<RealVectorValue>>>>(
      36         112 :             "dPorousFlow_darcy_velocity_qp_dgradvar"))
      37             : {
      38         112 :   if (_ph >= _dictator.numPhases())
      39           2 :     paramError("phase",
      40             :                "The Dictator proclaims that the maximum phase index in this simulation is ",
      41           2 :                _dictator.numPhases() - 1,
      42             :                " whereas you have used ",
      43           2 :                _ph,
      44             :                ". Remember that indexing starts at 0. The Dictator is watching you, to "
      45             :                "ensure your wellbeing.");
      46         110 : }
      47             : 
      48             : Real
      49        8360 : PorousFlowBasicAdvection::computeQpResidual()
      50             : {
      51        8360 :   return -_grad_test[_i][_qp] * _darcy_velocity[_qp][_ph] * _u[_qp];
      52             : }
      53             : 
      54             : Real
      55        7600 : PorousFlowBasicAdvection::computeQpJacobian()
      56             : {
      57        7600 :   const Real result = -_grad_test[_i][_qp] * _darcy_velocity[_qp][_ph] * _phi[_j][_qp];
      58        7600 :   return result + computeQpOffDiagJacobian(_var.number());
      59             : }
      60             : 
      61             : Real
      62        7880 : PorousFlowBasicAdvection::computeQpOffDiagJacobian(unsigned int jvar)
      63             : {
      64        7880 :   if (_dictator.notPorousFlowVariable(jvar))
      65             :     return 0.0;
      66             : 
      67         280 :   const unsigned pvar = _dictator.porousFlowVariableNum(jvar);
      68             :   Real result =
      69         280 :       -_grad_test[_i][_qp] * _ddarcy_velocity_dvar[_qp][_ph][pvar] * _phi[_j][_qp] * _u[_qp];
      70        1120 :   for (unsigned j = 0; j < LIBMESH_DIM; ++j)
      71         840 :     result -= _grad_test[_i][_qp] *
      72         840 :               (_ddarcy_velocity_dgradvar[_qp][_ph][j][pvar] * _grad_phi[_j][_qp](j)) * _u[_qp];
      73             : 
      74             :   return result;
      75             : }

Generated by: LCOV version 1.14