Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <cstddef>
7 :
8 : #include "DataStructures/TaggedTuple.hpp"
9 : #include "DataStructures/Variables.hpp"
10 : #include "Utilities/Kokkos/KokkosMacros.hpp"
11 : #include "Utilities/TMPL.hpp"
12 :
13 : /*!
14 : * \ingroup DataStructuresGroup
15 : * \brief A TempBuffer holds a set of `Tensor<DataType>`s, where
16 : * DataType is either a `DataVector` (or similar type) or a
17 : * fundamental type, in a way that minimizes allocations.
18 : *
19 : * The user gets references to Tensors inside of the TempBuffer using,
20 : * e.g., `auto& variable = get<Tag>(temp_buffer)`, where `Tag` is one
21 : * of the Tags in the `TagList`.
22 : *
23 : * If DataType is a DataVector or similar, than TempBuffer is a
24 : * Variables. If DataType is a fundamental type, then TempBuffer is a
25 : * TaggedTuple.
26 : *
27 : */
28 : template <typename TagList,
29 : bool is_fundamental = std::is_fundamental_v<
30 : typename tmpl::front<TagList>::type::value_type>>
31 1 : struct TempBuffer;
32 :
33 : template <typename TagList>
34 0 : struct TempBuffer<TagList, true> : tuples::tagged_tuple_from_typelist<TagList> {
35 0 : KOKKOS_FUNCTION explicit TempBuffer(const size_t /*size*/)
36 : : tuples::tagged_tuple_from_typelist<TagList>::TaggedTuple() {}
37 :
38 0 : KOKKOS_FUNCTION static size_t number_of_grid_points() { return 1; }
39 : };
40 :
41 : template <typename TagList>
42 0 : struct TempBuffer<TagList, false> : Variables<TagList> {
43 : using Variables<TagList>::Variables;
44 : };
|