DDC 0.13.0
Loading...
Searching...
No Matches
sparse_discrete_domain.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 <cstddef>
8#include <functional>
9#include <iterator>
10#include <string>
11#include <tuple>
12#include <type_traits>
13
14#include <Kokkos_Core.hpp>
15
16#include "detail/tagged_vector.hpp"
17#include "detail/type_seq.hpp"
18
21
22namespace ddc {
23
24template <class... DDims>
26
27template <class T>
28struct is_sparse_discrete_domain : std::false_type
29{
30};
31
32template <class... Tags>
33struct is_sparse_discrete_domain<SparseDiscreteDomain<Tags...>> : std::true_type
34{
35};
36
37template <class T>
39
40namespace concepts {
41
42template <class T>
43concept sparse_discrete_domain = is_sparse_discrete_domain_v<T>;
44
45}
46
47namespace detail {
48
49template <class... Tags>
50struct ToTypeSeq<SparseDiscreteDomain<Tags...>>
51{
52 using type = TypeSeq<Tags...>;
53};
54
55template <class... DDims, class... ODDims>
56struct Rebind<SparseDiscreteDomain<DDims...>, detail::TypeSeq<ODDims...>>
57{
58 using type = SparseDiscreteDomain<ODDims...>;
59};
60
61template <class InputIt1, class InputIt2>
62KOKKOS_FUNCTION bool equal(InputIt1 first1, InputIt1 last1, InputIt2 first2)
63{
64 for (; first1 != last1; ++first1, ++first2) {
65 if (!(*first1 == *first2)) {
66 return false;
67 }
68 }
69
70 return true;
71}
72
73template <class ForwardIt, class T = std::iterator_traits<ForwardIt>::value_type, class Compare>
74KOKKOS_FUNCTION ForwardIt lower_bound(ForwardIt first, ForwardIt last, T const& value, Compare comp)
75{
76 ForwardIt it;
77 typename std::iterator_traits<ForwardIt>::difference_type count = last - first;
78 while (count > 0) {
79 it = first;
80 typename std::iterator_traits<ForwardIt>::difference_type const step = count / 2;
81 it += step;
82
83 if (comp(*it, value)) {
84 first = ++it;
85 count -= step + 1;
86 } else {
87 count = step;
88 }
89 }
90
91 return first;
92}
93
94template <class ForwardIt, class T = std::iterator_traits<ForwardIt>::value_type, class Compare>
95KOKKOS_FUNCTION bool binary_search(ForwardIt first, ForwardIt last, T const& value, Compare comp)
96{
97 first = ::ddc::detail::lower_bound(first, last, value, comp);
98 return (!(first == last) && !(comp(value, *first)));
99}
100
101template <class DDim>
102Kokkos::View<DiscreteElementType*, Kokkos::SharedSpace> extract_uid(
103 Kokkos::DefaultExecutionSpace const& exec_space,
104 Kokkos::View<DiscreteElement<DDim>*, Kokkos::SharedSpace> const& input)
105{
106 Kokkos::View<DiscreteElementType*, Kokkos::SharedSpace> output(input.label(), input.size());
107 Kokkos::parallel_for(
108 "SparseDiscreteDomainCtor",
109 Kokkos::RangePolicy<
110 Kokkos::DefaultExecutionSpace,
111 Kokkos::IndexType<std::size_t>>(exec_space, 0, output.size()),
112 KOKKOS_LAMBDA(std::size_t const i) { output(i) = input(i).uid(); });
113 return output;
114}
115
116} // namespace detail
117
118template <class... DDims>
120{
121 template <class...>
122 friend class SparseDiscreteDomain;
123
124 static_assert(
125 type_seq_is_unique_v<detail::TypeSeq<DDims...>>,
126 "The dimensions of a SparseDiscreteDomain must be unique");
127
128public:
129 using discrete_element_type = DiscreteElement<DDims...>;
130
131 using discrete_vector_type = DiscreteVector<DDims...>;
132
133private:
134 detail::TaggedVector<Kokkos::View<DiscreteElementType*, Kokkos::SharedSpace>, DDims...> m_views;
135
136public:
137 static KOKKOS_FUNCTION constexpr std::size_t rank()
138 {
139 return sizeof...(DDims);
140 }
141
142 KOKKOS_DEFAULTED_FUNCTION SparseDiscreteDomain() = default;
143
144 /// Construct a SparseDiscreteDomain by copies and merge of domains
145 template <concepts::sparse_discrete_domain... DDoms>
146 KOKKOS_FUNCTION constexpr explicit SparseDiscreteDomain(DDoms const&... domains)
147 : m_views(domains.m_views...)
148 {
149 }
150
151 /** Construct a SparseDiscreteDomain with Kokkos::View explicitly listing the discrete elements.
152 * @param views list of Kokkos::View
153 */
154 explicit SparseDiscreteDomain(
155 Kokkos::View<DiscreteElement<DDims>*, Kokkos::SharedSpace> const&... views)
156 {
157 Kokkos::DefaultExecutionSpace const exec_space;
158 ((m_views[type_seq_rank_v<DDims, detail::TypeSeq<DDims...>>]
159 = detail::extract_uid(exec_space, views)),
160 ...);
161 exec_space.fence("SparseDiscreteDomainCtor");
162 }
163
164 KOKKOS_DEFAULTED_FUNCTION SparseDiscreteDomain(SparseDiscreteDomain const& x) = default;
165
166 KOKKOS_DEFAULTED_FUNCTION SparseDiscreteDomain(SparseDiscreteDomain&& x) = default;
167
168 KOKKOS_DEFAULTED_FUNCTION ~SparseDiscreteDomain() = default;
169
170 KOKKOS_DEFAULTED_FUNCTION SparseDiscreteDomain& operator=(SparseDiscreteDomain const& x)
171 = default;
172
173 KOKKOS_DEFAULTED_FUNCTION SparseDiscreteDomain& operator=(SparseDiscreteDomain&& x) = default;
174
175 template <class... ODims>
176 KOKKOS_FUNCTION constexpr bool operator==(SparseDiscreteDomain<ODims...> const& other) const
177 {
178 if constexpr ((std::is_same_v<DDims, ODims> && ...)) {
179 if (empty() && other.empty()) {
180 return true;
181 }
182 for (std::size_t i = 0; i < m_views.size(); ++i) {
183 if (m_views[i].size() != other.m_views[i].size()) {
184 return false;
185 }
186 if (!detail::
187 equal(m_views[i].data(),
188 m_views[i].data() + m_views[i].size(),
189 other.m_views[i].data())) {
190 return false;
191 }
192 }
193 return true;
194 } else {
195 return *this == SparseDiscreteDomain(other);
196 }
197 }
198
199#if !defined(__cpp_impl_three_way_comparison) || __cpp_impl_three_way_comparison < 201902L
200 // In C++20, `a!=b` shall be automatically translated by the compiler to `!(a==b)`
201 template <class... ODims>
202 KOKKOS_FUNCTION constexpr bool operator!=(SparseDiscreteDomain<ODims...> const& other) const
203 {
204 return !(*this == other);
205 }
206#endif
207
208 KOKKOS_FUNCTION constexpr std::size_t size() const
209 {
210 return (1UL * ... * get<DDims>(m_views).size());
211 }
212
213 KOKKOS_FUNCTION constexpr discrete_vector_type extents() const noexcept
214 {
215 return discrete_vector_type(get<DDims>(m_views).size()...);
216 }
217
218 KOKKOS_FUNCTION constexpr auto discrete_elements() const noexcept
219 {
220 return m_views;
221 }
222
223 template <class QueryDDim>
224 KOKKOS_FUNCTION constexpr DiscreteVector<QueryDDim> extent() const noexcept
225 {
226 return DiscreteVector<QueryDDim>(get<QueryDDim>(m_views).size());
227 }
228
229 KOKKOS_FUNCTION constexpr discrete_element_type front() const noexcept
230 {
231 return discrete_element_type(get<DDims>(m_views)(0)...);
232 }
233
234 KOKKOS_FUNCTION constexpr discrete_element_type back() const noexcept
235 {
236 return discrete_element_type(get<DDims>(m_views)(get<DDims>(m_views).size() - 1)...);
237 }
238
239 KOKKOS_FUNCTION constexpr SparseDiscreteDomain take_first(discrete_vector_type n) const
240 {
241 return SparseDiscreteDomain(front(), n);
242 }
243
244 KOKKOS_FUNCTION constexpr SparseDiscreteDomain take_last(discrete_vector_type n) const
245 {
246 return SparseDiscreteDomain(front() + prod(extents() - n), n);
247 }
248
249 KOKKOS_FUNCTION constexpr SparseDiscreteDomain remove_first(discrete_vector_type n) const
250 {
251 return SparseDiscreteDomain(front() + prod(n), extents() - n);
252 }
253
254 KOKKOS_FUNCTION constexpr SparseDiscreteDomain remove_last(discrete_vector_type n) const
255 {
257 }
258
259 KOKKOS_FUNCTION constexpr SparseDiscreteDomain remove(
260 discrete_vector_type n1,
261 discrete_vector_type n2) const
262 {
263 return SparseDiscreteDomain(front() + prod(n1), extents() - n1 - n2);
264 }
265
266 KOKKOS_FUNCTION constexpr DiscreteElement<DDims...> operator()(
267 DiscreteVector<DDims...> const& dvect) const noexcept
268 {
269 return DiscreteElement<DDims...>(get<DDims>(m_views)(get<DDims>(dvect))...);
270 }
271
272 template <class... DElems>
273 KOKKOS_FUNCTION bool contains(DElems const&... delems) const noexcept
274 {
275 static_assert(
276 sizeof...(DDims) == (0 + ... + DElems::size()),
277 "Invalid number of dimensions");
278 static_assert((is_discrete_element_v<DElems> && ...), "Expected DiscreteElements");
279 DiscreteElement<DDims...> const delem(delems...);
280 for (std::size_t i = 0; i < rank(); ++i) {
281 if (!detail::binary_search(
282 m_views[i].data(),
283 m_views[i].data() + m_views[i].size(),
284 detail::array(delem)[i],
285 std::less {})) {
286 return false;
287 }
288 }
289 return true;
290 }
291
292 template <class... DElems>
293 KOKKOS_FUNCTION DiscreteVector<DDims...> distance_from_front(
294 DElems const&... delems) const noexcept
295 {
296 static_assert(
297 sizeof...(DDims) == (0 + ... + DElems::size()),
298 "Invalid number of dimensions");
299 static_assert((is_discrete_element_v<DElems> && ...), "Expected DiscreteElements");
300 KOKKOS_ASSERT(contains(delems...))
301 return DiscreteVector<DDims...>(
302 (detail::lower_bound(
303 get<DDims>(m_views).data(),
304 get<DDims>(m_views).data() + get<DDims>(m_views).size(),
305 uid<DDims>(take<DDims>(delems...)),
306 std::less {})
307 - get<DDims>(m_views).data())...);
308 }
309
310 KOKKOS_FUNCTION constexpr bool empty() const noexcept
311 {
312 return size() == 0;
313 }
314
315 KOKKOS_FUNCTION constexpr explicit operator bool()
316 {
317 return !empty();
318 }
319
320 KOKKOS_FUNCTION auto begin() const
321 requires(sizeof...(DDims) == 1)
322 {
323 using DDim0 = std::tuple_element_t<0, std::tuple<DDims...>>;
324 return get<DDim0>(m_views).data();
325 }
326
327 KOKKOS_FUNCTION auto end() const
328 requires(sizeof...(DDims) == 1)
329 {
330 using DDim0 = std::tuple_element_t<0, std::tuple<DDims...>>;
331 return get<DDim0>(m_views).data() + get<DDim0>(m_views).size();
332 }
333
334 KOKKOS_FUNCTION auto cbegin() const
335 requires(sizeof...(DDims) == 1)
336 {
337 using DDim0 = std::tuple_element_t<0, std::tuple<DDims...>>;
338 return get<DDim0>(m_views).data();
339 }
340
341 KOKKOS_FUNCTION auto cend() const
342 requires(sizeof...(DDims) == 1)
343 {
344 using DDim0 = std::tuple_element_t<0, std::tuple<DDims...>>;
345 return get<DDim0>(m_views).data() + get<DDim0>(m_views).size();
346 }
347
348 KOKKOS_FUNCTION constexpr decltype(auto) operator[](std::size_t n)
349 requires(sizeof...(DDims) == 1)
350 {
351 return begin()[n];
352 }
353
354 KOKKOS_FUNCTION constexpr decltype(auto) operator[](std::size_t n) const
355 requires(sizeof...(DDims) == 1)
356 {
357 return begin()[n];
358 }
359};
360
361template <>
363{
364 template <class...>
365 friend class SparseDiscreteDomain;
366
367public:
368 using discrete_element_type = DiscreteElement<>;
369
370 using discrete_vector_type = DiscreteVector<>;
371
372 static KOKKOS_FUNCTION constexpr std::size_t rank()
373 {
374 return 0;
375 }
376
377 KOKKOS_DEFAULTED_FUNCTION constexpr SparseDiscreteDomain() = default;
378
379 // Construct a SparseDiscreteDomain from a reordered copy of `domain`
380 template <class... ODDims>
381 KOKKOS_FUNCTION constexpr explicit SparseDiscreteDomain(
382 SparseDiscreteDomain<ODDims...> const& /*domain*/)
383 {
384 }
385
386 KOKKOS_DEFAULTED_FUNCTION SparseDiscreteDomain(SparseDiscreteDomain const& x) = default;
387
388 KOKKOS_DEFAULTED_FUNCTION SparseDiscreteDomain(SparseDiscreteDomain&& x) = default;
389
390 KOKKOS_DEFAULTED_FUNCTION ~SparseDiscreteDomain() = default;
391
392 KOKKOS_DEFAULTED_FUNCTION SparseDiscreteDomain& operator=(SparseDiscreteDomain const& x)
393 = default;
394
395 KOKKOS_DEFAULTED_FUNCTION SparseDiscreteDomain& operator=(SparseDiscreteDomain&& x) = default;
396
397 KOKKOS_FUNCTION constexpr bool operator==(SparseDiscreteDomain const& /*other*/) const
398 {
399 return true;
400 }
401
402#if !defined(__cpp_impl_three_way_comparison) || __cpp_impl_three_way_comparison < 201902L
403 // In C++20, `a!=b` shall be automatically translated by the compiler to `!(a==b)`
404 KOKKOS_FUNCTION constexpr bool operator!=(SparseDiscreteDomain const& other) const
405 {
406 return !(*this == other);
407 }
408#endif
409
410 static KOKKOS_FUNCTION constexpr std::size_t size()
411 {
412 return 1;
413 }
414
415 static KOKKOS_FUNCTION constexpr discrete_vector_type extents() noexcept
416 {
417 return {};
418 }
419
420 static KOKKOS_FUNCTION constexpr discrete_element_type front() noexcept
421 {
422 return {};
423 }
424
425 static KOKKOS_FUNCTION constexpr discrete_element_type back() noexcept
426 {
427 return {};
428 }
429
430 KOKKOS_FUNCTION constexpr SparseDiscreteDomain take_first(discrete_vector_type /*n*/) const
431 {
432 return *this;
433 }
434
435 KOKKOS_FUNCTION constexpr SparseDiscreteDomain take_last(discrete_vector_type /*n*/) const
436 {
437 return *this;
438 }
439
440 KOKKOS_FUNCTION constexpr SparseDiscreteDomain remove_first(discrete_vector_type /*n*/) const
441 {
442 return *this;
443 }
444
445 KOKKOS_FUNCTION constexpr SparseDiscreteDomain remove_last(discrete_vector_type /*n*/) const
446 {
447 return *this;
448 }
449
450 KOKKOS_FUNCTION constexpr SparseDiscreteDomain remove(
451 discrete_vector_type /*n1*/,
452 discrete_vector_type /*n2*/) const
453 {
454 return *this;
455 }
456
457 KOKKOS_FUNCTION constexpr DiscreteElement<> operator()(
458 DiscreteVector<> const& /*dvect*/) const noexcept
459 {
460 return {};
461 }
462
463 static KOKKOS_FUNCTION bool contains() noexcept
464 {
465 return true;
466 }
467
468 static KOKKOS_FUNCTION bool contains(DiscreteElement<>) noexcept
469 {
470 return true;
471 }
472
473 static KOKKOS_FUNCTION DiscreteVector<> distance_from_front() noexcept
474 {
475 return {};
476 }
477
478 static KOKKOS_FUNCTION DiscreteVector<> distance_from_front(DiscreteElement<>) noexcept
479 {
480 return {};
481 }
482
483 static KOKKOS_FUNCTION constexpr bool empty() noexcept
484 {
485 return false;
486 }
487
488 KOKKOS_FUNCTION constexpr explicit operator bool()
489 {
490 return true;
491 }
492};
493
494template <class... QueryDDims, class... DDims>
495KOKKOS_FUNCTION constexpr SparseDiscreteDomain<QueryDDims...> select(
496 SparseDiscreteDomain<DDims...> const& domain)
497{
498 return SparseDiscreteDomain<QueryDDims...>(domain);
499}
500
501namespace detail {
502
503template <class T>
504struct ConvertTypeSeqToSparseDiscreteDomain
505{
506};
507
508template <class... DDims>
509struct ConvertTypeSeqToSparseDiscreteDomain<detail::TypeSeq<DDims...>>
510{
511 using type = SparseDiscreteDomain<DDims...>;
512};
513
514template <class T>
515using convert_type_seq_to_sparse_discrete_domain_t = ConvertTypeSeqToSparseDiscreteDomain<T>::type;
516
517} // namespace detail
518
519// Computes the subtraction DDom_a - DDom_b in the sense of linear spaces(retained dimensions are those in DDom_a which are not in DDom_b)
520template <class... DDimsA, class... DDimsB>
521KOKKOS_FUNCTION constexpr auto remove_dims_of(
522 SparseDiscreteDomain<DDimsA...> const& DDom_a,
523 SparseDiscreteDomain<DDimsB...> const& /*DDom_b*/) noexcept
524{
525 using TagSeqA = detail::TypeSeq<DDimsA...>;
526 using TagSeqB = detail::TypeSeq<DDimsB...>;
527
528 using type_seq_r = type_seq_remove_t<TagSeqA, TagSeqB>;
529 return detail::convert_type_seq_to_sparse_discrete_domain_t<type_seq_r>(DDom_a);
530}
531
532//! Remove the dimensions DDimsB from DDom_a
533//! @param[in] DDom_a The discrete domain on which to remove dimensions
534//! @return The discrete domain without DDimsB dimensions
535template <class... DDimsB, class... DDimsA>
536KOKKOS_FUNCTION constexpr auto remove_dims_of(
537 SparseDiscreteDomain<DDimsA...> const& DDom_a) noexcept
538{
539 using TagSeqA = detail::TypeSeq<DDimsA...>;
540 using TagSeqB = detail::TypeSeq<DDimsB...>;
541
542 using type_seq_r = type_seq_remove_t<TagSeqA, TagSeqB>;
543 return detail::convert_type_seq_to_sparse_discrete_domain_t<type_seq_r>(DDom_a);
544}
545
546namespace detail {
547
548// Checks if dimension of DDom_a is DDim1. If not, returns restriction to DDim2 of DDom_b. May not be useful in its own, it helps for replace_dim_of
549template <typename DDim1, typename DDim2, typename DDimA, typename... DDimsB>
550KOKKOS_FUNCTION constexpr std::conditional_t<
551 std::is_same_v<DDimA, DDim1>,
554replace_dim_of_1d(
555 [[maybe_unused]] SparseDiscreteDomain<DDimA> const& DDom_a,
556 [[maybe_unused]] SparseDiscreteDomain<DDimsB...> const& DDom_b) noexcept
557{
558 if constexpr (std::is_same_v<DDimA, DDim1>) {
559 return ddc::SparseDiscreteDomain<DDim2>(DDom_b);
560 } else {
561 return DDom_a;
562 }
563}
564
565} // namespace detail
566
567// Replace in DDom_a the dimension Dim1 by the dimension Dim2 of DDom_b
568template <typename DDim1, typename DDim2, typename... DDimsA, typename... DDimsB>
569KOKKOS_FUNCTION constexpr auto replace_dim_of(
570 SparseDiscreteDomain<DDimsA...> const& DDom_a,
571 [[maybe_unused]] SparseDiscreteDomain<DDimsB...> const& DDom_b) noexcept
572{
573 // TODO : static_asserts
574 using TagSeqA = detail::TypeSeq<DDimsA...>;
575 using TagSeqB = detail::TypeSeq<DDim1>;
576 using TagSeqC = detail::TypeSeq<DDim2>;
577
578 using type_seq_r = ddc::type_seq_replace_t<TagSeqA, TagSeqB, TagSeqC>;
579 return ddc::detail::convert_type_seq_to_sparse_discrete_domain_t<type_seq_r>(
580 detail::replace_dim_of_1d<
581 DDim1,
582 DDim2,
583 DDimsA,
584 DDimsB...>(ddc::SparseDiscreteDomain<DDimsA>(DDom_a), DDom_b)...);
585}
586
587template <class... QueryDDims, class... DDims>
588KOKKOS_FUNCTION constexpr DiscreteVector<QueryDDims...> extents(
589 SparseDiscreteDomain<DDims...> const& domain) noexcept
590{
591 return DiscreteVector<QueryDDims...>(SparseDiscreteDomain<QueryDDims>(domain).size()...);
592}
593
594template <class... QueryDDims, class... DDims>
595KOKKOS_FUNCTION constexpr DiscreteElement<QueryDDims...> front(
596 SparseDiscreteDomain<DDims...> const& domain) noexcept
597{
598 return DiscreteElement<QueryDDims...>(SparseDiscreteDomain<QueryDDims>(domain).front()...);
599}
600
601template <class... QueryDDims, class... DDims>
602KOKKOS_FUNCTION constexpr DiscreteElement<QueryDDims...> back(
603 SparseDiscreteDomain<DDims...> const& domain) noexcept
604{
605 return DiscreteElement<QueryDDims...>(SparseDiscreteDomain<QueryDDims>(domain).back()...);
606}
607
608} // namespace ddc
friend class DiscreteDomain
KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteElement()=default
KOKKOS_FUNCTION constexpr bool operator!=(DiscreteVector< OTags... > const &rhs) const noexcept
KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteVector()=default
KOKKOS_FUNCTION std::size_t size() const
KOKKOS_FUNCTION Coordinate< CDim > coordinate(discrete_element_type const &icoord) const noexcept
Convert a mesh index into a position in CDim
Impl(Impl< DDim, OriginMemorySpace > const &impl)
Impl & operator=(Impl &&x)=default
Impl & operator=(Impl const &x)=delete
Impl(InputIt const points_begin, InputIt const points_end)
Construct a NonUniformPointSampling using a pair of iterators.
KOKKOS_FUNCTION discrete_element_type front() const noexcept
Lower bound index of the mesh.
Impl(InputRange const &points)
Construct a NonUniformPointSampling using a C++20 "common range".
Impl(std::initializer_list< Coordinate< CDim > > const points)
Construct a NonUniformPointSampling using a brace-list, i.e. NonUniformPointSampling mesh({0....
NonUniformPointSampling models a non-uniform discretization of the CDim segment .
static std::tuple< typename DDim::template Impl< DDim, Kokkos::HostSpace >, DiscreteDomain< DDim > > init(InputRange const &non_uniform_points)
Construct an Impl<Kokkos::HostSpace> and associated discrete_domain_type from a range containing the ...
static std::tuple< typename DDim::template Impl< DDim, Kokkos::HostSpace >, DiscreteDomain< DDim >, DiscreteDomain< DDim >, DiscreteDomain< DDim >, DiscreteDomain< DDim > > init_ghosted(InputRange const &domain_r, InputRange const &pre_ghost_r, InputRange const &post_ghost_r)
Construct 4 non-uniform DiscreteDomain and an Impl<Kokkos::HostSpace> from 3 ranges containing the po...
Impl & operator=(Impl &&x)=default
KOKKOS_FUNCTION Coordinate< CDim > origin() const noexcept
Lower bound index of the mesh.
KOKKOS_FUNCTION discrete_element_type front() const noexcept
Lower bound index of the mesh.
KOKKOS_FUNCTION Coordinate< CDim > coordinate(discrete_element_type const &icoord) const noexcept
Convert a mesh index into a position in CDim
Impl(Impl const &)=delete
KOKKOS_FUNCTION std::size_t n_period() const
Number of steps in a period.
Impl(Impl< DDim, OriginMemorySpace > const &impl)
Impl(Coordinate< CDim > origin, Real step, std::size_t n_period)
Construct a Impl from a point and a spacing step.
KOKKOS_FUNCTION Real step() const
Spacing step of the mesh.
Impl & operator=(Impl const &x)=delete
PeriodicSampling models a periodic discretization of the provided continuous dimension.
static std::tuple< typename DDim::template Impl< DDim, Kokkos::HostSpace >, DiscreteDomain< DDim > > init(Coordinate< CDim > a, Coordinate< CDim > b, DiscreteVector< DDim > n, DiscreteVector< DDim > n_period)
Construct a Impl<Kokkos::HostSpace> and associated discrete_domain_type from a segment and a number ...
std::tuple< Impl< DDim, Kokkos::HostSpace >, DiscreteDomain< DDim >, DiscreteDomain< DDim >, DiscreteDomain< DDim >, DiscreteDomain< DDim > > init_ghosted(Coordinate< CDim > a, Coordinate< CDim > b, DiscreteVector< DDim > n, DiscreteVector< DDim > n_period, DiscreteVector< DDim > n_ghosts_before, DiscreteVector< DDim > n_ghosts_after)
Construct a periodic DiscreteDomain from a segment and a number of points n.
std::tuple< Impl< DDim, Kokkos::HostSpace >, DiscreteDomain< DDim >, DiscreteDomain< DDim >, DiscreteDomain< DDim >, DiscreteDomain< DDim > > init_ghosted(Coordinate< CDim > a, Coordinate< CDim > b, DiscreteVector< DDim > n, DiscreteVector< DDim > n_period, DiscreteVector< DDim > n_ghosts)
Construct a periodic DiscreteDomain from a segment and a number of points n.
ScopeGuard & operator=(ScopeGuard const &x)=delete
~ScopeGuard() noexcept
ScopeGuard(int argc, char **&argv)
ScopeGuard(ScopeGuard &&x) noexcept=delete
ScopeGuard & operator=(ScopeGuard &&x) noexcept=delete
ScopeGuard(ScopeGuard const &x)=delete
static KOKKOS_FUNCTION bool contains(DiscreteElement<>) noexcept
KOKKOS_FUNCTION constexpr SparseDiscreteDomain remove(discrete_vector_type, discrete_vector_type) const
KOKKOS_FUNCTION constexpr SparseDiscreteDomain take_first(discrete_vector_type) const
static KOKKOS_FUNCTION constexpr std::size_t rank()
KOKKOS_DEFAULTED_FUNCTION constexpr SparseDiscreteDomain()=default
KOKKOS_FUNCTION constexpr DiscreteElement operator()(DiscreteVector<> const &) const noexcept
KOKKOS_FUNCTION constexpr SparseDiscreteDomain remove_last(discrete_vector_type) const
static KOKKOS_FUNCTION DiscreteVector distance_from_front() noexcept
static KOKKOS_FUNCTION constexpr std::size_t size()
static KOKKOS_FUNCTION constexpr bool empty() noexcept
static KOKKOS_FUNCTION DiscreteVector distance_from_front(DiscreteElement<>) noexcept
KOKKOS_FUNCTION constexpr bool operator==(SparseDiscreteDomain const &) const
static KOKKOS_FUNCTION constexpr discrete_element_type back() noexcept
static KOKKOS_FUNCTION bool contains() noexcept
KOKKOS_FUNCTION constexpr SparseDiscreteDomain take_last(discrete_vector_type) const
KOKKOS_FUNCTION constexpr operator bool()
KOKKOS_DEFAULTED_FUNCTION SparseDiscreteDomain & operator=(SparseDiscreteDomain const &x)=default
KOKKOS_DEFAULTED_FUNCTION SparseDiscreteDomain & operator=(SparseDiscreteDomain &&x)=default
KOKKOS_FUNCTION constexpr SparseDiscreteDomain remove_first(discrete_vector_type) const
KOKKOS_DEFAULTED_FUNCTION SparseDiscreteDomain(SparseDiscreteDomain const &x)=default
KOKKOS_DEFAULTED_FUNCTION ~SparseDiscreteDomain()=default
static KOKKOS_FUNCTION constexpr discrete_element_type front() noexcept
KOKKOS_FUNCTION constexpr SparseDiscreteDomain(SparseDiscreteDomain< ODDims... > const &)
static KOKKOS_FUNCTION constexpr discrete_vector_type extents() noexcept
KOKKOS_DEFAULTED_FUNCTION SparseDiscreteDomain(SparseDiscreteDomain &&x)=default
KOKKOS_FUNCTION constexpr discrete_element_type back() const noexcept
KOKKOS_FUNCTION constexpr SparseDiscreteDomain remove_first(discrete_vector_type n) const
static KOKKOS_FUNCTION constexpr std::size_t rank()
KOKKOS_DEFAULTED_FUNCTION SparseDiscreteDomain & operator=(SparseDiscreteDomain const &x)=default
KOKKOS_FUNCTION constexpr SparseDiscreteDomain take_last(discrete_vector_type n) const
KOKKOS_FUNCTION DiscreteVector< DDims... > distance_from_front(DElems const &... delems) const noexcept
KOKKOS_FUNCTION constexpr auto discrete_elements() const noexcept
KOKKOS_FUNCTION constexpr SparseDiscreteDomain remove(discrete_vector_type n1, discrete_vector_type n2) const
KOKKOS_FUNCTION constexpr decltype(auto) operator[](std::size_t n) const
SparseDiscreteDomain(Kokkos::View< DiscreteElement< DDims > *, Kokkos::SharedSpace > const &... views)
Construct a SparseDiscreteDomain with Kokkos::View explicitly listing the discrete elements.
KOKKOS_DEFAULTED_FUNCTION SparseDiscreteDomain & operator=(SparseDiscreteDomain &&x)=default
KOKKOS_FUNCTION constexpr std::size_t size() const
KOKKOS_FUNCTION constexpr bool operator==(SparseDiscreteDomain< ODims... > const &other) const
KOKKOS_FUNCTION bool contains(DElems const &... delems) const noexcept
KOKKOS_FUNCTION constexpr decltype(auto) operator[](std::size_t n)
KOKKOS_FUNCTION constexpr SparseDiscreteDomain take_first(discrete_vector_type n) const
KOKKOS_DEFAULTED_FUNCTION SparseDiscreteDomain()=default
KOKKOS_DEFAULTED_FUNCTION SparseDiscreteDomain(SparseDiscreteDomain &&x)=default
KOKKOS_FUNCTION constexpr discrete_element_type front() const noexcept
KOKKOS_FUNCTION constexpr operator bool()
KOKKOS_FUNCTION constexpr bool empty() const noexcept
KOKKOS_FUNCTION constexpr SparseDiscreteDomain(DDoms const &... domains)
Construct a SparseDiscreteDomain by copies and merge of domains.
KOKKOS_FUNCTION constexpr DiscreteElement< DDims... > operator()(DiscreteVector< DDims... > const &dvect) const noexcept
KOKKOS_DEFAULTED_FUNCTION SparseDiscreteDomain(SparseDiscreteDomain const &x)=default
KOKKOS_FUNCTION constexpr SparseDiscreteDomain remove_last(discrete_vector_type n) const
KOKKOS_FUNCTION constexpr discrete_vector_type extents() const noexcept
KOKKOS_FUNCTION constexpr DiscreteVector< QueryDDim > extent() const noexcept
KOKKOS_DEFAULTED_FUNCTION ~SparseDiscreteDomain()=default
The top-level namespace of DDC.
constexpr bool is_non_uniform_point_sampling_v
KOKKOS_FUNCTION constexpr DiscreteElement< QueryDDims... > back(SparseDiscreteDomain< DDims... > const &domain) noexcept
KOKKOS_FUNCTION Coordinate< typename DDim::continuous_dimension_type > rlength(DiscreteDomain< DDim > const &d)
bool is_discrete_space_initialized() noexcept
KOKKOS_FUNCTION Coordinate< typename DDim::continuous_dimension_type > coordinate(DiscreteElement< DDim > const &c)
KOKKOS_FUNCTION Coordinate< typename DDim::continuous_dimension_type > distance_at_left(DiscreteElement< DDim > i)
KOKKOS_FUNCTION Coordinate< typename DDim::continuous_dimension_type > origin() noexcept
Lower bound index of the mesh.
KOKKOS_FUNCTION constexpr SparseDiscreteDomain< QueryDDims... > select(SparseDiscreteDomain< DDims... > const &domain)
KOKKOS_FUNCTION Coordinate< typename DDim::continuous_dimension_type > rmin(DiscreteDomain< DDim > const &d)
KOKKOS_FUNCTION Coordinate< typename DDim::continuous_dimension_type > distance_at_right(DiscreteElement< DDim > i)
void init_discrete_space(Args &&... args)
Initialize (emplace) a global singleton discrete space.
KOKKOS_FUNCTION constexpr auto remove_dims_of(SparseDiscreteDomain< DDimsA... > const &DDom_a, SparseDiscreteDomain< DDimsB... > const &) noexcept
detail::ddim_impl_t< DDim, Kokkos::HostSpace > const & host_discrete_space()
KOKKOS_FUNCTION constexpr DiscreteVector< QueryDDims... > extents(SparseDiscreteDomain< DDims... > const &domain) noexcept
KOKKOS_FUNCTION constexpr auto replace_dim_of(SparseDiscreteDomain< DDimsA... > const &DDom_a, SparseDiscreteDomain< DDimsB... > const &DDom_b) noexcept
KOKKOS_FUNCTION constexpr DiscreteElement< QueryDDims... > front(SparseDiscreteDomain< DDims... > const &domain) noexcept
constexpr bool is_periodic_sampling_v
KOKKOS_FUNCTION Real step() noexcept
Spacing step of the mesh.
constexpr bool is_sparse_discrete_domain_v
KOKKOS_FUNCTION constexpr auto remove_dims_of(SparseDiscreteDomain< DDimsA... > const &DDom_a) noexcept
Remove the dimensions DDimsB from DDom_a.
KOKKOS_FUNCTION DiscreteElement< DDim > front() noexcept
Lower bound index of the mesh.
KOKKOS_FUNCTION detail::ddim_impl_t< DDim, MemorySpace > const & discrete_space()
Arg0 init_discrete_space(std::tuple< DDimImpl, Arg0 > &&a)
Move construct a global singleton discrete space and pass through the other argument.
std::tuple< Arg0, Arg1, Args... > init_discrete_space(std::tuple< DDimImpl, Arg0, Arg1, Args... > &&a)
Move construct a global singleton discrete space and pass through remaining arguments.
KOKKOS_FUNCTION Coordinate< typename DDim::continuous_dimension_type > rmax(DiscreteDomain< DDim > const &d)