3#ifndef DUNE_GRID_COMMON_PARTITIONSET_HH
4#define DUNE_GRID_COMMON_PARTITIONSET_HH
8#include <dune/grid/common/gridenums.hh>
20 template<
unsigned int partitions>
21 struct derive_partition_iterator_type
24 static_assert(AlwaysFalse<std::integral_constant<unsigned int,partitions> >::value,
25 "There is no partition iterator for this combination of entity partitions");
32 struct derive_partition_iterator_type<
35 :
public std::integral_constant<PartitionIteratorType,Interior_Partition>
39 struct derive_partition_iterator_type<
43 :
public std::integral_constant<PartitionIteratorType,InteriorBorder_Partition>
47 struct derive_partition_iterator_type<
52 :
public std::integral_constant<PartitionIteratorType,Overlap_Partition>
56 struct derive_partition_iterator_type<
62 :
public std::integral_constant<PartitionIteratorType,OverlapFront_Partition>
66 struct derive_partition_iterator_type<
73 :
public std::integral_constant<PartitionIteratorType,All_Partition>
77 struct derive_partition_iterator_type<
80 :
public std::integral_constant<PartitionIteratorType,Ghost_Partition>
86 template<PartitionIteratorType pitype>
87 struct derive_partition_set;
94 : std::integral_constant<unsigned int, (1 << InteriorEntity)>
98 struct derive_partition_set<InteriorBorder_Partition>
99 : std::integral_constant<unsigned int, (1 << InteriorEntity) | (1 << BorderEntity)>
103 struct derive_partition_set<Overlap_Partition>
104 : std::integral_constant<unsigned int, (1 << InteriorEntity) | (1 << BorderEntity) | (1 << OverlapEntity)>
108 struct derive_partition_set<OverlapFront_Partition>
109 : std::integral_constant<unsigned int, (1 << InteriorEntity) | (1 << BorderEntity) | (1 << OverlapEntity) | (1 << FrontEntity)>
113 struct derive_partition_set<Ghost_Partition>
114 : std::integral_constant<unsigned int, (1 << GhostEntity)>
118 struct derive_partition_set<All_Partition>
119 : std::integral_constant<unsigned int, (1 << InteriorEntity) | (1 << BorderEntity) | (1 << OverlapEntity) | (1 << FrontEntity) | (1 << GhostEntity)>
134 template<unsigned int partitions>
138 static constexpr unsigned int value = partitions;
142 template<unsigned int p>
143 struct PartitionSet<partitions | p>
144 constexpr operator+(const PartitionSet<p>&) const
146 return PartitionSet<partitions | p>();
150 template<unsigned int p>
151 struct PartitionSet<partitions & ~p>
152 constexpr operator-(const PartitionSet<p>&) const
154 return PartitionSet<partitions & ~p>();
158 friend std::ostream& operator<<(std::ostream& os, const PartitionSet&)
160 unsigned int set = partitions;
161 os << "partition set {";
163 for (unsigned int p = 0; set; set &= ~(1 << p++))
165 if (!(set & (1 << p)))
170 os << static_cast<PartitionType>(p);
181 static constexpr PartitionIteratorType partitionIterator()
183 return derive_partition_iterator_type<partitions>::value;
187 static constexpr bool contains(PartitionType pt)
189 return partitions & (1 << pt);
193 template<unsigned int contained_partitions>
194 static constexpr bool contains(PartitionSet<contained_partitions>)
196 return (partitions & contained_partitions) == contained_partitions;
200 template<unsigned int p2>
201 constexpr bool operator==(PartitionSet<p2>) const
203 return partitions == p2;
207 template<unsigned int p2>
208 constexpr bool operator!=(PartitionSet<p2>) const
210 return partitions != p2;
219 template<PartitionType p>
220 PartitionSet<(1 << p)> partitionSet()
222 return PartitionSet<(1 << p)>();
229 template<PartitionIteratorType pitype>
230 constexpr PartitionSet<derive_partition_set<pitype>::value> partitionSet()
232 return PartitionSet<derive_partition_set<pitype>::value>();
236 namespace Partitions {
242 typedef PartitionSet<...> Interior;
245 typedef PartitionSet<...> Border;
248 typedef PartitionSet<...> Overlap;
251 typedef PartitionSet<...> Front;
254 typedef PartitionSet<...> Ghost;
257 typedef PartitionSet<...> InteriorBorder;
260 typedef PartitionSet<...> InteriorBorderOverlap;
263 typedef PartitionSet<...> InteriorBorderOverlapFront;
266 typedef PartitionSet<...> All;
270 constexpr Interior interior;
273 constexpr Border border;
276 constexpr Overlap overlap;
279 constexpr Front front;
282 constexpr Ghost ghost;
285 constexpr InteriorBorder interiorBorder;
288 constexpr InteriorBorderOverlap interiorBorderOverlap;
291 constexpr InteriorBorderOverlapFront interiorBorderOverlapFront;
300 typedef decltype(partitionSet<InteriorEntity>()) Interior;
301 typedef decltype(partitionSet<BorderEntity>()) Border;
302 typedef decltype(partitionSet<OverlapEntity>()) Overlap;
303 typedef decltype(partitionSet<FrontEntity>()) Front;
304 typedef decltype(partitionSet<GhostEntity>()) Ghost;
306#ifndef __cpp_inline_variables
314 DUNE_INLINE_VARIABLE constexpr Interior interior = {};
315 DUNE_INLINE_VARIABLE constexpr Border border = {};
316 DUNE_INLINE_VARIABLE constexpr Overlap overlap = {};
317 DUNE_INLINE_VARIABLE constexpr Front front = {};
318 DUNE_INLINE_VARIABLE constexpr Ghost ghost = {};
320#ifndef __cpp_inline_variables
326 typedef decltype(interior + border) InteriorBorder;
327 typedef decltype(interior + border + overlap) InteriorBorderOverlap;
328 typedef decltype(interior + border + overlap + front) InteriorBorderOverlapFront;
329 typedef decltype(interior + border + overlap + front + ghost) All;
331#ifndef __cpp_inline_variables
337 DUNE_INLINE_VARIABLE constexpr InteriorBorder interiorBorder = {};
338 DUNE_INLINE_VARIABLE constexpr InteriorBorderOverlap interiorBorderOverlap = {};
339 DUNE_INLINE_VARIABLE constexpr InteriorBorderOverlapFront interiorBorderOverlapFront = {};
340 DUNE_INLINE_VARIABLE constexpr All all = {};
342#ifndef __cpp_inline_variables
Traits for type conversions and type information.
Definitions of several macros that conditionally make C++ syntax available.
Dune namespace.
Definition: alignedallocator.hh:11