LCOV - code coverage report
Current view: top level - include/kokkos/nodalkernels - KokkosBoundNodalKernel.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 17 17 100.0 %
Date: 2026-05-29 20:35:17 Functions: 7 7 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             : #pragma once
      11             : 
      12             : #include "KokkosNodalKernel.h"
      13             : 
      14             : class KokkosBoundNodalKernel : public Moose::Kokkos::NodalKernel
      15             : {
      16             : public:
      17             :   static InputParameters validParams();
      18             : 
      19             :   KokkosBoundNodalKernel(const InputParameters & parameters);
      20             : 
      21             :   virtual void initialSetup() override;
      22             : 
      23             :   template <typename Derived>
      24             :   KOKKOS_FUNCTION Real computeQpResidual(const unsigned int qp, AssemblyDatum & datum) const;
      25             :   template <typename Derived>
      26             :   KOKKOS_FUNCTION Real computeQpJacobian(const unsigned int qp, AssemblyDatum & datum) const;
      27             :   template <typename Derived>
      28             :   KOKKOS_FUNCTION Real computeQpOffDiagJacobian(const unsigned int jvar,
      29             :                                                 const unsigned int qp,
      30             :                                                 AssemblyDatum & datum) const;
      31             : 
      32             : protected:
      33             :   /// The number of the coupled variable
      34             :   const unsigned int _v_var;
      35             : 
      36             :   /// The value of the coupled variable
      37             :   const Moose::Kokkos::VariableValue _v;
      38             : 
      39             : private:
      40             :   KOKKOS_FUNCTION bool skipOnBoundary(const ContiguousNodeID node) const;
      41             : 
      42             :   /// Boundaries on which we should not execute this object
      43             :   Moose::Kokkos::Array<ContiguousBoundaryID> _bnd_ids;
      44             : };
      45             : 
      46             : KOKKOS_FUNCTION inline bool
      47      334110 : KokkosBoundNodalKernel::skipOnBoundary(const ContiguousNodeID node) const
      48             : {
      49      991080 :   for (dof_id_type b = 0; b < _bnd_ids.size(); ++b)
      50      664470 :     if (kokkosMesh().isBoundaryNode(node, _bnd_ids[b]))
      51        7500 :       return true;
      52             : 
      53      326610 :   return false;
      54             : }
      55             : 
      56             : template <typename Derived>
      57             : KOKKOS_FUNCTION Real
      58      117744 : KokkosBoundNodalKernel::computeQpResidual(const unsigned int qp, AssemblyDatum & datum) const
      59             : {
      60      117744 :   if (skipOnBoundary(datum.node()))
      61        2688 :     return _u(datum, qp);
      62             : 
      63      115056 :   return static_cast<const Derived *>(this)->getResidual(qp, datum);
      64             : }
      65             : 
      66             : template <typename Derived>
      67             : KOKKOS_FUNCTION Real
      68       91816 : KokkosBoundNodalKernel::computeQpJacobian(const unsigned int qp, AssemblyDatum & datum) const
      69             : {
      70       91816 :   if (skipOnBoundary(datum.node()))
      71        2032 :     return 1;
      72             : 
      73       89784 :   return static_cast<const Derived *>(this)->getJacobian(qp, datum);
      74             : }
      75             : 
      76             : template <typename Derived>
      77             : KOKKOS_FUNCTION Real
      78      124550 : KokkosBoundNodalKernel::computeQpOffDiagJacobian(const unsigned int jvar,
      79             :                                                  const unsigned int qp,
      80             :                                                  AssemblyDatum & datum) const
      81             : {
      82      124550 :   if (skipOnBoundary(datum.node()))
      83        2780 :     return 0;
      84             : 
      85      121770 :   return static_cast<const Derived *>(this)->getOffDiagJacobian(jvar, qp, datum);
      86             : }

Generated by: LCOV version 1.14