3#ifndef DUNE_GEOMETRY_GENERICGEOMETRY_TOPOLOGYTYPES_HH
4#define DUNE_GEOMETRY_GENERICGEOMETRY_TOPOLOGYTYPES_HH
16 namespace GenericGeometry
19 enum TopologyConstruction { pyramidConstruction = 0, prismConstruction = 1 };
28 static const unsigned int dimension = 0;
29 static const unsigned int numCorners = 1;
31 static const unsigned int id = 0;
33 static std :: string name ()
40 template<
class BaseTopology >
43 static const unsigned int dimension = BaseTopology :: dimension + 1;
44 static const unsigned int numCorners = 2 * BaseTopology :: numCorners;
46 static const unsigned int id = BaseTopology::id | ((
unsigned int)prismConstruction << (dimension-1));
48 static std :: string name ()
50 return BaseTopology :: name() +
"l";
56 template<
class BaseTopology >
59 static const unsigned int dimension = BaseTopology :: dimension + 1;
60 static const unsigned int numCorners = BaseTopology :: numCorners + 1;
62 static const unsigned int id = BaseTopology::id | ((
unsigned int)pyramidConstruction << (dimension-1));
64 static std :: string name ()
66 return BaseTopology :: name() +
"o";
73 template<
class Topology >
76 template<
class Base >
77 struct BaseTopology< Prism< Base > >
82 template<
class Base >
83 struct BaseTopology< Pyramid< Base > >
90 template<
class Topology >
93 static const bool value = ((Topology::id >> 1) == 0);
96 template<
class Topology >
99 static const bool value = ((Topology::id | 1) == (1 << Topology::dimension) - 1);
102 template<
class Topology >
105 static const bool value
106 = !(IsSimplex< Topology >::value || IsCube< Topology >::value);
109 template<
class Topology >
110 struct IsGeneralizedPrism
112 static const bool value =
false;
115 template<
class BaseTopology >
116 struct IsGeneralizedPrism< Prism< BaseTopology > >
118 static const bool value
119 = (IsGeneralizedPrism< BaseTopology >::value || IsSimplex< BaseTopology >::value);
135 inline unsigned int numTopologies (
int dim )
151 inline bool isPyramid (
unsigned int topologyId,
int dim,
int codim = 0 )
153 assert( (dim > 0) && (topologyId < numTopologies( dim )) );
154 assert( (0 <= codim) && (codim < dim) );
155 return (((topologyId & ~1) & (1u << (dim-codim-1))) == 0);
169 inline bool isPrism (
unsigned int topologyId,
int dim,
int codim = 0 )
171 assert( (dim > 0) && (topologyId < numTopologies( dim )) );
172 assert( (0 <= codim) && (codim < dim) );
173 return (( (topologyId | 1) & (1u << (dim-codim-1))) != 0);
188 inline bool isTopology ( TopologyConstruction construction,
unsigned int topologyId,
int dim,
int codim = 0 )
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);
202 inline unsigned int baseTopologyId (
unsigned int topologyId,
int dim,
int codim = 1 )
204 assert( (dim >= 0) && (topologyId < numTopologies( dim )) );
205 assert( (0 <= codim) && (codim <= dim) );
206 return topologyId & ((1u << (dim-codim)) - 1);
214 template<
unsigned int dim >
215 struct SimplexTopology
217 typedef Pyramid<
typename SimplexTopology< dim-1 >::type > type;
221 struct SimplexTopology< 0 >
231 template<
unsigned int dim >
234 typedef Prism<
typename CubeTopology< dim-1 >::type > type;
238 struct CubeTopology< 0 >
248 template<
unsigned int dim >
249 struct PyramidTopology
251 typedef Pyramid<
typename CubeTopology< dim-1 >::type > type;
259 template<
unsigned int dim >
262 typedef Prism<
typename SimplexTopology< dim-1 >::type > type;
270 template<
unsigned int id,
unsigned int dim >
273 static const unsigned int dimension = dim;
277 static const bool isPrism = ((
id >> (dimension-1)) != 0);
279 typedef typename Topology< (
id & ~(1 << (dimension-1))), dimension-1 >::type
285 typedef GenericGeometry :: Prism< BaseTopology > type;
291 typedef GenericGeometry :: Pyramid< BaseTopology > type;
295 typedef typename conditional< isPrism, Prism<true>, Pyramid<false> >::type::type type;
298 template<
unsigned int id >
299 class Topology< id, 0 >
301 static const unsigned int dimension = 0;
314 template<
template<
class >
class Operation,
int dim,
class Topology = Point >
317 typedef IfTopology< Operation, dim-1, Prism< Topology > > IfPrism;
318 typedef IfTopology< Operation, dim-1, Pyramid< Topology > > IfPyramid;
321 static void apply (
const unsigned int topologyId )
324 IfPrism::apply( topologyId >> 1 );
326 IfPyramid::apply( topologyId >> 1 );
330 static void apply (
const unsigned int topologyId, T1 &p1 )
333 IfPrism::apply( topologyId >> 1, p1 );
335 IfPyramid::apply( topologyId >> 1, p1 );
338 template<
class T1,
class T2 >
339 static void apply (
const unsigned int topologyId, T1 &p1, T2 &p2 )
342 IfPrism::apply( topologyId >> 1, p1, p2 );
344 IfPyramid::apply( topologyId >> 1, p1, p2 );
347 template<
class T1,
class T2,
class T3 >
348 static void apply (
const unsigned int topologyId, T1 &p1, T2 &p2, T3 &p3 )
351 IfPrism::apply( topologyId >> 1, p1, p2, p3 );
353 IfPyramid::apply( topologyId >> 1, p1, p2, p3 );
356 template<
class T1,
class T2,
class T3,
class T4 >
357 static void apply (
const unsigned int topologyId, T1 &p1, T2 &p2, T3 &p3, T4 &p4 )
360 IfPrism::apply( topologyId >> 1, p1, p2, p3, p4 );
362 IfPyramid::apply( topologyId >> 1, p1, p2, p3, p4 );
366 template<
template<
class >
class Operation,
class Topology >
367 class IfTopology< Operation, 0, Topology >
370 static void apply (
const unsigned int topologyId )
373 Operation< Topology >::apply();
377 static void apply (
const unsigned int topologyId, T1 &p1 )
380 Operation< Topology >::apply( p1 );
383 template<
class T1,
class T2 >
384 static void apply (
const unsigned int topologyId, T1 &p1, T2 &p2 )
387 Operation< Topology >::apply( p1, p2 );
390 template<
class T1,
class T2,
class T3 >
391 static void apply (
const unsigned int topologyId, T1 &p1, T2 &p2, T3 &p3 )
394 Operation< Topology >::apply( p1, p2, p3 );
397 template<
class T1,
class T2,
class T3,
class T4 >
398 static void apply (
const unsigned int topologyId, T1 &p1, T2 &p2, T3 &p3, T4 &p4 )
401 Operation< Topology >::apply( p1, p2, p3, p4 );
#define dune_static_assert(COND, MSG)
Helper template so that compilation fails if condition is not true.
Definition: static_assert.hh:79
Dune namespace.
Definition: alignment.hh:14
Fallback implementation of the C++0x static_assert feature.
Traits for type conversions and type information.
Definition of the DUNE_UNUSED macro for the case that config.h is not available.
#define DUNE_UNUSED_PARAMETER(parm)
A macro to mark intentional unused function parameters with.
Definition: unused.hh:18