dune-grid  2.2.0
entitykey.hh
Go to the documentation of this file.
1 #ifndef DUNE_DGFEnTITYKEY_HH
2 #define DUNE_DGFEnTITYKEY_HH
3 
4 #include <iostream>
5 #include <vector>
6 
9 
10 namespace Dune
11 {
12 
13  // DGFEntityKey
14  // ------------
15 
16  template< class A >
17  struct DGFEntityKey
18  {
19  DGFEntityKey ( const std :: vector< A > &key, bool setOrigKey = true );
20  DGFEntityKey ( const std::vector< A > &key,
21  int N, int offset, bool setOrigKey = true );
22  DGFEntityKey ( const DGFEntityKey< A > &k );
23 
25 
26  inline const A &operator[] ( int i ) const;
27  inline bool operator < ( const DGFEntityKey< A > &k ) const;
28 
29  void orientation ( int base, std :: vector< std :: vector< double > > &vtx );
30  void print( std :: ostream &out = std :: cerr ) const;
31 
32  inline bool origKeySet () const;
33  inline const A &origKey ( int i ) const;
34  inline int size () const;
35 
36  private:
37  std :: vector< A > key_, origKey_;
38  bool origKeySet_;
39  };
40 
41 
42  template< class A >
43  inline const A &DGFEntityKey< A > :: operator[] ( int i ) const
44  {
45  return key_[ i ];
46  }
47 
48 
49  template< class A >
50  inline bool DGFEntityKey< A > :: operator< ( const DGFEntityKey< A > &k ) const
51  {
52  // assert(k.key_.size()==key_.size());
53  return key_ < k.key_;
54  }
55 
56 
57  template< class A >
58  inline bool DGFEntityKey< A > :: origKeySet () const
59  {
60  return origKeySet_;
61  }
62 
63 
64  template< class A >
65  inline const A &DGFEntityKey< A > :: origKey ( int i ) const
66  {
67  return origKey_[ i ];
68  }
69 
70 
71  template< class A >
72  inline int DGFEntityKey< A > :: size () const
73  {
74  return key_.size();
75  }
76 
77 
78 
79  // ElementFaceUtil
80  // ---------------
81 
83  {
84  inline static int nofFaces ( int dim, std::vector< unsigned int > &element );
85  inline static int faceSize ( int dim, bool simpl );
86 
88  generateFace ( int dim, const std::vector< unsigned int > &element, int f );
89 
90  private:
91  template< int dim >
93  generateCubeFace( const std::vector< unsigned int > &element, int f );
94 
95  template< int dim >
97  generateSimplexFace ( const std::vector< unsigned int > &element, int f );
98  };
99 
100 
101  inline int ElementFaceUtil::nofFaces ( int dim, std::vector< unsigned int > &element )
102  {
103  switch( dim )
104  {
105  case 1:
106  return 2;
107  case 2:
108  switch( element.size() )
109  {
110  case 3:
111  return 3;
112  case 4:
113  return 4;
114  default:
115  return -1;
116  }
117  case 3:
118  switch( element.size() )
119  {
120  case 4:
121  return 4;
122  case 8:
123  return 6;
124  default:
125  return -1;
126  }
127  default:
128  return -1;
129  }
130  }
131 
132 
133  inline int ElementFaceUtil::faceSize( int dim, bool simpl )
134  {
135  switch( dim )
136  {
137  case 1:
138  return 1;
139  case 2:
140  return 2;
141  case 3:
142  return (simpl ? 3 : 4);
143  default:
144  return -1;
145  }
146  }
147 
148 } //end namespace Dune
149 
150 // inlcude inline implementation
151 #include "entitykey_inline.hh"
152 #endif