18template <
class SimplexType>
21template <std::size_t K,
class... Tag>
22struct BoundaryType<
Simplex<K, Tag...>>
24 using type =
Simplex<K - 1, Tag...>;
27template <
class SimplexType,
class LayoutStr
idedPolicy,
class MemorySpace>
28struct BoundaryType<
Chain<SimplexType, LayoutStridedPolicy, MemorySpace>>
36using boundary_t =
typename detail::BoundaryType<T>::type;
41template <
class SimplexType, misc::Specialization<Kokkos::View> AllocationType>
42KOKKOS_FUNCTION
constexpr Chain<
44 typename AllocationType::array_layout,
45 typename AllocationType::memory_space>
46generate_half_subchain(
47 AllocationType allocation,
48 typename SimplexType::discrete_element_type elem,
49 typename SimplexType::discrete_vector_type vect,
50 bool negative =
false)
52 auto array = ddc::detail::array(vect);
54 typename AllocationType::array_layout,
55 typename AllocationType::memory_space>
58 for (std::size_t i = 0; i < SimplexType::dimension(); ++i) {
60 auto j = array_.begin() + id_dist + 1;
61 auto id = std::find_if(j, array_.end(), [](
int k) { return k != 0; });
62 id_dist = std::distance(array_.begin(),
id);
64 typename SimplexType::discrete_vector_type vect_;
65 ddc::detail::array(vect_) = array_;
74template <misc::Specialization<Kokkos::View> AllocationType,
class SimplexType>
77 typename AllocationType::array_layout,
78 typename AllocationType::memory_space>
79boundary(AllocationType allocation, SimplexType simplex)
82 typename AllocationType::array_layout,
83 typename AllocationType::memory_space>
85 detail::generate_half_subchain<SimplexType>(
88 std::pair<std::size_t, std::size_t>(0, SimplexType::dimension())),
89 simplex.discrete_element(),
90 simplex.discrete_vector(),
91 SimplexType::dimension() % 2);
92 chain += SimplexType::dimension();
93 detail::generate_half_subchain<SimplexType>(
96 std::pair<std::size_t, std::size_t>(
97 SimplexType::dimension(),
98 2 * SimplexType::dimension())),
99 simplex.discrete_element() + simplex.discrete_vector(),
100 -simplex.discrete_vector());
101 chain += SimplexType::dimension();
102 chain *= (SimplexType::dimension() % 2 ? 1 : -1) * (simplex.negative() ? -1 : 1);
106template <misc::Specialization<Kokkos::View> AllocationType,
class SimplexType>
107KOKKOS_FUNCTION
Chain<
109 typename AllocationType::array_layout,
110 typename AllocationType::memory_space>
112 AllocationType allocation,
114 typename AllocationType::array_layout,
115 typename AllocationType::memory_space> chain)
118 typename AllocationType::array_layout,
119 typename AllocationType::memory_space>
120 boundary_chain(allocation);
121 for (
auto i = chain.begin(); i < chain.end(); ++i) {
122 std::size_t
const distance = Kokkos::Experimental::distance(chain.begin(), i);
126 std::pair<std::size_t, std::size_t>(
127 2 * SimplexType::dimension() * distance,
128 2 * SimplexType::dimension() * (distance + 1))),
130 boundary_chain += 2 * SimplexType::dimension();
133 return boundary_chain;