https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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>::_idx; \
16 using MaterialPropertyValueBase<T, dimension>::_data; \
17 using MaterialPropertyValueBase<T, dimension>::_value
18
19namespace Moose::Kokkos
20{
21
22template <typename T, unsigned int dimension>
24
25class Datum;
26
33template <typename T, unsigned int dimension>
35{
36public:
43 KOKKOS_FUNCTION MaterialPropertyValueBase(const MaterialProperty<T, dimension> & property,
44 const Datum & datum,
45 const unsigned int qp);
46
52 KOKKOS_FUNCTION dof_id_type n(unsigned int dim) const { return _data->n(dim); }
53
54protected:
58 const dof_id_type _idx;
66 const T & _value;
67};
68
69template <typename T, unsigned int dimension>
71{
73
74public:
81 KOKKOS_FUNCTION MaterialPropertyValue(const MaterialProperty<T, dimension> & property,
82 const Datum & datum,
83 const unsigned int qp);
84
90 template <typename... index_type>
91 KOKKOS_FUNCTION T & operator()(index_type... i)
92 {
93 static_assert(sizeof...(i) == dimension,
94 "Number of arguments should match material property dimension");
95
96 return (*_data)(i..., _idx);
97 }
103 template <typename... index_type>
104 KOKKOS_FUNCTION const T & operator()(index_type... i) const
105 {
106 static_assert(sizeof...(i) == dimension,
107 "Number of arguments should match material property dimension");
108
109 return _data ? (*_data)(i..., _idx) : _value;
110 }
111};
112
113template <typename T>
115{
117
118public:
125 KOKKOS_FUNCTION
127 const Datum & datum,
128 const unsigned int qp);
129
134 KOKKOS_FUNCTION operator const T &() const { return _data ? (*_data)(_idx) : _value; }
139 KOKKOS_FUNCTION auto & operator=(const T & value);
144 KOKKOS_FUNCTION auto & operator=(const MaterialPropertyValue<T, 0> & value);
145};
147
148} // namespace Moose::Kokkos
KOKKOS_FUNCTION index_type n(unsigned int dim) const
Get the size of a dimension.
The Kokkos array class.
The Kokkos object that holds thread-private data in the parallel operations of any Kokkos object.
The Kokkos wrapper class for accessing the material property values of a single quadrature point.
const dof_id_type _idx
Index into the property data storage.
KOKKOS_FUNCTION dof_id_type n(unsigned int dim) const
Get the size of a dimension.
Array< T, dimension+1 > const * _data
Pointer to the property data storage.
KOKKOS_FUNCTION const T & operator()(index_type... i) const
Get the const reference of a property value.
KOKKOS_FUNCTION T & operator()(index_type... i)
Get the writeable reference of a property value.
usingKokkosMaterialPropertyValueBaseMembers(T, dimension)
The Kokkos material property class.
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition Moose.h:165