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::Kokkos 15 : { 16 : 17 : /** 18 : * The Kokkos wrapper class that can hold the reference of an arithmetic scalar variable 19 : */ 20 : template <typename T, typename = typename std::enable_if<std::is_arithmetic<T>::value>::type> 21 : class Scalar : public ReferenceWrapper<T> 22 : { 23 : public: 24 : /** 25 : * Constructor 26 : * @param value The writeable reference of the arithmetic scalar variable to store 27 : */ 28 59510 : Scalar(T & value) : ReferenceWrapper<T>(value) {} 29 : 30 : /** 31 : * Assign a scalar value to the underlying host reference 32 : * @param value The scalar value to be assigned 33 : */ 34 150 : auto & operator=(T value) 35 : { 36 150 : this->_reference = value; 37 : 38 150 : return *this; 39 : } 40 : 41 : // TODO: add support for arithmetic operators 42 : }; 43 : 44 : template <typename T> 45 : struct ArrayDeepCopy<Scalar<T>> 46 : { 47 : static constexpr bool value = true; 48 : }; 49 : 50 : // Mimic MOOSE convention 51 : using PostprocessorValue = Scalar<const PostprocessorValue>; 52 : 53 : } // namespace Moose::Kokkos