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