DDC 0.12.0
Loading...
Searching...
No Matches
discrete_vector.hpp
1// Copyright (C) The DDC development team, see COPYRIGHT.md file
2//
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
7#include <array>
8#include <concepts>
9#include <cstddef>
10#include <iosfwd>
11#include <type_traits>
12#include <utility>
13
14#include <Kokkos_Macros.hpp>
15
16#include "detail/macros.hpp"
17#include "detail/type_seq.hpp"
18#include "detail/utils.hpp"
19
20namespace ddc {
21
22template <class...>
23class DiscreteVector;
24
25template <class T>
26struct is_discrete_vector : std::false_type
27{
28};
29
30template <class... Tags>
31struct is_discrete_vector<DiscreteVector<Tags...>> : std::true_type
32{
33};
34
35template <class T>
36inline constexpr bool is_discrete_vector_v = is_discrete_vector<T>::value;
37
38namespace concepts {
39
40template <class T>
41concept discrete_vector = is_discrete_vector_v<T>;
42
43}
44
45namespace detail {
46
47template <class... Tags>
48struct ToTypeSeq<DiscreteVector<Tags...>>
49{
50 using type = TypeSeq<Tags...>;
51};
52
53} // namespace detail
54
55/** A DiscreteVectorElement is a scalar that represents the difference between two coordinates.
56 */
57using DiscreteVectorElement = std::ptrdiff_t;
58
59template <class QueryTag, class... Tags>
60KOKKOS_FUNCTION constexpr DiscreteVectorElement const& get(
61 DiscreteVector<Tags...> const& tuple) noexcept
62{
63 return tuple.template get<QueryTag>();
64}
65
66template <class QueryTag, class... Tags>
67KOKKOS_FUNCTION constexpr DiscreteVectorElement& get(DiscreteVector<Tags...>& tuple) noexcept
68{
69 return tuple.template get<QueryTag>();
70}
71
72template <class QueryTag, class... Tags>
73KOKKOS_FUNCTION constexpr DiscreteVectorElement const& get_or(
74 DiscreteVector<Tags...> const& tuple,
75 DiscreteVectorElement const& default_value) noexcept
76{
77 return tuple.template get_or<QueryTag>(default_value);
78}
79
80template <class QueryTag, class... Tags>
81KOKKOS_FUNCTION constexpr DiscreteVector<QueryTag> select_or(
82 DiscreteVector<Tags...> const& arr,
83 DiscreteVector<QueryTag> const& default_value) noexcept
84{
85 if constexpr (in_tags_v<QueryTag, detail::TypeSeq<Tags...>>) {
86 return DiscreteVector<QueryTag>(arr);
87 } else {
88 return default_value;
89 }
90}
91
92/// Unary operators: +, -
93
94template <class... Tags>
95KOKKOS_FUNCTION constexpr DiscreteVector<Tags...> operator+(DiscreteVector<Tags...> const& x)
96{
97 return x;
98}
99
100template <class... Tags>
101KOKKOS_FUNCTION constexpr DiscreteVector<Tags...> operator-(DiscreteVector<Tags...> const& x)
102{
103 return DiscreteVector<Tags...>((-get<Tags>(x))...);
104}
105
106/// Internal binary operators: +, -
107
108template <class... Tags, class... OTags>
109KOKKOS_FUNCTION constexpr auto operator+(
110 DiscreteVector<Tags...> const& lhs,
111 DiscreteVector<OTags...> const& rhs)
112{
113 using detail::TypeSeq;
114 if constexpr (sizeof...(Tags) >= sizeof...(OTags)) {
115 static_assert((type_seq_contains_v<TypeSeq<OTags>, TypeSeq<Tags...>> && ...));
116 DiscreteVector<Tags...> result(lhs);
117 result += rhs;
118 return result;
119 } else {
120 static_assert((type_seq_contains_v<TypeSeq<Tags>, TypeSeq<OTags...>> && ...));
121 DiscreteVector<OTags...> result(rhs);
122 result += lhs;
123 return result;
124 }
125}
126
127template <class... Tags, class... OTags>
128KOKKOS_FUNCTION constexpr auto operator-(
129 DiscreteVector<Tags...> const& lhs,
130 DiscreteVector<OTags...> const& rhs)
131{
132 using detail::TypeSeq;
133 if constexpr (sizeof...(Tags) >= sizeof...(OTags)) {
134 static_assert((type_seq_contains_v<TypeSeq<OTags>, TypeSeq<Tags...>> && ...));
135 DiscreteVector<Tags...> result(lhs);
136 result -= rhs;
137 return result;
138 } else {
139 static_assert((type_seq_contains_v<TypeSeq<Tags>, TypeSeq<OTags...>> && ...));
140 DiscreteVector<OTags...> result(-rhs);
141 result += lhs;
142 return result;
143 }
144}
145
146template <class Tag, std::integral IntegralType>
147KOKKOS_FUNCTION constexpr DiscreteVector<Tag> operator+(
148 DiscreteVector<Tag> const& lhs,
149 IntegralType const& rhs)
150{
151 return DiscreteVector<Tag>(get<Tag>(lhs) + rhs);
152}
153
154template <std::integral IntegralType, class Tag>
155KOKKOS_FUNCTION constexpr DiscreteVector<Tag> operator+(
156 IntegralType const& lhs,
157 DiscreteVector<Tag> const& rhs)
158{
159 return DiscreteVector<Tag>(lhs + get<Tag>(rhs));
160}
161
162template <class Tag, std::integral IntegralType>
163KOKKOS_FUNCTION constexpr DiscreteVector<Tag> operator-(
164 DiscreteVector<Tag> const& lhs,
165 IntegralType const& rhs)
166{
167 return DiscreteVector<Tag>(get<Tag>(lhs) - rhs);
168}
169
170template <std::integral IntegralType, class Tag>
171KOKKOS_FUNCTION constexpr DiscreteVector<Tag> operator-(
172 IntegralType const& lhs,
173 DiscreteVector<Tag> const& rhs)
174{
175 return DiscreteVector<Tag>(lhs - get<Tag>(rhs));
176}
177
178/// external left binary operator: *
179
180template <std::integral IntegralType, class... Tags>
181KOKKOS_FUNCTION constexpr auto operator*(
182 IntegralType const& lhs,
183 DiscreteVector<Tags...> const& rhs)
184{
185 return DiscreteVector<Tags...>((lhs * get<Tags>(rhs))...);
186}
187
188template <class... QueryTags, class... Tags>
189KOKKOS_FUNCTION constexpr DiscreteVector<QueryTags...> select(
190 DiscreteVector<Tags...> const& arr) noexcept
191{
192 return DiscreteVector<QueryTags...>(arr);
193}
194
195template <class... QueryTags, class... Tags>
196KOKKOS_FUNCTION constexpr DiscreteVector<QueryTags...> select(
197 DiscreteVector<Tags...>&& arr) noexcept
198{
199 return DiscreteVector<QueryTags...>(std::move(arr));
200}
201
202/// Returns a reference towards the DiscreteVector that contains the QueryTag
203template <
204 class QueryTag,
205 concepts::discrete_vector HeadDVect,
206 concepts::discrete_vector... TailDVects>
207KOKKOS_FUNCTION constexpr auto const& take(HeadDVect const& head, TailDVects const&... tail)
208{
209 DDC_IF_NVCC_THEN_PUSH_AND_SUPPRESS(implicit_return_from_non_void_function)
210 if constexpr (type_seq_contains_v<detail::TypeSeq<QueryTag>, to_type_seq_t<HeadDVect>>) {
211 static_assert(
212 (!type_seq_contains_v<detail::TypeSeq<QueryTag>, to_type_seq_t<TailDVects>> && ...),
213 "ERROR: tag redundant");
214 return head;
215 } else {
216 static_assert(sizeof...(TailDVects) > 0, "ERROR: tag not found");
217 return take<QueryTag>(tail...);
218 }
219 DDC_IF_NVCC_THEN_POP
220}
221
222namespace detail {
223
224template <class T>
225class DiscreteVectorConversionOperators
226{
227};
228
229template <class Tag>
230class DiscreteVectorConversionOperators<DiscreteVector<Tag>>
231{
232public:
233 // NOLINTBEGIN(google-explicit-constructor)
234 KOKKOS_FUNCTION constexpr operator DiscreteVectorElement const&() const noexcept
235 {
236 return static_cast<DiscreteVector<Tag> const*>(this)->m_values[0];
237 }
238
239 KOKKOS_FUNCTION constexpr operator DiscreteVectorElement&() noexcept
240 {
241 return static_cast<DiscreteVector<Tag>*>(this)->m_values[0];
242 }
243 // NOLINTEND(google-explicit-constructor)
244};
245
246/// Returns a reference to the underlying `std::array`
247template <class... Tags>
248KOKKOS_FUNCTION constexpr std::array<DiscreteVectorElement, sizeof...(Tags)>& array(
249 DiscreteVector<Tags...>& v) noexcept
250{
251 return v.m_values;
252}
253
254/// Returns a reference to the underlying `std::array`
255template <class... Tags>
256KOKKOS_FUNCTION constexpr std::array<DiscreteVectorElement, sizeof...(Tags)> const& array(
257 DiscreteVector<Tags...> const& v) noexcept
258{
259 return v.m_values;
260}
261
262} // namespace detail
263
264/** A DiscreteVector is a vector in the discrete dimension
265 *
266 * Each is tagged by its associated dimensions.
267 */
268template <class... Tags>
269class DiscreteVector : public detail::DiscreteVectorConversionOperators<DiscreteVector<Tags...>>
270{
271 friend class detail::DiscreteVectorConversionOperators<DiscreteVector<Tags...>>;
272
273 friend KOKKOS_FUNCTION constexpr std::array<DiscreteVectorElement, sizeof...(Tags)>& detail::
274 array<Tags...>(DiscreteVector<Tags...>& v) noexcept;
275 friend KOKKOS_FUNCTION constexpr std::array<DiscreteVectorElement, sizeof...(Tags)> const&
276 detail::array<Tags...>(DiscreteVector<Tags...> const& v) noexcept;
277
278 using tags_seq = detail::TypeSeq<Tags...>;
279
280 static_assert(
281 type_seq_is_unique_v<tags_seq>,
282 "The dimensions of a DiscreteVector must be unique");
283
284private:
285 std::array<DiscreteVectorElement, sizeof...(Tags)> m_values;
286
287public:
288 using value_type = DiscreteVectorElement;
289
290 static KOKKOS_FUNCTION constexpr std::size_t size() noexcept
291 {
292 return sizeof...(Tags);
293 }
294
295public:
296 KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteVector() = default;
297
298 KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteVector(DiscreteVector const&) = default;
299
300 KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteVector(DiscreteVector&&) = default;
301
302 template <concepts::discrete_vector... DVects>
303 KOKKOS_FUNCTION constexpr explicit DiscreteVector(DVects const&... delems) noexcept
304 : m_values {take<Tags>(delems...).template get<Tags>()...}
305 {
306 }
307
308 template <std::convertible_to<DiscreteVectorElement> IntegerType>
309 KOKKOS_FUNCTION constexpr explicit DiscreteVector(
310 std::array<IntegerType, sizeof...(Tags)> const& values) noexcept
311 : m_values(
312 detail::convert_array_to<DiscreteVectorElement>(
313 values,
314 std::make_index_sequence<sizeof...(Tags)>()))
315 {
316 }
317
318 template <std::convertible_to<DiscreteVectorElement>... Params>
319 KOKKOS_FUNCTION constexpr explicit DiscreteVector(Params const&... params) noexcept
320 requires((!is_discrete_vector_v<Params> && ...) && sizeof...(Params) == sizeof...(Tags))
321 : m_values {static_cast<DiscreteVectorElement>(params)...}
322 {
323 }
324
325 KOKKOS_DEFAULTED_FUNCTION ~DiscreteVector() = default;
326
327 KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteVector& operator=(DiscreteVector const& other)
328 = default;
329
330 KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteVector& operator=(DiscreteVector&& other) = default;
331
332 template <class... OTags>
333 KOKKOS_FUNCTION constexpr bool operator==(DiscreteVector<OTags...> const& rhs) const noexcept
334 {
335 return ((m_values[type_seq_rank_v<Tags, tags_seq>] == rhs.template get<Tags>()) && ...);
336 }
337
338#if !defined(__cpp_impl_three_way_comparison) || __cpp_impl_three_way_comparison < 201902L
339 // In C++20, `a!=b` shall be automatically translated by the compiler to `!(a==b)`
340 template <class... OTags>
341 KOKKOS_FUNCTION constexpr bool operator!=(DiscreteVector<OTags...> const& rhs) const noexcept
342 {
343 return !(*this == rhs);
344 }
345#endif
346
347 template <class QueryTag>
348 KOKKOS_FUNCTION constexpr DiscreteVectorElement& get() noexcept
349 {
350 static_assert(in_tags_v<QueryTag, tags_seq>, "requested Tag absent from DiscreteVector");
351 return m_values[type_seq_rank_v<QueryTag, tags_seq>];
352 }
353
354 template <class QueryTag>
355 KOKKOS_FUNCTION constexpr DiscreteVectorElement const& get() const noexcept
356 {
357 static_assert(in_tags_v<QueryTag, tags_seq>, "requested Tag absent from DiscreteVector");
358 return m_values[type_seq_rank_v<QueryTag, tags_seq>];
359 }
360
361 template <class QueryTag>
362 KOKKOS_FUNCTION constexpr DiscreteVectorElement const& get_or(
363 DiscreteVectorElement const& default_value) const&
364 {
365 DDC_IF_NVCC_THEN_PUSH_AND_SUPPRESS(implicit_return_from_non_void_function)
366 if constexpr (in_tags_v<QueryTag, tags_seq>) {
367 return m_values[type_seq_rank_v<QueryTag, tags_seq>];
368 } else {
369 return default_value;
370 }
371 DDC_IF_NVCC_THEN_POP
372 }
373
374 KOKKOS_FUNCTION constexpr DiscreteVectorElement const& value() const noexcept
375 requires(sizeof...(Tags) == 1)
376 {
377 return m_values[0];
378 }
379
380 KOKKOS_FUNCTION constexpr DiscreteVector& operator++()
381 requires(sizeof...(Tags) == 1)
382 {
383 ++m_values[0];
384 return *this;
385 }
386
387 KOKKOS_FUNCTION constexpr DiscreteVector operator++(int)
388 requires(sizeof...(Tags) == 1)
389 {
390 DiscreteVector const tmp = *this;
391 ++m_values[0];
392 return tmp;
393 }
394
395 KOKKOS_FUNCTION constexpr DiscreteVector& operator--()
396 requires(sizeof...(Tags) == 1)
397 {
398 --m_values[0];
399 return *this;
400 }
401
402 KOKKOS_FUNCTION constexpr DiscreteVector operator--(int)
403 requires(sizeof...(Tags) == 1)
404 {
405 DiscreteVector const tmp = *this;
406 --m_values[0];
407 return tmp;
408 }
409
410 template <class... OTags>
411 KOKKOS_FUNCTION constexpr DiscreteVector& operator+=(DiscreteVector<OTags...> const& rhs)
412 {
413 static_assert((type_seq_contains_v<detail::TypeSeq<OTags>, tags_seq> && ...));
414 ((m_values[type_seq_rank_v<OTags, tags_seq>] += rhs.template get<OTags>()), ...);
415 return *this;
416 }
417
418 template <std::integral IntegralType>
419 KOKKOS_FUNCTION constexpr DiscreteVector& operator+=(IntegralType const& rhs)
420 requires(sizeof...(Tags) == 1)
421 {
422 m_values[0] += rhs;
423 return *this;
424 }
425
426 template <class... OTags>
427 KOKKOS_FUNCTION constexpr DiscreteVector& operator-=(DiscreteVector<OTags...> const& rhs)
428 {
429 static_assert((type_seq_contains_v<detail::TypeSeq<OTags>, tags_seq> && ...));
430 ((m_values[type_seq_rank_v<OTags, tags_seq>] -= rhs.template get<OTags>()), ...);
431 return *this;
432 }
433
434 template <std::integral IntegralType>
435 KOKKOS_FUNCTION constexpr DiscreteVector& operator-=(IntegralType const& rhs)
436 requires(sizeof...(Tags) == 1)
437 {
438 m_values[0] -= rhs;
439 return *this;
440 }
441
442 template <class... OTags>
443 KOKKOS_FUNCTION constexpr DiscreteVector& operator*=(DiscreteVector<OTags...> const& rhs)
444 {
445 static_assert((type_seq_contains_v<detail::TypeSeq<OTags>, tags_seq> && ...));
446 ((m_values[type_seq_rank_v<OTags, tags_seq>] *= rhs.template get<OTags>()), ...);
447 return *this;
448 }
449};
450
451template <class Tag>
452KOKKOS_FUNCTION constexpr bool operator<(
453 DiscreteVector<Tag> const& lhs,
454 DiscreteVector<Tag> const& rhs)
455{
456 return lhs.value() < rhs.value();
457}
458
459template <class Tag, class IntegralType>
460KOKKOS_FUNCTION constexpr bool operator<(DiscreteVector<Tag> const& lhs, IntegralType const& rhs)
461{
462 return lhs.value() < rhs;
463}
464
465namespace detail {
466
467void print_discrete_vector(std::ostream& os, DiscreteVectorElement const* data, std::size_t n);
468
469} // namespace detail
470
471template <class... Tags>
472std::ostream& operator<<(std::ostream& os, DiscreteVector<Tags...> const& arr)
473{
474 std::array const std_arr = detail::array(arr);
475 detail::print_discrete_vector(os, std_arr.data(), std_arr.size());
476 return os;
477}
478
479} // namespace ddc
friend class ChunkSpan
KOKKOS_FUNCTION constexpr ChunkCommon(ElementType *ptr, SupportType const &domain)
Constructs a new ChunkCommon from scratch.
KOKKOS_FUNCTION constexpr bool is_strided() const noexcept
KOKKOS_DEFAULTED_FUNCTION ~ChunkCommon() noexcept=default
KOKKOS_FUNCTION constexpr ElementType * data_handle() const
Access to the underlying allocation pointer.
KOKKOS_DEFAULTED_FUNCTION constexpr ChunkCommon()=default
Empty ChunkCommon.
allocation_mdspan_type m_allocation_mdspan
The raw view of the data.
KOKKOS_FUNCTION constexpr SupportType domain() const noexcept
Provide access to the domain on which this chunk is defined.
static KOKKOS_FUNCTION constexpr bool is_always_strided() noexcept
KOKKOS_FUNCTION constexpr allocation_mdspan_type allocation_mdspan() const
Provide a modifiable view of the data.
KOKKOS_FUNCTION constexpr ChunkCommon(allocation_mdspan_type allocation_mdspan, SupportType const &domain) noexcept
Constructs a new ChunkCommon from scratch.
KOKKOS_DEFAULTED_FUNCTION constexpr ChunkCommon(ChunkCommon const &other)=default
Constructs a new ChunkCommon by copy, yields a new view to the same data.
static KOKKOS_FUNCTION constexpr bool is_always_unique() noexcept
KOKKOS_FUNCTION constexpr DiscreteDomain< QueryDDims... > domain() const noexcept
Provide access to the domain on which this chunk is defined.
KOKKOS_DEFAULTED_FUNCTION constexpr ChunkCommon & operator=(ChunkCommon const &other)=default
Copy-assigns a new value to this ChunkCommon, yields a new view to the same data.
KOKKOS_DEFAULTED_FUNCTION constexpr ChunkCommon(ChunkCommon &&other) noexcept=default
Constructs a new ChunkCommon by move.
KOKKOS_DEFAULTED_FUNCTION constexpr ChunkCommon & operator=(ChunkCommon &&other) noexcept=default
Move-assigns a new value to this ChunkCommon.
KOKKOS_FUNCTION constexpr size_type extent() const noexcept
KOKKOS_FUNCTION constexpr size_type stride() const
KOKKOS_FUNCTION constexpr bool is_exhaustive() const noexcept
KOKKOS_FUNCTION constexpr mapping_type mapping() const noexcept
static KOKKOS_FUNCTION constexpr int rank() noexcept
KOKKOS_FUNCTION constexpr bool is_unique() const noexcept
KOKKOS_FUNCTION constexpr accessor_type accessor() const
KOKKOS_FUNCTION constexpr SupportType::discrete_vector_type extents() const noexcept
KOKKOS_FUNCTION constexpr size_type size() const noexcept
SupportType m_domain
The mesh on which this chunk is defined.
static KOKKOS_FUNCTION constexpr int rank_dynamic() noexcept
static KOKKOS_FUNCTION constexpr size_type static_extent(std::size_t r) noexcept
static KOKKOS_FUNCTION constexpr bool is_always_exhaustive() noexcept
auto operator[](DiscreteElement< QueryDDims... > const &slice_spec) const
Slice out some dimensions.
Definition chunk.hpp:154
char const * label() const
Returns the label of the Chunk.
Definition chunk.hpp:249
const_allocation_mdspan_type allocation_mdspan() const
Provide a mdspan on the memory allocation.
Definition chunk.hpp:273
ElementType const * data_handle() const
Access to the underlying allocation pointer.
Definition chunk.hpp:257
auto allocation_kokkos_view()
Provide an unmanaged Kokkos::View on the memory allocation.
Definition chunk.hpp:289
auto operator[](DiscreteDomain< QueryDDims... > const &odomain)
Slice out some dimensions.
Definition chunk.hpp:176
auto allocation_kokkos_view() const
Provide an unmanaged Kokkos::View on the memory allocation.
Definition chunk.hpp:305
Chunk(SupportType const &domain, Allocator allocator=Allocator())
Construct a Chunk on a domain with uninitialized values.
Definition chunk.hpp:104
Chunk & operator=(Chunk const &other)=delete
Deleted: use deepcopy instead.
allocation_mdspan_type allocation_mdspan()
Provide a mdspan on the memory allocation.
Definition chunk.hpp:281
ElementType * data_handle()
Access to the underlying allocation pointer.
Definition chunk.hpp:265
view_type span_cview() const
Definition chunk.hpp:318
Chunk(Chunk const &other)=delete
Deleted: use deepcopy instead.
~Chunk() noexcept
Definition chunk.hpp:124
Chunk(std::string const &label, SupportType const &domain, Allocator allocator=Allocator())
Construct a labeled Chunk on a domain with uninitialized values.
Definition chunk.hpp:93
element_type & operator()(DElems const &... delems) noexcept
Element access using a list of DiscreteElement.
Definition chunk.hpp:219
Chunk()=default
Empty Chunk.
Chunk & operator=(Chunk &&other) noexcept
Move-assigns a new value to this field.
Definition chunk.hpp:138
Chunk(Chunk &&other) noexcept
Constructs a new Chunk by move.
Definition chunk.hpp:115
friend class Chunk
Definition chunk.hpp:81
span_type span_view()
Definition chunk.hpp:328
view_type span_view() const
Definition chunk.hpp:323
auto operator[](DiscreteDomain< QueryDDims... > const &odomain) const
Slice out some dimensions.
Definition chunk.hpp:168
element_type const & operator()(DElems const &... delems) const noexcept
Element access using a list of DiscreteElement.
Definition chunk.hpp:187
auto operator[](DiscreteElement< QueryDDims... > const &slice_spec)
Slice out some dimensions.
Definition chunk.hpp:161
static KOKKOS_FUNCTION constexpr discrete_vector_type extents() noexcept
KOKKOS_DEFAULTED_FUNCTION ~DiscreteDomain()=default
KOKKOS_FUNCTION constexpr DiscreteDomain(discrete_element_type const &element_begin, discrete_vector_type const &size)
Construct a DiscreteDomain starting from element_begin with size points.
KOKKOS_FUNCTION constexpr DiscreteDomain(DDoms const &...)
Construct a DiscreteDomain by copies and merge of domains.
KOKKOS_FUNCTION constexpr DiscreteDomain take_last(discrete_vector_type) const
KOKKOS_FUNCTION constexpr bool operator==(DiscreteDomain const &) const
KOKKOS_FUNCTION constexpr DiscreteDomain remove(discrete_vector_type, discrete_vector_type) const
static KOKKOS_FUNCTION constexpr std::size_t rank()
KOKKOS_FUNCTION constexpr DiscreteDomain remove_last(discrete_vector_type) const
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain(DiscreteDomain const &x)=default
static KOKKOS_FUNCTION bool contains() noexcept
KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteDomain()=default
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain & operator=(DiscreteDomain &&x)=default
KOKKOS_FUNCTION constexpr operator bool()
static KOKKOS_FUNCTION constexpr std::size_t size()
static KOKKOS_FUNCTION constexpr bool empty() noexcept
static KOKKOS_FUNCTION bool contains(DiscreteElement<>) noexcept
static KOKKOS_FUNCTION constexpr discrete_element_type back() noexcept
static KOKKOS_FUNCTION DiscreteVector distance_from_front(DiscreteElement<>) noexcept
KOKKOS_FUNCTION constexpr DiscreteDomain remove_first(discrete_vector_type) const
static KOKKOS_FUNCTION constexpr discrete_element_type front() noexcept
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain & operator=(DiscreteDomain const &x)=default
KOKKOS_FUNCTION constexpr DiscreteDomain take_first(discrete_vector_type) const
KOKKOS_FUNCTION constexpr DiscreteDomain restrict_with(DiscreteDomain< ODims... > const &) const
KOKKOS_FUNCTION constexpr DiscreteElement operator()(DiscreteVector<> const &) const noexcept
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain(DiscreteDomain &&x)=default
static KOKKOS_FUNCTION DiscreteVector distance_from_front() noexcept
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain(DiscreteDomain const &x)=default
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain(DiscreteDomain &&x)=default
KOKKOS_FUNCTION constexpr DiscreteDomain remove_last(discrete_vector_type n) const
KOKKOS_FUNCTION bool contains(DElems const &... delems) const noexcept
KOKKOS_FUNCTION constexpr DiscreteDomain take_last(discrete_vector_type n) const
KOKKOS_FUNCTION constexpr DiscreteDomain(DDoms const &... domains)
Construct a DiscreteDomain by copies and merge of domains.
KOKKOS_FUNCTION constexpr decltype(auto) operator[](std::size_t n)
KOKKOS_FUNCTION constexpr DiscreteDomain remove(discrete_vector_type n1, discrete_vector_type n2) const
KOKKOS_FUNCTION constexpr decltype(auto) operator[](std::size_t n) const
KOKKOS_FUNCTION constexpr auto restrict_with(DiscreteDomain< ODDims... > const &odomain) const
static KOKKOS_FUNCTION constexpr std::size_t rank()
KOKKOS_FUNCTION constexpr bool empty() const noexcept
KOKKOS_FUNCTION constexpr std::size_t size() const
friend class DiscreteDomain
KOKKOS_FUNCTION constexpr discrete_vector_type extents() const noexcept
KOKKOS_FUNCTION constexpr DiscreteVector< QueryDDim > extent() const noexcept
KOKKOS_FUNCTION constexpr discrete_element_type front() const noexcept
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain & operator=(DiscreteDomain &&x)=default
KOKKOS_FUNCTION constexpr DiscreteDomain remove_first(discrete_vector_type n) const
KOKKOS_FUNCTION constexpr bool operator==(DiscreteDomain< ODims... > const &other) const
KOKKOS_FUNCTION constexpr DiscreteDomain take_first(discrete_vector_type n) const
KOKKOS_DEFAULTED_FUNCTION ~DiscreteDomain()=default
KOKKOS_FUNCTION DiscreteVector< DDims... > distance_from_front(DElems const &... delems) const noexcept
KOKKOS_FUNCTION constexpr discrete_element_type back() const noexcept
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain & operator=(DiscreteDomain const &x)=default
KOKKOS_FUNCTION constexpr DiscreteElement< DDims... > operator()(DiscreteVector< DDims... > const &dvect) const noexcept
KOKKOS_DEFAULTED_FUNCTION DiscreteDomain()=default
KOKKOS_FUNCTION constexpr operator bool()
KOKKOS_FUNCTION constexpr DiscreteDomain(discrete_element_type const &element_begin, discrete_vector_type const &size)
Construct a DiscreteDomain starting from element_begin with size points.
KOKKOS_FUNCTION constexpr DiscreteElement & operator+=(DiscreteVector< OTags... > const &rhs)
KOKKOS_FUNCTION constexpr value_type const & uid() const noexcept
KOKKOS_FUNCTION constexpr value_type & uid() noexcept
KOKKOS_DEFAULTED_FUNCTION ~DiscreteElement()=default
KOKKOS_FUNCTION constexpr DiscreteElement(DElems const &... delems) noexcept
KOKKOS_FUNCTION constexpr DiscreteElement & operator+=(IntegralType const &rhs)
KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteElement(DiscreteElement const &)=default
KOKKOS_FUNCTION constexpr DiscreteElement operator--(int)
KOKKOS_FUNCTION constexpr DiscreteElement & operator-=(IntegralType const &rhs)
KOKKOS_FUNCTION constexpr DiscreteElement & operator-=(DiscreteVector< OTags... > const &rhs)
KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteElement()=default
KOKKOS_FUNCTION constexpr DiscreteElement operator++(int)
KOKKOS_DEFAULTED_FUNCTION DiscreteElement & operator=(DiscreteElement const &other)=default
static KOKKOS_FUNCTION constexpr std::size_t size() noexcept
KOKKOS_FUNCTION constexpr DiscreteElement(std::array< IntegerType, sizeof...(Tags)> const &values) noexcept
KOKKOS_DEFAULTED_FUNCTION DiscreteElement & operator=(DiscreteElement &&other)=default
KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteElement(DiscreteElement &&)=default
KOKKOS_FUNCTION constexpr DiscreteVectorElement const & get_or(DiscreteVectorElement const &default_value) const &
KOKKOS_FUNCTION constexpr DiscreteVector operator--(int)
KOKKOS_DEFAULTED_FUNCTION ~DiscreteVector()=default
KOKKOS_FUNCTION constexpr DiscreteVectorElement const & get() const noexcept
KOKKOS_FUNCTION constexpr DiscreteVector & operator+=(IntegralType const &rhs)
KOKKOS_FUNCTION constexpr DiscreteVector & operator-=(DiscreteVector< OTags... > const &rhs)
KOKKOS_FUNCTION constexpr DiscreteVector & operator-=(IntegralType const &rhs)
KOKKOS_FUNCTION constexpr DiscreteVector(DVects const &... delems) noexcept
KOKKOS_FUNCTION constexpr bool operator!=(DiscreteVector< OTags... > const &rhs) const noexcept
KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteVector & operator=(DiscreteVector &&other)=default
static KOKKOS_FUNCTION constexpr std::size_t size() noexcept
KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteVector()=default
KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteVector(DiscreteVector const &)=default
KOKKOS_FUNCTION constexpr DiscreteVectorElement & get() noexcept
KOKKOS_FUNCTION constexpr bool operator==(DiscreteVector< OTags... > const &rhs) const noexcept
KOKKOS_FUNCTION constexpr DiscreteVector(std::array< IntegerType, sizeof...(Tags)> const &values) noexcept
KOKKOS_FUNCTION constexpr DiscreteVector & operator*=(DiscreteVector< OTags... > const &rhs)
KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteVector(DiscreteVector &&)=default
KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteVector & operator=(DiscreteVector const &other)=default
KOKKOS_FUNCTION constexpr DiscreteVector operator++(int)
KOKKOS_FUNCTION constexpr DiscreteVector & operator+=(DiscreteVector< OTags... > const &rhs)
The top-level namespace of DDC.
constexpr bool is_borrowed_chunk_v
KOKKOS_FUNCTION constexpr bool operator<(DiscreteElement< Tag > const &lhs, DiscreteElement< Tag > const &rhs)
KOKKOS_FUNCTION auto get_domain(ChunkType const &chunk) noexcept
Access the domain (or subdomain) of a view.
constexpr bool enable_chunk< Chunk< ElementType, SupportType, Allocator > >
Definition chunk.hpp:28
KOKKOS_FUNCTION constexpr DiscreteElement< Tag > operator+(DiscreteElement< Tag > const &lhs, IntegralType const &rhs)
KOKKOS_FUNCTION constexpr DiscreteElement< QueryDDims... > back(DiscreteDomain< DDims... > const &domain) noexcept
constexpr bool enable_borrowed_chunk
constexpr bool enable_chunk
KOKKOS_FUNCTION constexpr bool operator==(DiscreteElement< Tags... > const &lhs, DiscreteElement< OTags... > const &rhs) noexcept
KOKKOS_FUNCTION constexpr DiscreteVector< Tags... > operator+(DiscreteVector< Tags... > const &x)
Unary operators: +, -.
KOKKOS_FUNCTION constexpr DiscreteElement< QueryTags... > select(DiscreteElement< Tags... > &&arr) noexcept
constexpr DiscreteElement< DDim > create_reference_discrete_element() noexcept
constexpr bool is_chunk_v
KOKKOS_FUNCTION constexpr DiscreteElement< QueryTags... > select(DiscreteElement< Tags... > const &arr) noexcept
KOKKOS_FUNCTION constexpr auto const & take(HeadDElem const &head, TailDElems const &... tail)
Returns a reference towards the DiscreteElement that contains the QueryTag.
KOKKOS_FUNCTION constexpr DiscreteVector< Tag > operator-(IntegralType const &lhs, DiscreteVector< Tag > const &rhs)
KOKKOS_FUNCTION constexpr auto remove_dims_of(DiscreteDomain< DDimsA... > const &DDom_a, DiscreteDomain< DDimsB... > const &) noexcept
KOKKOS_FUNCTION constexpr bool operator<(DiscreteVector< Tag > const &lhs, IntegralType const &rhs)
KOKKOS_FUNCTION constexpr DiscreteVectorElement const & get_or(DiscreteVector< Tags... > const &tuple, DiscreteVectorElement const &default_value) noexcept
KOKKOS_FUNCTION constexpr auto operator-(DiscreteVector< Tags... > const &lhs, DiscreteVector< OTags... > const &rhs)
KOKKOS_FUNCTION constexpr auto remove_dims_of(DiscreteDomain< DDimsA... > const &DDom_a) noexcept
Remove the dimensions DDimsB from DDom_a.
KOKKOS_FUNCTION constexpr DiscreteVector< Tags... > operator-(DiscreteElement< Tags... > const &lhs, DiscreteElement< OTags... > const &rhs)
binary operator: -
KOKKOS_FUNCTION constexpr DiscreteElement< QueryDDims... > front(DiscreteDomain< DDims... > const &domain) noexcept
KOKKOS_FUNCTION constexpr DiscreteVectorElement & get(DiscreteVector< Tags... > &tuple) noexcept
KOKKOS_FUNCTION constexpr DiscreteElement< QueryTag > select_or(DiscreteElement< Tags... > const &arr, DiscreteElement< QueryTag > const &default_value) noexcept
constexpr bool is_writable_chunk_v
KOKKOS_FUNCTION constexpr DiscreteVector< Tag > operator+(IntegralType const &lhs, DiscreteVector< Tag > const &rhs)
constexpr bool is_discrete_vector_v
KOKKOS_FUNCTION constexpr DiscreteElementType const & uid(DiscreteElement< Tag > const &tuple) noexcept
KOKKOS_FUNCTION constexpr DiscreteElement< Tags... > operator+(DiscreteElement< Tags... > const &lhs, DiscreteVector< OTags... > const &rhs)
right external binary operators: +, -
KOKKOS_FUNCTION constexpr DiscreteVectorElement const & get(DiscreteVector< Tags... > const &tuple) noexcept
KOKKOS_FUNCTION constexpr DiscreteVector< Tags... > operator-(DiscreteVector< Tags... > const &x)
constexpr bool is_discrete_element_v
KOKKOS_FUNCTION constexpr DiscreteVector< QueryTags... > select(DiscreteVector< Tags... > const &arr) noexcept
KOKKOS_FUNCTION constexpr DiscreteVector< QueryDDims... > extents(DiscreteDomain< DDims... > const &domain) noexcept
Chunk(SupportType const &, Allocator) -> Chunk< typename Allocator::value_type, SupportType, Allocator >
KOKKOS_FUNCTION constexpr bool operator>=(DiscreteElement< Tag > const &lhs, DiscreteElement< Tag > const &rhs)
KOKKOS_FUNCTION constexpr auto operator+(DiscreteVector< Tags... > const &lhs, DiscreteVector< OTags... > const &rhs)
Internal binary operators: +, -.
KOKKOS_FUNCTION constexpr auto replace_dim_of(DiscreteDomain< DDimsA... > const &DDom_a, DiscreteDomain< DDimsB... > const &DDom_b) noexcept
KOKKOS_FUNCTION constexpr bool operator<=(DiscreteElement< Tag > const &lhs, DiscreteElement< Tag > const &rhs)
KOKKOS_FUNCTION constexpr bool operator<(DiscreteVector< Tag > const &lhs, DiscreteVector< Tag > const &rhs)
KOKKOS_FUNCTION constexpr DiscreteElementType & uid(DiscreteElement< Tags... > &tuple) noexcept
Chunk(std::string const &, SupportType const &, Allocator) -> Chunk< typename Allocator::value_type, SupportType, Allocator >
KOKKOS_FUNCTION constexpr DiscreteVector< QueryTag > select_or(DiscreteVector< Tags... > const &arr, DiscreteVector< QueryTag > const &default_value) noexcept
KOKKOS_FUNCTION constexpr bool operator>(DiscreteElement< Tag > const &lhs, DiscreteElement< Tag > const &rhs)
KOKKOS_FUNCTION constexpr DiscreteElementType & uid(DiscreteElement< Tag > &tuple) noexcept
constexpr bool is_discrete_domain_v
KOKKOS_FUNCTION constexpr DiscreteVector< QueryTags... > select(DiscreteVector< Tags... > &&arr) noexcept
KOKKOS_FUNCTION constexpr DiscreteElement< Tag > operator-(DiscreteElement< Tag > const &lhs, IntegralType const &rhs)
KOKKOS_FUNCTION constexpr DiscreteElement< Tags... > operator-(DiscreteElement< Tags... > const &lhs, DiscreteVector< OTags... > const &rhs)
KOKKOS_FUNCTION constexpr DiscreteElementType const & uid(DiscreteElement< Tags... > const &tuple) noexcept
KOKKOS_FUNCTION constexpr auto operator*(IntegralType const &lhs, DiscreteVector< Tags... > const &rhs)
external left binary operator: *
KOKKOS_FUNCTION constexpr DiscreteDomain< QueryDDims... > select(DiscreteDomain< DDims... > const &domain)
KOKKOS_FUNCTION constexpr DiscreteVector< Tag > operator-(DiscreteVector< Tag > const &lhs, IntegralType const &rhs)
KOKKOS_FUNCTION constexpr DiscreteVector< Tag > operator+(DiscreteVector< Tag > const &lhs, IntegralType const &rhs)
KOKKOS_FUNCTION constexpr DiscreteDomainIterator operator--(int)
friend KOKKOS_FUNCTION constexpr bool operator<=(DiscreteDomainIterator const &xx, DiscreteDomainIterator const &yy)
KOKKOS_FUNCTION constexpr DiscreteElement< DDim > operator*() const noexcept
friend KOKKOS_FUNCTION constexpr bool operator>=(DiscreteDomainIterator const &xx, DiscreteDomainIterator const &yy)
KOKKOS_DEFAULTED_FUNCTION DiscreteDomainIterator()=default
KOKKOS_FUNCTION constexpr DiscreteElement< DDim > operator[](difference_type n) const
KOKKOS_FUNCTION constexpr DiscreteDomainIterator & operator--()
KOKKOS_FUNCTION constexpr DiscreteDomainIterator operator++(int)
friend KOKKOS_FUNCTION constexpr DiscreteDomainIterator operator-(DiscreteDomainIterator i, difference_type n)
friend KOKKOS_FUNCTION constexpr DiscreteDomainIterator operator+(DiscreteDomainIterator i, difference_type n)
friend KOKKOS_FUNCTION constexpr bool operator>(DiscreteDomainIterator const &xx, DiscreteDomainIterator const &yy)
friend KOKKOS_FUNCTION constexpr bool operator!=(DiscreteDomainIterator const &xx, DiscreteDomainIterator const &yy)
friend KOKKOS_FUNCTION constexpr bool operator<(DiscreteDomainIterator const &xx, DiscreteDomainIterator const &yy)
KOKKOS_FUNCTION constexpr DiscreteDomainIterator & operator+=(difference_type n)
KOKKOS_FUNCTION constexpr DiscreteDomainIterator & operator++()
friend KOKKOS_FUNCTION constexpr DiscreteDomainIterator operator+(difference_type n, DiscreteDomainIterator i)
friend KOKKOS_FUNCTION constexpr bool operator==(DiscreteDomainIterator const &xx, DiscreteDomainIterator const &yy)
KOKKOS_FUNCTION constexpr DiscreteDomainIterator(DiscreteElement< DDim > value)
KOKKOS_FUNCTION constexpr DiscreteDomainIterator & operator-=(difference_type n)
friend KOKKOS_FUNCTION constexpr difference_type operator-(DiscreteDomainIterator const &xx, DiscreteDomainIterator const &yy)