dune-pdelab  2.0.0
partitioninfoprovider.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 
4 #ifndef DUNE_PDELAB_COMMON_PARTITIONINFOPROVIDER_HH
5 #define DUNE_PDELAB_COMMON_PARTITIONINFOPROVIDER_HH
6 
7 #include <bitset>
8 
9 #include <dune/grid/common/gridenums.hh>
10 
11 namespace Dune {
12  namespace PDELab {
13 
15 
23  {
24 
25  public:
26 
28  bool containsPartition(PartitionType partition) const
29  {
30  return _contained_partitions.test(static_cast<unsigned char>(partition));
31  }
32 
34  std::bitset<6> containedPartitions() const
35  {
36  return _contained_partitions;
37  }
38 
39  protected:
40 
43  {
44  _contained_partitions.reset();
45  }
46 
49  {
50  _contained_partitions |= r._contained_partitions;
51  }
52 
54 
58  void setPartitionSet(const std::bitset<6>& partitions)
59  {
60  _contained_partitions = partitions;
61  }
62 
65  {
66  _contained_partitions = r._contained_partitions;
67  }
68 
70 
76  template<typename It>
77  void mergePartitionSets(It begin, It end)
78  {
80  for (; begin != end; ++begin)
81  mergePartitionSet(reference(*begin));
82  }
83 
84  private:
85 
86  // ********************************************************************************
87  // The following two function are here to make mergePartitionSets() work with both
88  // normal iterators and iterators of pointers. It would be nice to just use
89  // boost::indirect_iterator, but alas...
90  // ********************************************************************************
91 
92  static const PartitionInfoProvider& reference(const PartitionInfoProvider& provider)
93  {
94  return provider;
95  }
96 
97  static const PartitionInfoProvider& reference(const PartitionInfoProvider* provider)
98  {
99  return *provider;
100  }
101 
102  std::bitset<6> _contained_partitions;
103 
104  };
105 
106  } // namespace PDELab
107 } // namespace Dune
108 
109 #endif // DUNE_PDELAB_COMMON_PARTITIONINFOPROVIDER_HH
Mixin class for providing information about contained grid partitions.
Definition: partitioninfoprovider.hh:22
void mergePartitionSet(const PartitionInfoProvider &r)
Adds all partitions contained in r the set of contained partitions.
Definition: partitioninfoprovider.hh:48
void setPartitionSet(const PartitionInfoProvider &r)
Copies the set of contained partitions from r.
Definition: partitioninfoprovider.hh:64
void setPartitionSet(const std::bitset< 6 > &partitions)
Sets the set of contained partitions to the passed-in value.
Definition: partitioninfoprovider.hh:58
void clearPartitionSet()
Empties the set of contained partitions.
Definition: partitioninfoprovider.hh:42
bool containsPartition(PartitionType partition) const
Returns whether this ordering contains entities with PartitionType partition.
Definition: partitioninfoprovider.hh:28
std::bitset< 6 > containedPartitions() const
Returns the internal representation of the set of contained entities.
Definition: partitioninfoprovider.hh:34
void mergePartitionSets(It begin, It end)
Adds the partitions from all PartitionInfoProviders in the range [begin,end).
Definition: partitioninfoprovider.hh:77