https://mooseframework.inl.gov
KokkosMaterialPropertyValueDecl.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 "KokkosArray.h"
13 
14 #define usingKokkosMaterialPropertyValueBaseMembers(T, dimension) \
15  using MaterialPropertyValueBase<T, dimension>::_qp; \
16  using MaterialPropertyValueBase<T, dimension>::_data; \
17  using MaterialPropertyValueBase<T, dimension>::_value
18 
19 namespace Moose
20 {
21 namespace Kokkos
22 {
23 
24 template <typename T, unsigned int dimension>
25 class MaterialProperty;
26 
27 class Datum;
28 
34 template <typename T, unsigned int dimension>
36 class MaterialPropertyValueBase
37 {
38 public:
45  KOKKOS_FUNCTION MaterialPropertyValueBase(const MaterialProperty<T, dimension> & property,
46  const Datum & datum,
47  const unsigned int qp);
48 
54  KOKKOS_FUNCTION dof_id_type n(unsigned int dim) const { return _data->n(dim); }
55 
56 protected:
68  const T & _value;
69 };
70 
71 template <typename T, unsigned int dimension>
73 
74 template <typename T>
76 {
77  usingKokkosMaterialPropertyValueBaseMembers(T, 0);
78 
79 public:
86  KOKKOS_FUNCTION
88  const Datum & datum,
89  unsigned int qp);
90 
95  KOKKOS_FUNCTION operator const T &() const { return _data ? (*_data)(_qp) : _value; }
100  KOKKOS_FUNCTION auto & operator=(const T & value);
105  KOKKOS_FUNCTION auto & operator=(const MaterialPropertyValue<T, 0> & value);
106 };
107 
108 template <typename T>
110 {
111  usingKokkosMaterialPropertyValueBaseMembers(T, 1);
112 
113 public:
120  KOKKOS_FUNCTION
122  const Datum & datum,
123  unsigned int qp);
124 
130  KOKKOS_FUNCTION T & operator()(unsigned int i0) { return (*_data)(i0, _qp); }
136  KOKKOS_FUNCTION const T & operator()(unsigned int i0) const
137  {
138  return _data ? (*_data)(i0, _qp) : _value;
139  }
140 };
141 
142 template <typename T>
144 {
145  usingKokkosMaterialPropertyValueBaseMembers(T, 2);
146 
147 public:
154  KOKKOS_FUNCTION
156  const Datum & datum,
157  unsigned int qp);
158 
165  KOKKOS_FUNCTION T & operator()(unsigned int i0, unsigned int i1) { return (*_data)(i0, i1, _qp); }
172  KOKKOS_FUNCTION const T & operator()(unsigned int i0, unsigned int i1) const
173  {
174  return _data ? (*_data)(i0, i1, _qp) : _value;
175  }
176 };
177 
178 template <typename T>
180 {
181  usingKokkosMaterialPropertyValueBaseMembers(T, 3);
182 
183 public:
190  KOKKOS_FUNCTION
192  const Datum & datum,
193  unsigned int qp);
194 
202  KOKKOS_FUNCTION T & operator()(unsigned int i0, unsigned int i1, unsigned int i2)
203  {
204  return (*_data)(i0, i1, i2, _qp);
205  }
213  KOKKOS_FUNCTION const T & operator()(unsigned int i0, unsigned int i1, unsigned int i2) const
214  {
215  return _data ? (*_data)(i0, i1, i2, _qp) : _value;
216  }
217 };
218 
219 template <typename T>
221 {
222  usingKokkosMaterialPropertyValueBaseMembers(T, 4);
223 
224 public:
231  KOKKOS_FUNCTION
233  const Datum & datum,
234  unsigned int qp);
235 
244  KOKKOS_FUNCTION T & operator()(unsigned int i0, unsigned int i1, unsigned int i2, unsigned int i3)
245  {
246  return (*_data)(i0, i1, i2, i3, _qp);
247  }
256  KOKKOS_FUNCTION const T &
257  operator()(unsigned int i0, unsigned int i1, unsigned int i2, unsigned int i3) const
258  {
259  return _data ? (*_data)(i0, i1, i2, i3, _qp) : _value;
260  }
261 };
263 
264 } // namespace Kokkos
265 } // namespace Moose
The Kokkos object that holds thread-private data in the parallel operations of any Kokkos object...
Definition: KokkosDatum.h:25
KOKKOS_FUNCTION const T & operator()(unsigned int i0, unsigned int i1, unsigned int i2, unsigned int i3) const
Get the const reference of a property value.
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:159
KOKKOS_FUNCTION const T & operator()(unsigned int i0, unsigned int i1) const
Get the const reference of a property value.
KOKKOS_FUNCTION MaterialPropertyValueBase(const MaterialProperty< T, dimension > &property, const Datum &datum, const unsigned int qp)
Constructor.
KOKKOS_FUNCTION T & operator()(unsigned int i0)
Get the writeable reference of a property value.
The Kokkos wrapper class for accessing the material property values of a single quadrature point...
KOKKOS_FUNCTION const T & operator()(unsigned int i0) const
Get the const reference of a property value.
Array< T, dimension+1 > const * _data
Pointer to the property data storage.
KOKKOS_FUNCTION const T & operator()(unsigned int i0, unsigned int i1, unsigned int i2) const
Get the const reference of a property value.
infix_ostream_iterator< T, charT, traits > & operator=(T const &item)
Definition: InfixIterator.h:46
KOKKOS_FUNCTION dof_id_type n(unsigned int dim) const
Get the size of a dimension.
KOKKOS_FUNCTION T & operator()(unsigned int i0, unsigned int i1)
Get the writeable reference of a property value.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
MaterialPropertyValueTempl< false > MaterialPropertyValue
The Kokkos material property class.
const dof_id_type _qp
Global quadrature point index.
KOKKOS_FUNCTION T & operator()(unsigned int i0, unsigned int i1, unsigned int i2, unsigned int i3)
Get the writeable reference of a property value.
uint8_t dof_id_type
KOKKOS_FUNCTION T & operator()(unsigned int i0, unsigned int i1, unsigned int i2)
Get the writeable reference of a property value.