LCOV - code coverage report
Current view: top level - src/kernels - ArrayReaction.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 30 36 83.3 %
Date: 2025-08-08 20:01:16 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       15211 : ArrayReaction::validParams()
      16             : {
      17       15211 :   InputParameters params = ArrayKernel::validParams();
      18       15211 :   params.addRequiredParam<MaterialPropertyName>(
      19             :       "reaction_coefficient",
      20             :       "The name of the reactivity, can be scalar, vector, or matrix material property.");
      21       15211 :   params.addClassDescription("The array reaction operator with the weak "
      22             :                              "form of $(\\psi_i, u_h)$.");
      23       15211 :   return params;
      24           0 : }
      25             : 
      26         483 : ArrayReaction::ArrayReaction(const InputParameters & parameters)
      27             :   : ArrayKernel(parameters),
      28         966 :     _r(hasMaterialProperty<Real>("reaction_coefficient")
      29         483 :            ? &getMaterialProperty<Real>("reaction_coefficient")
      30             :            : nullptr),
      31         966 :     _r_array(hasMaterialProperty<RealEigenVector>("reaction_coefficient")
      32         483 :                  ? &getMaterialProperty<RealEigenVector>("reaction_coefficient")
      33             :                  : nullptr),
      34         966 :     _r_2d_array(hasMaterialProperty<RealEigenMatrix>("reaction_coefficient")
      35         483 :                     ? &getMaterialProperty<RealEigenMatrix>("reaction_coefficient")
      36         483 :                     : nullptr)
      37             : {
      38         483 :   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         483 : }
      44             : 
      45             : void
      46     3070232 : ArrayReaction::computeQpResidual(RealEigenVector & residual)
      47             : {
      48             : 
      49     3070232 :   if (_r)
      50           0 :     residual = (*_r)[_qp] * _u[_qp] * _test[_i][_qp];
      51             : 
      52     3070232 :   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     2738776 :     residual.noalias() = (*_r_array)[_qp].asDiagonal() * _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      331456 :     residual.noalias() = (*_r_2d_array)[_qp] * _u[_qp] * _test[_i][_qp];
      71             :   }
      72     3070232 : }
      73             : 
      74             : RealEigenVector
      75     1935572 : ArrayReaction::computeQpJacobian()
      76             : {
      77     1935572 :   if (_r)
      78           0 :     return RealEigenVector::Constant(_var.count(), _phi[_j][_qp] * _test[_i][_qp] * (*_r)[_qp]);
      79     1935572 :   else if (_r_array)
      80     3626408 :     return _phi[_j][_qp] * _test[_i][_qp] * (*_r_array)[_qp];
      81             : 
      82             :   else
      83      244736 :     return _phi[_j][_qp] * _test[_i][_qp] * (*_r_2d_array)[_qp].diagonal();
      84             : }
      85             : 
      86             : RealEigenMatrix
      87     1296644 : ArrayReaction::computeQpOffDiagJacobian(const MooseVariableFEBase & jvar)
      88             : {
      89     1296644 :   if (jvar.number() == _var.number() && _r_2d_array)
      90      724992 :     return _phi[_j][_qp] * _test[_i][_qp] * (*_r_2d_array)[_qp];
      91             :   else
      92      934148 :     return ArrayKernel::computeQpOffDiagJacobian(jvar);
      93             : }

Generated by: LCOV version 1.14