LCOV - code coverage report
Current view: top level - src/kernels - ArrayReaction.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 30 36 83.3 %
Date: 2026-05-29 20:35:17 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 "ArrayReaction.h"
      11             : 
      12             : registerMooseObject("MooseApp", ArrayReaction);
      13             : 
      14             : InputParameters
      15        3952 : ArrayReaction::validParams()
      16             : {
      17        3952 :   InputParameters params = ArrayKernel::validParams();
      18       15808 :   params.addRequiredParam<MaterialPropertyName>(
      19             :       "reaction_coefficient",
      20             :       "The name of the reactivity, can be scalar, vector, or matrix material property.");
      21        3952 :   params.addClassDescription("The array reaction operator with the weak "
      22             :                              "form of $(\\psi_i, u_h)$.");
      23        3952 :   return params;
      24           0 : }
      25             : 
      26         458 : ArrayReaction::ArrayReaction(const InputParameters & parameters)
      27             :   : ArrayKernel(parameters),
      28         458 :     _r(hasMaterialProperty<Real>("reaction_coefficient")
      29         458 :            ? &getMaterialProperty<Real>("reaction_coefficient")
      30             :            : nullptr),
      31         916 :     _r_array(hasMaterialProperty<RealEigenVector>("reaction_coefficient")
      32        1058 :                  ? &getMaterialProperty<RealEigenVector>("reaction_coefficient")
      33             :                  : nullptr),
      34         916 :     _r_2d_array(hasMaterialProperty<RealEigenMatrix>("reaction_coefficient")
      35         774 :                     ? &getMaterialProperty<RealEigenMatrix>("reaction_coefficient")
      36         458 :                     : nullptr)
      37             : {
      38         458 :   if (!_r && !_r_array && !_r_2d_array)
      39             :   {
      40           0 :     MaterialPropertyName mat = getParam<MaterialPropertyName>("reaction_coefficient");
      41           0 :     mooseError("Property " + mat + " is of unsupported type for ArrayReaction");
      42           0 :   }
      43         458 : }
      44             : 
      45             : void
      46     4698496 : ArrayReaction::computeQpResidual(RealEigenVector & residual)
      47             : {
      48             : 
      49     4698496 :   if (_r)
      50           0 :     residual = (*_r)[_qp] * _u[_qp] * _test[_i][_qp];
      51             : 
      52     4698496 :   else if (_r_array)
      53             :   {
      54             :     mooseAssert((*_r_array)[_qp].size() == _var.count(),
      55             :                 "reaction_coefficient size is inconsistent with the number of components of array "
      56             :                 "variable");
      57             :     // WARNING: use noalias() syntax with caution. See ArrayDiffusion.C for more details.
      58     2452416 :     residual.noalias() = (*_r_array)[_qp].cwiseProduct(_u[_qp]) * _test[_i][_qp];
      59             :   }
      60             : 
      61             :   else
      62             :   {
      63             :     mooseAssert((*_r_2d_array)[_qp].cols() == _var.count(),
      64             :                 "reaction_coefficient size is inconsistent with the number of components of array "
      65             :                 "variable");
      66             :     mooseAssert((*_r_2d_array)[_qp].rows() == _var.count(),
      67             :                 "reaction_coefficient size is inconsistent with the number of components of array "
      68             :                 "variable");
      69             :     // WARNING: use noalias() syntax with caution. See ArrayDiffusion.C for more details.
      70     2246080 :     residual.noalias() = (*_r_2d_array)[_qp] * _u[_qp] * _test[_i][_qp];
      71             :   }
      72     4698496 : }
      73             : 
      74             : RealEigenVector
      75     1717920 : ArrayReaction::computeQpJacobian()
      76             : {
      77     1717920 :   if (_r)
      78           0 :     return RealEigenVector::Constant(_var.count(), _phi[_j][_qp] * _test[_i][_qp] * (*_r)[_qp]);
      79     1717920 :   else if (_r_array)
      80     3218752 :     return _phi[_j][_qp] * _test[_i][_qp] * (*_r_array)[_qp];
      81             : 
      82             :   else
      83      108544 :     return _phi[_j][_qp] * _test[_i][_qp] * (*_r_2d_array)[_qp].diagonal();
      84             : }
      85             : 
      86             : RealEigenMatrix
      87     2010912 : ArrayReaction::computeQpOffDiagJacobian(const MooseVariableFEBase & jvar)
      88             : {
      89     2010912 :   if (jvar.number() == _var.number() && _r_2d_array)
      90     2375680 :     return _phi[_j][_qp] * _test[_i][_qp] * (*_r_2d_array)[_qp];
      91             :   else
      92      823072 :     return ArrayKernel::computeQpOffDiagJacobian(jvar);
      93             : }

Generated by: LCOV version 1.14