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 operator()(AllocationType allocation, SimplexType
const& 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>
140 AllocationType allocation,
142 typename AllocationType::array_layout,
143 typename AllocationType::memory_space>
const& chain)
146 typename AllocationType::array_layout,
147 typename AllocationType::memory_space>
148 boundary_chain(allocation);
149 for (
auto i = chain.begin(); i < chain.end(); ++i) {
150 std::size_t
const distance = Kokkos::Experimental::distance(chain.begin(), i);
154 std::pair<std::size_t, std::size_t>(
155 2 * SimplexType::dimension() * distance,
156 2 * SimplexType::dimension() * (distance + 1))),
158 boundary_chain += 2 * SimplexType::dimension();
161 return boundary_chain;
165template <misc::Specialization<Kokkos::View> AllocationType,
class SimplexType>
166KOKKOS_FUNCTION
Chain<
168 typename AllocationType::array_layout,
169 typename AllocationType::memory_space>
170boundary(AllocationType allocation, SimplexType
const& simplex)
175template <
class MemorySpace = Kokkos::HostSpace,
class SimplexType>
177 SimplexType
const& simplex)
180 simplex.discrete_element());
181 chain += detail::generate_local_half_subchain<MemorySpace, SimplexType>(
182 simplex.discrete_element(),
183 simplex.discrete_vector(),
184 SimplexType::dimension() % 2);
185 chain += detail::generate_local_half_subchain<MemorySpace, SimplexType>(
186 simplex.discrete_element() + simplex.discrete_vector(),
187 -simplex.discrete_vector());
188 chain *= (SimplexType::dimension() % 2 ? 1 : -1) * (simplex.negative() ? -1 : 1);
192template <misc::Specialization<Kokkos::View> AllocationType,
class SimplexType>
193KOKKOS_FUNCTION
Chain<
195 typename AllocationType::array_layout,
196 typename AllocationType::memory_space>
198 AllocationType allocation,
200 typename AllocationType::array_layout,
201 typename AllocationType::memory_space>
const& chain)
static KOKKOS_FUNCTION Chain< boundary_t< SimplexType >, typename AllocationType::array_layout, typename AllocationType::memory_space > operator()(AllocationType allocation, Chain< SimplexType, typename AllocationType::array_layout, typename AllocationType::memory_space > const &chain)