LCOV - code coverage report
Current view: top level - include/kokkos/base - KokkosScalar.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 6f668f Lines: 5 5 100.0 %
Date: 2025-09-22 20:01:15 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://www.mooseframework.org
       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 "KokkosReferenceWrapper.h"
      13             : 
      14             : namespace Moose
      15             : {
      16             : namespace Kokkos
      17             : {
      18             : 
      19             : /**
      20             :  * The Kokkos wrapper class that can hold the reference of an arithmetic scalar variable
      21             :  */
      22             : ///@{
      23             : template <typename T, typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
      24             : class Scalar : public ReferenceWrapper<T>
      25             : {
      26             : public:
      27             :   /**
      28             :    * Constructor
      29             :    * @param value The writeable reference of the arithmetic scalar variable to store
      30             :    */
      31       15724 :   Scalar(T & value) : ReferenceWrapper<T>(value) {}
      32             : 
      33             :   /**
      34             :    * Assign a scalar value to the underlying host reference
      35             :    * @param value The scalar value to be assigned
      36             :    */
      37         100 :   auto & operator=(T value)
      38             :   {
      39         100 :     this->_reference = value;
      40             : 
      41         100 :     return *this;
      42             :   }
      43             : 
      44             :   // TODO: add support for arithmetic operators
      45             : };
      46             : 
      47             : // The const specialization
      48             : template <typename T>
      49             : class Scalar<const T, typename std::enable_if<std::is_arithmetic<T>::value>::type>
      50             :   : public ReferenceWrapper<const T>
      51             : {
      52             : public:
      53             :   /**
      54             :    * Constructor
      55             :    * @param value The const reference of the arithmetic scalar variable to store
      56             :    */
      57        5805 :   Scalar(const T & value) : ReferenceWrapper<const T>(value) {}
      58             : };
      59             : ///@}
      60             : 
      61             : // Mimic MOOSE convention
      62             : using PostprocessorValue = Scalar<const PostprocessorValue>;
      63             : 
      64             : } // namespace Kokkos
      65             : } // namespace Moose

Generated by: LCOV version 1.14