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