https://mooseframework.inl.gov
KokkosScalar.h
Go to the documentation of this file.
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 
22 template <typename T, typename = typename std::enable_if<std::is_arithmetic<T>::value>::type>
24 class Scalar : public ReferenceWrapper<T>
25 {
26 public:
31  Scalar(T & value) : ReferenceWrapper<T>(value) {}
32 
37  auto & operator=(T value)
38  {
39  this->_reference = value;
40 
41  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:
57  Scalar(const T & value) : ReferenceWrapper<const T>(value) {}
58 };
60 
61 // Mimic MOOSE convention
63 
64 } // namespace Kokkos
65 } // namespace Moose
The Kokkos object that can hold the reference of a variable.
The Kokkos wrapper class that can hold the reference of an arithmetic scalar variable.
Definition: KokkosScalar.h:24
T & _reference
Writeable host reference of the variable.
auto & operator=(T value)
Assign a scalar value to the underlying host reference.
Definition: KokkosScalar.h:37
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
Scalar(T &value)
Constructor.
Definition: KokkosScalar.h:31
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...