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