LCOV - code coverage report
Current view: top level - src/kernels - KernelGrad.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 29 49 59.2 %
Date: 2025-07-17 01:28:37 Functions: 5 7 71.4 %
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       14299 : KernelGrad::validParams()
      17             : {
      18       14299 :   return Kernel::validParams();
      19             : }
      20             : 
      21          18 : KernelGrad::KernelGrad(const InputParameters & parameters) : Kernel(parameters) {}
      22             : 
      23             : void
      24       11776 : KernelGrad::computeResidual()
      25             : {
      26       11776 :   prepareVectorTag(_assembly, _var.number());
      27       11776 :   const unsigned int n_test = _test.size();
      28      198656 :   for (_qp = 0; _qp < _qrule->n_points(); _qp++)
      29             :   {
      30      186880 :     RealGradient value = precomputeQpResidual() * _JxW[_qp] * _coord[_qp];
      31     3170816 :     for (_i = 0; _i < n_test; _i++) // target for auto vectorization
      32     2983936 :       _local_re(_i) += value * _grad_test[_i][_qp];
      33             :   }
      34       11776 :   accumulateTaggedLocalResidual();
      35             : 
      36       11776 :   if (_has_save_in)
      37           0 :     for (const auto & var : _save_in)
      38           0 :       var->sys().solution().add_vector(_local_re, var->dofIndices());
      39       11776 : }
      40             : 
      41             : void
      42        4256 : KernelGrad::computeJacobian()
      43             : {
      44        4256 :   prepareMatrixTag(_assembly, _var.number(), _var.number());
      45             : 
      46        4256 :   const unsigned int n_test = _test.size();
      47       71968 :   for (_qp = 0; _qp < _qrule->n_points(); _qp++)
      48     1149568 :     for (_j = 0; _j < _phi.size(); _j++)
      49             :     {
      50     1081856 :       RealGradient value = precomputeQpJacobian() * _JxW[_qp] * _coord[_qp];
      51    18385408 :       for (_i = 0; _i < n_test; _i++) // target for auto vectorization
      52    17303552 :         _local_ke(_i, _j) += value * _grad_test[_i][_qp];
      53             :     }
      54             : 
      55        4256 :   accumulateTaggedLocalMatrix();
      56             : 
      57        4256 :   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        4256 : }
      68             : 
      69             : void
      70        2688 : KernelGrad::computeOffDiagJacobian(const unsigned int jvar_num)
      71             : {
      72        2688 :   const auto & jvar = getVariable(jvar_num);
      73             : 
      74        2688 :   if (jvar_num == _var.number())
      75        2688 :     computeJacobian();
      76             :   else
      77             :   {
      78           0 :     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           0 :     auto phi_size = jvar.dofIndices().size();
      83             : 
      84           0 :     for (_j = 0; _j < phi_size; _j++)
      85           0 :       for (_qp = 0; _qp < _qrule->n_points(); _qp++)
      86           0 :         for (_i = 0; _i < _test.size(); _i++)
      87           0 :           _local_ke(_i, _j) += _JxW[_qp] * _coord[_qp] * computeQpOffDiagJacobian(jvar_num);
      88             : 
      89           0 :     accumulateTaggedLocalMatrix();
      90             :   }
      91        2688 : }
      92             : 
      93             : Real
      94           0 : KernelGrad::computeQpResidual()
      95             : {
      96           0 :   return 0.0;
      97             : }
      98             : 
      99             : RealGradient
     100           0 : KernelGrad::precomputeQpJacobian()
     101             : {
     102           0 :   return RealGradient(0.0);
     103             : }

Generated by: LCOV version 1.14