5#ifndef DUNE_GRID_COMMON_PARTITIONSET_HH
6#define DUNE_GRID_COMMON_PARTITIONSET_HH
10#include <dune/grid/common/gridenums.hh>
22 template<
unsigned int partitions>
23 struct derive_partition_iterator_type
26 static_assert(AlwaysFalse<std::integral_constant<unsigned int,partitions> >::value,
27 "There is no partition iterator for this combination of entity partitions");
34 struct derive_partition_iterator_type<
37 :
public std::integral_constant<PartitionIteratorType,Interior_Partition>
41 struct derive_partition_iterator_type<
45 :
public std::integral_constant<PartitionIteratorType,InteriorBorder_Partition>
49 struct derive_partition_iterator_type<
54 :
public std::integral_constant<PartitionIteratorType,Overlap_Partition>
58 struct derive_partition_iterator_type<
64 :
public std::integral_constant<PartitionIteratorType,OverlapFront_Partition>
68 struct derive_partition_iterator_type<
75 :
public std::integral_constant<PartitionIteratorType,All_Partition>
79 struct derive_partition_iterator_type<
82 :
public std::integral_constant<PartitionIteratorType,Ghost_Partition>
88 template<PartitionIteratorType pitype>
89 struct derive_partition_set;
96 : std::integral_constant<unsigned int, (1 << InteriorEntity)>
100 struct derive_partition_set<InteriorBorder_Partition>
101 : std::integral_constant<unsigned int, (1 << InteriorEntity) | (1 << BorderEntity)>
105 struct derive_partition_set<Overlap_Partition>
106 : std::integral_constant<unsigned int, (1 << InteriorEntity) | (1 << BorderEntity) | (1 << OverlapEntity)>
110 struct derive_partition_set<OverlapFront_Partition>
111 : std::integral_constant<unsigned int, (1 << InteriorEntity) | (1 << BorderEntity) | (1 << OverlapEntity) | (1 << FrontEntity)>
115 struct derive_partition_set<Ghost_Partition>
116 : std::integral_constant<unsigned int, (1 << GhostEntity)>
120 struct derive_partition_set<All_Partition>
121 : std::integral_constant<unsigned int, (1 << InteriorEntity) | (1 << BorderEntity) | (1 << OverlapEntity) | (1 << FrontEntity) | (1 << GhostEntity)>
136 template<unsigned int partitions>
140 static constexpr unsigned int value = partitions;
144 template<unsigned int p>
145 struct PartitionSet<partitions | p>
146 constexpr operator+(const PartitionSet<p>&) const
148 return PartitionSet<partitions | p>();
152 template<unsigned int p>
153 struct PartitionSet<partitions & ~p>
154 constexpr operator-(const PartitionSet<p>&) const
156 return PartitionSet<partitions & ~p>();
160 friend std::ostream& operator<<(std::ostream& os, const PartitionSet&)
162 unsigned int set = partitions;
163 os << "partition set {";
165 for (unsigned int p = 0; set; set &= ~(1 << p++))
167 if (!(set & (1 << p)))
172 os << static_cast<PartitionType>(p);
183 static constexpr PartitionIteratorType partitionIterator()
185 return derive_partition_iterator_type<partitions>::value;
189 static constexpr bool contains(PartitionType pt)
191 return partitions & (1 << pt);
195 template<unsigned int contained_partitions>
196 static constexpr bool contains(PartitionSet<contained_partitions>)
198 return (partitions & contained_partitions) == contained_partitions;
202 template<unsigned int p2>
203 constexpr bool operator==(PartitionSet<p2>) const
205 return partitions == p2;
209 template<unsigned int p2>
210 constexpr bool operator!=(PartitionSet<p2>) const
212 return partitions != p2;
221 template<PartitionType p>
222 PartitionSet<(1 << p)> partitionSet()
224 return PartitionSet<(1 << p)>();
231 template<PartitionIteratorType pitype>
232 constexpr PartitionSet<derive_partition_set<pitype>::value> partitionSet()
234 return PartitionSet<derive_partition_set<pitype>::value>();
238 namespace Partitions {
244 typedef PartitionSet<...> Interior;
247 typedef PartitionSet<...> Border;
250 typedef PartitionSet<...> Overlap;
253 typedef PartitionSet<...> Front;
256 typedef PartitionSet<...> Ghost;
259 typedef PartitionSet<...> InteriorBorder;
262 typedef PartitionSet<...> InteriorBorderOverlap;
265 typedef PartitionSet<...> InteriorBorderOverlapFront;
268 typedef PartitionSet<...> All;
272 constexpr Interior interior;
275 constexpr Border border;
278 constexpr Overlap overlap;
281 constexpr Front front;
284 constexpr Ghost ghost;
287 constexpr InteriorBorder interiorBorder;
290 constexpr InteriorBorderOverlap interiorBorderOverlap;
293 constexpr InteriorBorderOverlapFront interiorBorderOverlapFront;
302 typedef decltype(partitionSet<InteriorEntity>()) Interior;
303 typedef decltype(partitionSet<BorderEntity>()) Border;
304 typedef decltype(partitionSet<OverlapEntity>()) Overlap;
305 typedef decltype(partitionSet<FrontEntity>()) Front;
306 typedef decltype(partitionSet<GhostEntity>()) Ghost;
308#ifndef __cpp_inline_variables
316 DUNE_INLINE_VARIABLE constexpr Interior interior = {};
317 DUNE_INLINE_VARIABLE constexpr Border border = {};
318 DUNE_INLINE_VARIABLE constexpr Overlap overlap = {};
319 DUNE_INLINE_VARIABLE constexpr Front front = {};
320 DUNE_INLINE_VARIABLE constexpr Ghost ghost = {};
322#ifndef __cpp_inline_variables
328 typedef decltype(interior + border) InteriorBorder;
329 typedef decltype(interior + border + overlap) InteriorBorderOverlap;
330 typedef decltype(interior + border + overlap + front) InteriorBorderOverlapFront;
331 typedef decltype(interior + border + overlap + front + ghost) All;
333#ifndef __cpp_inline_variables
339 DUNE_INLINE_VARIABLE constexpr InteriorBorder interiorBorder = {};
340 DUNE_INLINE_VARIABLE constexpr InteriorBorderOverlap interiorBorderOverlap = {};
341 DUNE_INLINE_VARIABLE constexpr InteriorBorderOverlapFront interiorBorderOverlapFront = {};
342 DUNE_INLINE_VARIABLE constexpr All all = {};
344#ifndef __cpp_inline_variables
Definitions of several macros that conditionally make C++ syntax available.
Dune namespace.
Definition: alignedallocator.hh:13
Traits for type conversions and type information.