5#ifndef DUNE_GRID_COMMON_PARTITIONSET_HH
6#define DUNE_GRID_COMMON_PARTITIONSET_HH
9#include <dune/grid/common/gridenums.hh>
21 template<
unsigned int partitions>
22 struct derive_partition_iterator_type
25 static_assert(AlwaysFalse<std::integral_constant<unsigned int,partitions> >::value,
26 "There is no partition iterator for this combination of entity partitions");
33 struct derive_partition_iterator_type<
36 :
public std::integral_constant<PartitionIteratorType,Interior_Partition>
40 struct derive_partition_iterator_type<
44 :
public std::integral_constant<PartitionIteratorType,InteriorBorder_Partition>
48 struct derive_partition_iterator_type<
53 :
public std::integral_constant<PartitionIteratorType,Overlap_Partition>
57 struct derive_partition_iterator_type<
63 :
public std::integral_constant<PartitionIteratorType,OverlapFront_Partition>
67 struct derive_partition_iterator_type<
74 :
public std::integral_constant<PartitionIteratorType,All_Partition>
78 struct derive_partition_iterator_type<
81 :
public std::integral_constant<PartitionIteratorType,Ghost_Partition>
87 template<PartitionIteratorType pitype>
88 struct derive_partition_set;
95 : std::integral_constant<unsigned int, (1 << InteriorEntity)>
99 struct derive_partition_set<InteriorBorder_Partition>
100 : std::integral_constant<unsigned int, (1 << InteriorEntity) | (1 << BorderEntity)>
104 struct derive_partition_set<Overlap_Partition>
105 : std::integral_constant<unsigned int, (1 << InteriorEntity) | (1 << BorderEntity) | (1 << OverlapEntity)>
109 struct derive_partition_set<OverlapFront_Partition>
110 : std::integral_constant<unsigned int, (1 << InteriorEntity) | (1 << BorderEntity) | (1 << OverlapEntity) | (1 << FrontEntity)>
114 struct derive_partition_set<Ghost_Partition>
115 : std::integral_constant<unsigned int, (1 << GhostEntity)>
119 struct derive_partition_set<All_Partition>
120 : std::integral_constant<unsigned int, (1 << InteriorEntity) | (1 << BorderEntity) | (1 << OverlapEntity) | (1 << FrontEntity) | (1 << GhostEntity)>
135 template<unsigned int partitions>
139 static constexpr unsigned int value = partitions;
143 template<unsigned int p>
144 struct PartitionSet<partitions | p>
145 constexpr operator+(const PartitionSet<p>&) const
147 return PartitionSet<partitions | p>();
151 template<unsigned int p>
152 struct PartitionSet<partitions & ~p>
153 constexpr operator-(const PartitionSet<p>&) const
155 return PartitionSet<partitions & ~p>();
159 friend std::ostream& operator<<(std::ostream& os, const PartitionSet&)
161 unsigned int set = partitions;
162 os << "partition set {";
164 for (unsigned int p = 0; set; set &= ~(1 << p++))
166 if (!(set & (1 << p)))
171 os << static_cast<PartitionType>(p);
182 static constexpr PartitionIteratorType partitionIterator()
184 return derive_partition_iterator_type<partitions>::value;
188 static constexpr bool contains(PartitionType pt)
190 return partitions & (1 << pt);
194 template<unsigned int contained_partitions>
195 static constexpr bool contains(PartitionSet<contained_partitions>)
197 return (partitions & contained_partitions) == contained_partitions;
201 template<unsigned int p2>
202 constexpr bool operator==(PartitionSet<p2>) const
204 return partitions == p2;
208 template<unsigned int p2>
209 constexpr bool operator!=(PartitionSet<p2>) const
211 return partitions != p2;
220 template<PartitionType p>
221 PartitionSet<(1 << p)> partitionSet()
223 return PartitionSet<(1 << p)>();
230 template<PartitionIteratorType pitype>
231 constexpr PartitionSet<derive_partition_set<pitype>::value> partitionSet()
233 return PartitionSet<derive_partition_set<pitype>::value>();
237 namespace Partitions {
243 typedef PartitionSet<...> Interior;
246 typedef PartitionSet<...> Border;
249 typedef PartitionSet<...> Overlap;
252 typedef PartitionSet<...> Front;
255 typedef PartitionSet<...> Ghost;
258 typedef PartitionSet<...> InteriorBorder;
261 typedef PartitionSet<...> InteriorBorderOverlap;
264 typedef PartitionSet<...> InteriorBorderOverlapFront;
267 typedef PartitionSet<...> All;
271 constexpr Interior interior;
274 constexpr Border border;
277 constexpr Overlap overlap;
280 constexpr Front front;
283 constexpr Ghost ghost;
286 constexpr InteriorBorder interiorBorder;
289 constexpr InteriorBorderOverlap interiorBorderOverlap;
292 constexpr InteriorBorderOverlapFront interiorBorderOverlapFront;
301 typedef decltype(partitionSet<InteriorEntity>()) Interior;
302 typedef decltype(partitionSet<BorderEntity>()) Border;
303 typedef decltype(partitionSet<OverlapEntity>()) Overlap;
304 typedef decltype(partitionSet<FrontEntity>()) Front;
305 typedef decltype(partitionSet<GhostEntity>()) Ghost;
307 inline constexpr Interior interior = {};
308 inline constexpr Border border = {};
309 inline constexpr Overlap overlap = {};
310 inline constexpr Front front = {};
311 inline constexpr Ghost ghost = {};
315 typedef decltype(interior + border) InteriorBorder;
316 typedef decltype(interior + border + overlap) InteriorBorderOverlap;
317 typedef decltype(interior + border + overlap + front) InteriorBorderOverlapFront;
318 typedef decltype(interior + border + overlap + front + ghost) All;
320 inline constexpr InteriorBorder interiorBorder = {};
321 inline constexpr InteriorBorderOverlap interiorBorderOverlap = {};
322 inline constexpr InteriorBorderOverlapFront interiorBorderOverlapFront = {};
323 inline constexpr All all = {};
Dune namespace.
Definition: alignedallocator.hh:13
Traits for type conversions and type information.