LCOV - code coverage report
Current view: top level - src/kernels - KernelGrad.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 36 45 80.0 %
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 "KernelGrad.h"
      11             : #include "Assembly.h"
      12             : #include "SystemBase.h"
      13             : #include "libmesh/quadrature.h"
      14             : 
      15             : InputParameters
      16        9489 : KernelGrad::validParams()
      17             : {
      18        9489 :   return Kernel::validParams();
      19             : }
      20             : 
      21        1757 : KernelGrad::KernelGrad(const InputParameters & parameters) : Kernel(parameters) {}
      22             : 
      23             : void
      24     2535846 : KernelGrad::computeResidual()
      25             : {
      26     2535846 :   prepareVectorTag(_assembly, _var.number());
      27     2535846 :   const unsigned int n_test = _test.size();
      28    12243824 :   for (_qp = 0; _qp < _qrule->n_points(); _qp++)
      29             :   {
      30     9707978 :     RealGradient value = precomputeQpResidual() * _JxW[_qp] * _coord[_qp];
      31    58869204 :     for (_i = 0; _i < n_test; _i++) // target for auto vectorization
      32    49161226 :       _local_re(_i) += value * _grad_test[_i][_qp];
      33             :   }
      34     2535846 :   accumulateTaggedLocalResidual();
      35             : 
      36     2535846 :   if (_has_save_in)
      37           0 :     for (const auto & var : _save_in)
      38           0 :       var->sys().solution().add_vector(_local_re, var->dofIndices());
      39     2535846 : }
      40             : 
      41             : void
      42      471937 : KernelGrad::computeJacobian()
      43             : {
      44      471937 :   prepareMatrixTag(_assembly, _var.number(), _var.number());
      45             : 
      46      471937 :   const unsigned int n_test = _test.size();
      47     2021473 :   for (_qp = 0; _qp < _qrule->n_points(); _qp++)
      48     8317756 :     for (_j = 0; _j < _phi.size(); _j++)
      49             :     {
      50     6768220 :       RealGradient value = precomputeQpJacobian() * _JxW[_qp] * _coord[_qp];
      51    54482284 :       for (_i = 0; _i < n_test; _i++) // target for auto vectorization
      52    47714064 :         _local_ke(_i, _j) += value * _grad_test[_i][_qp];
      53             :     }
      54             : 
      55      471937 :   accumulateTaggedLocalMatrix();
      56             : 
      57      471937 :   if (_has_diag_save_in)
      58             :   {
      59           0 :     const unsigned int rows = _local_ke.m();
      60           0 :     DenseVector<Number> diag(rows);
      61           0 :     for (unsigned int i = 0; i < rows; i++) // target for auto vectorization
      62           0 :       diag(i) = _local_ke(i, i);
      63             : 
      64           0 :     for (const auto & var : _diag_save_in)
      65           0 :       var->sys().solution().add_vector(diag, var->dofIndices());
      66           0 :   }
      67      471937 : }
      68             : 
      69             : void
      70      129830 : KernelGrad::computeOffDiagJacobian(const unsigned int jvar_num)
      71             : {
      72      129830 :   const auto & jvar = getVariable(jvar_num);
      73             : 
      74      129830 :   if (jvar_num == _var.number())
      75      128934 :     computeJacobian();
      76             :   else
      77             :   {
      78         896 :     prepareMatrixTag(_assembly, _var.number(), jvar_num);
      79             : 
      80             :     // This (undisplaced) jvar could potentially yield the wrong phi size if this object is acting
      81             :     // on the displaced mesh
      82         896 :     auto phi_size = jvar.dofIndices().size();
      83             : 
      84        4480 :     for (_j = 0; _j < phi_size; _j++)
      85       17920 :       for (_qp = 0; _qp < _qrule->n_points(); _qp++)
      86       71680 :         for (_i = 0; _i < _test.size(); _i++)
      87       57344 :           _local_ke(_i, _j) += _JxW[_qp] * _coord[_qp] * computeQpOffDiagJacobian(jvar_num);
      88             : 
      89         896 :     accumulateTaggedLocalMatrix();
      90             :   }
      91      129830 : }

Generated by: LCOV version 1.14