21template <
class SimplexType>
24template <std::size_t K,
class... Tag>
25struct BoundaryType<
Simplex<K, Tag...>>
27 using type =
Simplex<K - 1, Tag...>;
30template <
class SimplexType,
class LayoutStr
idedPolicy,
class MemorySpace>
31struct BoundaryType<
Chain<SimplexType, LayoutStridedPolicy, MemorySpace>>
39using boundary_t =
typename detail::BoundaryType<T>::type;
43template <
class MemorySpace = Kokkos::HostSpace,
class SimplexType>
45generate_local_half_subchain(
46 typename SimplexType::discrete_element_type elem,
47 typename SimplexType::discrete_vector_type vect,
48 bool negative =
false)
50 auto array = ddc::detail::array(vect);
53 for (std::size_t i = 0; i < SimplexType::dimension(); ++i) {
55 auto j = array_.begin() + id_dist + 1;
56 auto id = std::find_if(j, array_.end(), [](
int k) { return k != 0; });
57 id_dist = std::distance(array_.begin(),
id);
59 typename SimplexType::discrete_vector_type vect_;
60 ddc::detail::array(vect_) = array_;
68template <
class SimplexType, misc::Specialization<Kokkos::View> AllocationType>
69KOKKOS_FUNCTION
constexpr Chain<
71 typename AllocationType::array_layout,
72 typename AllocationType::memory_space>
73generate_half_subchain(
74 AllocationType allocation,
75 typename SimplexType::discrete_element_type elem,
76 typename SimplexType::discrete_vector_type vect,
77 bool negative =
false)
79 auto array = ddc::detail::array(vect);
81 typename AllocationType::array_layout,
82 typename AllocationType::memory_space>
85 for (std::size_t i = 0; i < SimplexType::dimension(); ++i) {
87 auto j = array_.begin() + id_dist + 1;
88 auto id = std::find_if(j, array_.end(), [](
int k) { return k != 0; });
89 id_dist = std::distance(array_.begin(),
id);
91 typename SimplexType::discrete_vector_type vect_;
92 ddc::detail::array(vect_) = array_;
101template <misc::Specialization<Kokkos::View> AllocationType,
class SimplexType>
104 KOKKOS_FUNCTION
static Chain<
106 typename AllocationType::array_layout,
107 typename AllocationType::memory_space>
108 run(AllocationType allocation, SimplexType simplex)
111 typename AllocationType::array_layout,
112 typename AllocationType::memory_space>
114 detail::generate_half_subchain<SimplexType>(
117 std::pair<std::size_t, std::size_t>(0, SimplexType::dimension())),
118 simplex.discrete_element(),
119 simplex.discrete_vector(),
120 SimplexType::dimension() % 2);
121 chain += SimplexType::dimension();
122 detail::generate_half_subchain<SimplexType>(
125 std::pair<std::size_t, std::size_t>(
126 SimplexType::dimension(),
127 2 * SimplexType::dimension())),
128 simplex.discrete_element() + simplex.discrete_vector(),
129 -simplex.discrete_vector());
130 chain += SimplexType::dimension();
131 chain *= (SimplexType::dimension() % 2 ? 1 : -1) * (simplex.negative() ? -1 : 1);
135 KOKKOS_FUNCTION
static Chain<
137 typename AllocationType::array_layout,
138 typename AllocationType::memory_space>
139 run(AllocationType allocation,
141 typename AllocationType::array_layout,
142 typename AllocationType::memory_space> chain)
145 typename AllocationType::array_layout,
146 typename AllocationType::memory_space>
147 boundary_chain(allocation);
148 for (
auto i = chain.begin(); i < chain.end(); ++i) {
149 std::size_t
const distance = Kokkos::Experimental::distance(chain.begin(), i);
153 std::pair<std::size_t, std::size_t>(
154 2 * SimplexType::dimension() * distance,
155 2 * SimplexType::dimension() * (distance + 1))),
157 boundary_chain += 2 * SimplexType::dimension();
160 return boundary_chain;
164template <misc::Specialization<Kokkos::View> AllocationType,
class SimplexType>
165KOKKOS_FUNCTION
Chain<
167 typename AllocationType::array_layout,
168 typename AllocationType::memory_space>
169boundary(AllocationType allocation, SimplexType simplex)
174template <
class MemorySpace = Kokkos::HostSpace,
class SimplexType>
179 simplex.discrete_element());
180 chain += detail::generate_local_half_subchain<MemorySpace, SimplexType>(
181 simplex.discrete_element(),
182 simplex.discrete_vector(),
183 SimplexType::dimension() % 2);
184 chain += detail::generate_local_half_subchain<MemorySpace, SimplexType>(
185 simplex.discrete_element() + simplex.discrete_vector(),
186 -simplex.discrete_vector());
187 chain *= (SimplexType::dimension() % 2 ? 1 : -1) * (simplex.negative() ? -1 : 1);
191template <misc::Specialization<Kokkos::View> AllocationType,
class SimplexType>
192KOKKOS_FUNCTION
Chain<
194 typename AllocationType::array_layout,
195 typename AllocationType::memory_space>
197 AllocationType allocation,
199 typename AllocationType::array_layout,
200 typename AllocationType::memory_space> chain)
static KOKKOS_FUNCTION Chain< boundary_t< SimplexType >, typename AllocationType::array_layout, typename AllocationType::memory_space > run(AllocationType allocation, Chain< SimplexType, typename AllocationType::array_layout, typename AllocationType::memory_space > chain)