LCOV - code coverage report
Current view: top level - src/nodalkernels - ArrayNodalKernel.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31706 (f8ed4a) with base bb0a08 Lines: 33 52 63.5 %
Date: 2025-11-03 17:23:24 Functions: 6 8 75.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 "ArrayNodalKernel.h"
      11             : #include "SubProblem.h"
      12             : #include "SystemBase.h"
      13             : #include "MooseVariableFE.h"
      14             : #include "Assembly.h"
      15             : 
      16             : InputParameters
      17       29830 : ArrayNodalKernel::validParams()
      18             : {
      19       29830 :   return NodalKernelBase::validParams();
      20             : }
      21             : 
      22          50 : ArrayNodalKernel::ArrayNodalKernel(const InputParameters & parameters)
      23             :   : NodalKernelBase(parameters),
      24             :     MooseVariableInterface<RealEigenVector>(this,
      25             :                                             true,
      26             :                                             "variable",
      27             :                                             Moose::VarKindType::VAR_SOLVER,
      28             :                                             Moose::VarFieldType::VAR_FIELD_ARRAY),
      29         100 :     _var(*mooseVariable()),
      30          50 :     _u(_var.dofValues()),
      31          50 :     _count(_var.count()),
      32          50 :     _work_vector(_count),
      33         250 :     _work_dofs(_count)
      34             : {
      35          50 :   addMooseVariableDependency(mooseVariable());
      36          50 : }
      37             : 
      38             : void
      39        1662 : ArrayNodalKernel::prepareDofs()
      40             : {
      41        1662 :   const dof_id_type root_dof_idx = _var.nodalDofIndex();
      42        1662 :   std::iota(_work_dofs.begin(), _work_dofs.end(), root_dof_idx);
      43        1662 : }
      44             : 
      45             : void
      46        1464 : ArrayNodalKernel::computeResidual()
      47             : {
      48        1464 :   if (!_var.isNodalDefined())
      49           0 :     return;
      50        1464 :   prepareDofs();
      51        1464 :   _qp = 0;
      52        1464 :   computeQpResidual(_work_vector);
      53        1464 :   addResiduals(_assembly, _work_vector, _work_dofs, _var.arrayScalingFactor());
      54             : }
      55             : 
      56             : void
      57         198 : ArrayNodalKernel::computeJacobian()
      58             : {
      59         198 :   if (!_var.isNodalDefined())
      60           0 :     return;
      61         198 :   prepareDofs();
      62         198 :   _qp = 0;
      63         198 :   const auto jacobian = computeQpJacobian();
      64         594 :   for (const auto i : make_range(_count))
      65        1980 :     addJacobianElement(
      66         396 :         _assembly, jacobian(i), _work_dofs[i], _work_dofs[i], _var.arrayScalingFactor()[i]);
      67         198 : }
      68             : 
      69             : void
      70         198 : ArrayNodalKernel::computeOffDiagJacobian(const unsigned int jvar_num)
      71             : {
      72         198 :   if (!_var.isNodalDefined())
      73           0 :     return;
      74             : 
      75         198 :   if (jvar_num == _var.number())
      76         198 :     computeJacobian();
      77             :   else
      78             :   {
      79           0 :     prepareDofs();
      80             : 
      81           0 :     const auto & jvar = getVariable(jvar_num);
      82           0 :     const auto jacobian = computeQpOffDiagJacobian(jvar);
      83           0 :     const auto root_jvar_idx = _current_node->dof_number(_sys.number(), jvar_num, 0);
      84             : 
      85           0 :     for (const auto i : make_range(_var.count()))
      86           0 :       for (const auto j : make_range(jvar.count()))
      87           0 :         addJacobianElement(_assembly,
      88           0 :                            jacobian(i, j),
      89           0 :                            _work_dofs[i],
      90           0 :                            root_jvar_idx + j,
      91           0 :                            _var.arrayScalingFactor()[i]);
      92           0 :   }
      93             : }
      94             : 
      95             : RealEigenVector
      96           0 : ArrayNodalKernel::computeQpJacobian()
      97             : {
      98           0 :   return RealEigenVector::Zero(_count);
      99             : }
     100             : 
     101             : RealEigenMatrix
     102           0 : ArrayNodalKernel::computeQpOffDiagJacobian(const MooseVariableFieldBase & jvar)
     103             : {
     104           0 :   return RealEigenMatrix::Zero(_count, jvar.count());
     105             : }

Generated by: LCOV version 1.14