LCOV - code coverage report
Current view: top level - include/kernels - ADArrayKernel.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 2 2 100.0 %
Date: 2026-05-29 20:35:17 Functions: 2 2 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             : #pragma once
      11             : 
      12             : #include "KernelBase.h"
      13             : #include "MooseVariableInterface.h"
      14             : #include "ADFunctorInterface.h"
      15             : 
      16             : /**
      17             :  * Base class for array variable (equation) kernels using automatic differentiation
      18             :  */
      19             : class ADArrayKernel : public KernelBase,
      20             :                       public MooseVariableInterface<RealEigenVector>,
      21             :                       public ADFunctorInterface
      22             : {
      23             : public:
      24             :   static InputParameters validParams();
      25             : 
      26             :   ADArrayKernel(const InputParameters & parameters);
      27             : 
      28             :   virtual void computeResidual() override;
      29             :   virtual void computeJacobian() override;
      30             :   virtual void computeOffDiagJacobian(unsigned int jvar) override;
      31             :   virtual void jacobianSetup() override;
      32             : 
      33        1407 :   virtual const ArrayMooseVariable & variable() const override { return _var; }
      34             : 
      35             : protected:
      36             :   /**
      37             :    * Compute this Kernel's contribution to the residual at the current quadrature point,
      38             :    * to be filled in \p residual.
      39             :    */
      40             :   virtual void computeQpResidual(ADRealEigenVector & residual) = 0;
      41             : 
      42             :   /**
      43             :    * Put necessary evaluations depending on qp but independent on test functions here
      44             :    */
      45      133248 :   virtual void initQpResidual() {}
      46             : 
      47             :   /// This is an array kernel so we cast to a ArrayMooseVariable
      48             :   ArrayMooseVariable & _var;
      49             : 
      50             :   /// the current test function
      51             :   const ArrayVariableTestValue & _test;
      52             : 
      53             :   /// gradient of the test function
      54             :   const ArrayVariableTestGradient & _grad_test;
      55             :   const MappedArrayVariablePhiGradient & _array_grad_test;
      56             : 
      57             :   /// the current shape functions
      58             :   const ArrayVariablePhiValue & _phi;
      59             : 
      60             :   /// gradient of the shape function
      61             :   const ArrayVariablePhiGradient & _grad_phi;
      62             : 
      63             :   /// Holds the solution at current quadrature points
      64             :   const ADArrayVariableValue & _u;
      65             : 
      66             :   /// Holds the solution gradient at current quadrature points
      67             :   const ADArrayVariableGradient & _grad_u;
      68             : 
      69             :   /// Number of components of the array variable
      70             :   const unsigned int _count;
      71             : 
      72             :   // Pre-allocated vector for storing the AD array residual of the kernel
      73             :   std::vector<ADReal> _local_ad_re;
      74             : 
      75             : private:
      76             :   /// Work vector for residual and diag jacobian
      77             :   ADRealEigenVector _work_vector;
      78             : 
      79             :   /// Cache variable to prevent multiple invocations of Jacobian computation for one element (recall that AD computes the Jacobian at all once for all variable couplings)
      80             :   const Elem * _my_elem = nullptr;
      81             : };

Generated by: LCOV version 1.14