dune-geometry  2.3.1
topologytypes.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_GEOMETRY_GENERICGEOMETRY_TOPOLOGYTYPES_HH
4 #define DUNE_GEOMETRY_GENERICGEOMETRY_TOPOLOGYTYPES_HH
5 
6 #include <cassert>
7 #include <string>
8 
9 #include <dune/common/static_assert.hh>
10 #include <dune/common/typetraits.hh>
11 #include <dune/common/unused.hh>
12 
13 namespace Dune
14 {
15 
16  namespace GenericGeometry
17  {
18 
20 
21 
22 
23  // Basic Topology Types
24  // --------------------
25 
26  struct Point
27  {
28  static const unsigned int dimension = 0;
29  static const unsigned int numCorners = 1;
30 
31  static const unsigned int id = 0;
32 
33  static std :: string name ()
34  {
35  return "p";
36  }
37  };
38 
39 
40  template< class BaseTopology >
41  struct Prism
42  {
43  static const unsigned int dimension = BaseTopology :: dimension + 1;
44  static const unsigned int numCorners = 2 * BaseTopology :: numCorners;
45 
46  static const unsigned int id = BaseTopology::id | ((unsigned int)prismConstruction << (dimension-1));
47 
48  static std :: string name ()
49  {
50  return BaseTopology :: name() + "l";
51  // return BaseTopology :: name() + "'";
52  }
53  };
54 
55 
56  template< class BaseTopology >
57  struct Pyramid
58  {
59  static const unsigned int dimension = BaseTopology :: dimension + 1;
60  static const unsigned int numCorners = BaseTopology :: numCorners + 1;
61 
62  static const unsigned int id = BaseTopology::id | ((unsigned int)pyramidConstruction << (dimension-1));
63 
64  static std :: string name ()
65  {
66  return BaseTopology :: name() + "o";
67  // return BaseTopology :: name() + "°";
68  }
69  };
70 
71 
72 
73  template< class Topology >
74  struct BaseTopology;
75 
76  template< class Base >
77  struct BaseTopology< Prism< Base > >
78  {
79  typedef Base type;
80  };
81 
82  template< class Base >
83  struct BaseTopology< Pyramid< Base > >
84  {
85  typedef Base type;
86  };
87 
88 
89 
90  template< class Topology >
91  struct IsSimplex
92  {
93  static const bool value = ((Topology::id >> 1) == 0);
94  };
95 
96  template< class Topology >
97  struct IsCube
98  {
99  static const bool value = ((Topology::id | 1) == (1 << Topology::dimension) - 1);
100  };
101 
102  template< class Topology >
103  struct IsHybrid
104  {
105  static const bool value
107  };
108 
109  template< class Topology >
111  {
112  static const bool value = false;
113  };
114 
115  template< class BaseTopology >
116  struct IsGeneralizedPrism< Prism< BaseTopology > >
117  {
118  static const bool value
120  };
121 
122 
123 
124  // Dynamic Topology Properties
125  // ---------------------------
126 
135  inline unsigned int numTopologies ( int dim )
136  {
137  return (1u << dim);
138  }
139 
151  inline bool isPyramid ( unsigned int topologyId, int dim, int codim = 0 )
152  {
153  assert( (dim > 0) && (topologyId < numTopologies( dim )) );
154  assert( (0 <= codim) && (codim < dim) );
155  return (((topologyId & ~1) & (1u << (dim-codim-1))) == 0);
156  }
157 
169  inline bool isPrism ( unsigned int topologyId, int dim, int codim = 0 )
170  {
171  assert( (dim > 0) && (topologyId < numTopologies( dim )) );
172  assert( (0 <= codim) && (codim < dim) );
173  return (( (topologyId | 1) & (1u << (dim-codim-1))) != 0);
174  }
175 
188  inline bool isTopology ( TopologyConstruction construction, unsigned int topologyId, int dim, int codim = 0 )
189  {
190  assert( (dim > 0) && (topologyId < numTopologies( dim )) );
191  assert( (0 <= codim) && (codim <= dim) );
192  return (codim >= (dim-1)) || (((topologyId >> (dim-codim-1)) & 1) == (unsigned int)construction);
193  }
194 
202  inline unsigned int baseTopologyId ( unsigned int topologyId, int dim, int codim = 1 )
203  {
204  assert( (dim >= 0) && (topologyId < numTopologies( dim )) );
205  assert( (0 <= codim) && (codim <= dim) );
206  return topologyId & ((1u << (dim-codim)) - 1);
207  }
208 
209 
210 
211  // SimplexTopology
212  // ---------------
213 
214  template< unsigned int dim >
216  {
206  return topologyId & ((1u << (dim-codim)) - 1);
207  }
208 
209 
210 
211  // SimplexTopology
212  // ---------------
213 
214  template< unsigned int dim >
216  {
206  return topologyId & ((1u << (dim-codim)) - 1);
207  }
208 
209 
210 
211  // SimplexTopology
212  // ---------------
213 
214  template< unsigned int dim >
216  {
206  return topologyId & ((1u << (dim-codim)) - 1);
207  }
208 
209 
210 
211  // SimplexTopology
212  // ---------------
213 
214  template< unsigned int dim >
216  {
206  return topologyId & ((1u << (dim-codim)) - 1);
207  }
208 
209 
210 
211  // SimplexTopology
212  // ---------------
213 
214  template< unsigned int dim >
216  {
206  return topologyId & ((1u << (dim-codim)) - 1);
207  }
208 
209 
210 
211  // SimplexTopology
212  // ---------------
213 
214  template< unsigned int dim >
216  {
206  return topologyId & ((1u << (dim-codim)) - 1);
207  }
208 
209 
210 
211  // SimplexTopology
212  // ---------------
213 
214  template< unsigned int dim >
216  {
206  return topologyId & ((1u << (dim-codim)) - 1);
207  }
208 
209 
210 
211  // SimplexTopology
212  // ---------------
213 
214  template< unsigned int dim >
216  {
206  return topologyId & ((1u << (dim-codim)) - 1);
207  }
208 
209 
210 
211  // SimplexTopology
212  // ---------------
213 
214  template< unsigned int dim >
216  {
206  return topologyId & ((1u << (dim-codim)) - 1);
207  }
208 
209 
210 
211  // SimplexTopology
212  // ---------------
213 
214  template< unsigned int dim >
216  {
206  return topologyId & ((1u << (dim-codim)) - 1);
207  }
208 
209 
210 
211  // SimplexTopology
212  // ---------------
213 
214  template< unsigned int dim >
216  {
206  return topologyId & ((1u << (dim-codim)) - 1);
207  }
208 
209 
210 
211  // SimplexTopology
212  // ---------------
213 
214  template< unsigned int dim >
216  {
206  return topologyId & ((1u << (dim-codim)) - 1);
207  }
208 
209 
210 
211  // SimplexTopology
212  // ---------------
213 
214  template< unsigned int dim >
216  {
206  return topologyId & ((1u << (dim-codim)) - 1);
207  }
208 
209 
210 
211  // SimplexTopology
212  // ---------------
213 
214  template< unsigned int dim >
216  {
206  return topologyId & ((1u << (dim-codim)) - 1);
207  }
208 
209 
210 
211  // SimplexTopology
212  // ---------------
213 
214  template< unsigned int dim >
216  {
206  return topologyId & ((1u << (dim-codim)) - 1);
207  }
208 
209 
210 
211  // SimplexTopology
212  // ---------------
213 
214  template< unsigned int dim >
216  {
206  return topologyId & ((1u << (dim-codim)) - 1);
207  }
208 
209 
210 
211  // SimplexTopology
212  // ---------------
213 
214  template< unsigned int dim >
216  {
206  return topologyId & ((1u << (dim-codim)) - 1);
207  }
208 
209 
210 
211  // SimplexTopology
212  // ---------------
213 
214  template< unsigned int dim >
216  {
206  return topologyId & ((1u << (dim-codim)) - 1);
207  }
208 
209 
210 
211  // SimplexTopology
212  // ---------------
213 
214  template< unsigned int dim >
216  {
206  return topologyId & ((1u << (dim-codim)) - 1);
207  }
208 
209 
210 
211  // SimplexTopology
212  // ---------------
213 
214  template< unsigned int dim >
216  {
206  return topologyId & ((1u << (dim-codim)) - 1);
207  }
208 
209 
210 
211  // SimplexTopology
212  // ---------------
213 
214  template< unsigned int dim >
216  {
206  return topologyId & ((1u << (dim-codim)) - 1);
207  }
208 
209 
210 
211  // SimplexTopology
212  // ---------------
213 
214  template< unsigned int dim >
216  {
206  return topologyId & ((1u << (dim-codim)) - 1);
207  }
208 
209 
210 
211  // SimplexTopology
212  // ---------------