LCOV - code coverage report
Current view: top level - src/kernels - ADArrayReaction.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 21 27 77.8 %
Date: 2026-05-29 20:35:17 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://www.mooseframework.org
       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 "ADArrayReaction.h"
      11             : 
      12             : registerMooseObject("MooseApp", ADArrayReaction);
      13             : 
      14             : InputParameters
      15        3105 : ADArrayReaction::validParams()
      16             : {
      17        3105 :   InputParameters params = ADArrayKernel::validParams();
      18        3105 :   params += ADFunctorInterface::validParams();
      19       12420 :   params.addRequiredParam<MaterialPropertyName>(
      20             :       "reaction_coefficient",
      21             :       "The name of the reaction (can be either a scalar, vector, or matrix) material property.");
      22        3105 :   params.addClassDescription(
      23             :       "An automatic differentiation kernel for the array reaction operator ($r * u$)");
      24        3105 :   return params;
      25           0 : }
      26             : 
      27          23 : ADArrayReaction::ADArrayReaction(const InputParameters & parameters)
      28             :   : ADArrayKernel(parameters),
      29          23 :     _r(hasADMaterialProperty<Real>("reaction_coefficient")
      30          23 :            ? &getADMaterialProperty<Real>("reaction_coefficient")
      31             :            : nullptr),
      32          46 :     _r_array(hasADMaterialProperty<RealEigenVector>("reaction_coefficient")
      33          23 :                  ? &getADMaterialProperty<RealEigenVector>("reaction_coefficient")
      34             :                  : nullptr),
      35          46 :     _r_2d_array(hasADMaterialProperty<RealEigenMatrix>("reaction_coefficient")
      36          69 :                     ? &getADMaterialProperty<RealEigenMatrix>("reaction_coefficient")
      37          23 :                     : nullptr)
      38             : {
      39          23 :   if (!_r && !_r_array && !_r_2d_array)
      40             :   {
      41           0 :     MaterialPropertyName mat = getParam<MaterialPropertyName>("reaction_coefficient");
      42           0 :     mooseError("Property '" + mat + "' is of unsupported type for ADArrayReaction");
      43           0 :   }
      44          23 : }
      45             : 
      46             : void
      47      177664 : ADArrayReaction::computeQpResidual(ADRealEigenVector & residual)
      48             : {
      49      177664 :   if (_r)
      50           0 :     residual = (*_r)[_qp] * _u[_qp] * _test[_i][_qp];
      51      177664 :   else if (_r_array)
      52           0 :     residual.noalias() = (*_r_array)[_qp].cwiseProduct(_u[_qp]) * _test[_i][_qp];
      53             :   else
      54      177664 :     residual.noalias() = (*_r_2d_array)[_qp] * _u[_qp] * _test[_i][_qp];
      55      177664 : }

Generated by: LCOV version 1.14