LCOV - code coverage report
Current view: top level - include/kokkos/userobjects - KokkosUserObject.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 2 6 33.3 %
Date: 2026-05-29 20:35:17 Functions: 21 44 47.7 %
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 "KokkosMesh.h"
      13             : #include "KokkosAssembly.h"
      14             : #include "KokkosSystem.h"
      15             : #include "KokkosDispatcher.h"
      16             : 
      17             : #include "UserObjectBase.h"
      18             : 
      19             : namespace Moose::Kokkos
      20             : {
      21             : 
      22             : class UserObject : public ::UserObjectBase
      23             : {
      24             : public:
      25             :   static InputParameters validParams();
      26             : 
      27             :   UserObject(const InputParameters & params);
      28             : 
      29             :   /**
      30             :    * Copy constructor for parallel dispatch
      31             :    */
      32             :   UserObject(const UserObject & object);
      33             : 
      34             :   // Unused for Kokkos user objects because all subdomains are computed in parallel
      35           0 :   virtual void subdomainSetup() override final {}
      36             : 
      37             :   // Kokkos user objects are never threaded
      38           0 :   virtual bool needThreadedCopy() const override final { return false; }
      39             : 
      40             :   /**
      41             :    * Compute this user object
      42             :    */
      43             :   virtual void compute() = 0;
      44             : 
      45             :   /**
      46             :    * Kokkos function tag
      47             :    */
      48             :   struct DefaultLoop
      49             :   {
      50             :   };
      51             : 
      52             :   /**
      53             :    * Default method to prevent compile errors even when this method was not defined in the derived
      54             :    * class
      55             :    */
      56             :   template <typename Derived>
      57           0 :   KOKKOS_FUNCTION void execute(Datum & /* datum */) const
      58             :   {
      59           0 :     ::Kokkos::abort("Default execute() should never be called. Make sure you properly redefined "
      60             :                     "this method in your class without typos.");
      61             :   }
      62             : 
      63             :   /**
      64             :    * Function used to check if users have overriden the hook method
      65             :    * @returns The function pointer of the default hook method
      66             :    */
      67             :   template <typename Derived>
      68      847380 :   static auto defaultExecute()
      69             :   {
      70      847380 :     return &UserObject::execute<Derived>;
      71             :   }
      72             : 
      73             : protected:
      74             :   /**
      75             :    * Dispatch parallel operation
      76             :    */
      77             :   virtual void computeUserObject();
      78             :   /**
      79             :    * Get the number of threads
      80             :    */
      81             :   virtual ThreadID numUserObjectThreads() const = 0;
      82             : 
      83             :   /**
      84             :    * Kokkos functor dispatcher
      85             :    */
      86             :   std::unique_ptr<DispatcherBase> _user_object_dispatcher;
      87             : };
      88             : 
      89             : } // namespace Moose::Kokkos

Generated by: LCOV version 1.14