dune-localfunctions  2.4.1
localkey.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 #ifndef DUNE_LOCALKEY_HH
4 #define DUNE_LOCALKEY_HH
5 
6 #include <array>
7 #include <cstddef>
8 
9 #include <dune/common/array.hh>
10 
11 namespace Dune
12 {
21  class LocalKey
22  {
23  public:
24 
26  enum {
36  };
37 
40  {}
41 
47  LocalKey (unsigned int s, unsigned int c, unsigned int i)
48  {
49  values_[0] = s;
50  values_[1] = c;
51  values_[2] = i;
52  }
53 
55  inline unsigned int subEntity () const
56  {
57  return values_[0];
58  }
59 
61  inline unsigned int codim () const
62  {
63  return values_[1];
64  }
65 
67  inline unsigned int index () const
68  {
69  return values_[2];
70  }
71 
73  void index (unsigned int i)
74  {
75  values_[2] = i;
76  }
77 
79  bool operator< (const LocalKey& other) const
80  {
81  return values_ < other.values_;
82  }
83 
85  friend std::ostream& operator<< (std::ostream& s, const LocalKey& localKey)
86  {
87  return s << "[ subEntity: " << localKey.subEntity()
88  << ", codim: " << localKey.codim()
89  << ", index: " << localKey.index() << " ]";
90  }
91 
92  private:
93 
94  // We use an array to store the values in order to be able to use the array::operator< implementation
95  std::array<unsigned int,3> values_;
96 
97  };
98 
99 }
100 #endif
friend std::ostream & operator<<(std::ostream &s, const LocalKey &localKey)
Write LocalKey object to output stream.
Definition: localkey.hh:85
Definition: brezzidouglasmarini1cube2dlocalbasis.hh:14
LocalKey(unsigned int s, unsigned int c, unsigned int i)
Initialize all components.
Definition: localkey.hh:47
unsigned int codim() const
Return codim of associated entity.
Definition: localkey.hh:61
unsigned int subEntity() const
Return number of associated subentity.
Definition: localkey.hh:55
bool operator<(const LocalKey &other) const
Less-than operator so we can use this class as a key type in stl containers.
Definition: localkey.hh:79
void index(unsigned int i)
Set index component.
Definition: localkey.hh:73
LocalKey()
Standard constructor for uninitialized local index.
Definition: localkey.hh:39
Codimension returned by LocalKey::codim() for degrees of freedom attached to an intersection.
Definition: localkey.hh:35
Describe position of one degree of freedom.
Definition: localkey.hh:21
unsigned int index() const
Return offset within subentity.
Definition: localkey.hh:67