3#ifndef DUNE_GEOMETRY_GENERICGEOMETRY_TOPOLOGYTYPES_HH
4#define DUNE_GEOMETRY_GENERICGEOMETRY_TOPOLOGYTYPES_HH
15 namespace GenericGeometry
18 enum TopologyConstruction { pyramidConstruction = 0, prismConstruction = 1 };
27 static const unsigned int dimension = 0;
28 static const unsigned int numCorners = 1;
30 static const unsigned int id = 0;
32 static std :: string name ()
39 template<
class BaseTopology >
42 static const unsigned int dimension = BaseTopology :: dimension + 1;
43 static const unsigned int numCorners = 2 * BaseTopology :: numCorners;
45 static const unsigned int id = BaseTopology::id | ((
unsigned int)prismConstruction << (dimension-1));
47 static std :: string name ()
49 return BaseTopology :: name() +
"l";
55 template<
class BaseTopology >
58 static const unsigned int dimension = BaseTopology :: dimension + 1;
59 static const unsigned int numCorners = BaseTopology :: numCorners + 1;
61 static const unsigned int id = BaseTopology::id | ((
unsigned int)pyramidConstruction << (dimension-1));
63 static std :: string name ()
65 return BaseTopology :: name() +
"o";
72 template<
class Topology >
75 template<
class Base >
76 struct BaseTopology< Prism< Base > >
81 template<
class Base >
82 struct BaseTopology< Pyramid< Base > >
89 template<
class Topology >
92 static const bool value = ((Topology::id >> 1) == 0);
95 template<
class Topology >
98 static const bool value = ((Topology::id | 1) == (1 << Topology::dimension) - 1);
101 template<
class Topology >
104 static const bool value
105 = !(IsSimplex< Topology >::value || IsCube< Topology >::value);
108 template<
class Topology >
109 struct IsGeneralizedPrism
111 static const bool value =
false;
114 template<
class BaseTopology >
115 struct IsGeneralizedPrism< Prism< BaseTopology > >
117 static const bool value
118 = (IsGeneralizedPrism< BaseTopology >::value || IsSimplex< BaseTopology >::value);
134 inline unsigned int numTopologies (
int dim )
150 inline bool isPyramid (
unsigned int topologyId,
int dim,
int codim = 0 )
152 assert( (dim > 0) && (topologyId < numTopologies( dim )) );
153 assert( (0 <= codim) && (codim < dim) );
154 return (((topologyId & ~1) & (1u << (dim-codim-1))) == 0);
168 inline bool isPrism (
unsigned int topologyId,
int dim,
int codim = 0 )
170 assert( (dim > 0) && (topologyId < numTopologies( dim )) );
171 assert( (0 <= codim) && (codim < dim) );
172 return (( (topologyId | 1) & (1u << (dim-codim-1))) != 0);
187 inline bool isTopology ( TopologyConstruction construction,
unsigned int topologyId,
int dim,
int codim = 0 )
189 assert( (dim > 0) && (topologyId < numTopologies( dim )) );
190 assert( (0 <= codim) && (codim <= dim) );
191 return (codim >= (dim-1)) || (((topologyId >> (dim-codim-1)) & 1) == (
unsigned int)construction);
201 inline unsigned int baseTopologyId (
unsigned int topologyId,
int dim,
int codim = 1 )
203 assert( (dim >= 0) && (topologyId < numTopologies( dim )) );
204 assert( (0 <= codim) && (codim <= dim) );
205 return topologyId & ((1u << (dim-codim)) - 1);
213 template<
unsigned int dim >
214 struct SimplexTopology
216 typedef Pyramid<
typename SimplexTopology< dim-1 >::type > type;
220 struct SimplexTopology< 0 >
230 template<
unsigned int dim >
233 typedef Prism<
typename CubeTopology< dim-1 >::type > type;
237 struct CubeTopology< 0 >
247 template<
unsigned int dim >
248 struct PyramidTopology
250 typedef Pyramid<
typename CubeTopology< dim-1 >::type > type;
258 template<
unsigned int dim >
261 typedef Prism<
typename SimplexTopology< dim-1 >::type > type;
269 template<
unsigned int id,
unsigned int dim >
272 static const unsigned int dimension = dim;
274 static_assert((
id < (1 << dimension)),
"id too large.");
276 static const bool isPrism = ((
id >> (dimension-1)) != 0);
278 typedef typename Topology< (
id & ~(1 << (dimension-1))), dimension-1 >::type
284 typedef GenericGeometry :: Prism< BaseTopology > type;
290 typedef GenericGeometry :: Pyramid< BaseTopology > type;
294 typedef typename conditional< isPrism, Prism<true>, Pyramid<false> >::type::type type;
297 template<
unsigned int id >
298 class Topology< id, 0 >
300 static const unsigned int dimension = 0;
302 static_assert((
id < (1 << dimension)),
"id too large.");
313 template<
template<
class >
class Operation,
int dim,
class Topology = Point >
316 typedef IfTopology< Operation, dim-1, Prism< Topology > > IfPrism;
317 typedef IfTopology< Operation, dim-1, Pyramid< Topology > > IfPyramid;
320 static void apply (
const unsigned int topologyId )
323 IfPrism::apply( topologyId >> 1 );
325 IfPyramid::apply( topologyId >> 1 );
329 static void apply (
const unsigned int topologyId, T1 &p1 )
332 IfPrism::apply( topologyId >> 1, p1 );
334 IfPyramid::apply( topologyId >> 1, p1 );
337 template<
class T1,
class T2 >
338 static void apply (
const unsigned int topologyId, T1 &p1, T2 &p2 )
341 IfPrism::apply( topologyId >> 1, p1, p2 );
343 IfPyramid::apply( topologyId >> 1, p1, p2 );
346 template<
class T1,
class T2,
class T3 >
347 static void apply (
const unsigned int topologyId, T1 &p1, T2 &p2, T3 &p3 )
350 IfPrism::apply( topologyId >> 1, p1, p2, p3 );
352 IfPyramid::apply( topologyId >> 1, p1, p2, p3 );
355 template<
class T1,
class T2,
class T3,
class T4 >
356 static void apply (
const unsigned int topologyId, T1 &p1, T2 &p2, T3 &p3, T4 &p4 )
359 IfPrism::apply( topologyId >> 1, p1, p2, p3, p4 );
361 IfPyramid::apply( topologyId >> 1, p1, p2, p3, p4 );
365 template<
template<
class >
class Operation,
class Topology >
366 class IfTopology< Operation, 0, Topology >
369 static void apply (
const unsigned int topologyId )
372 Operation< Topology >::apply();
376 static void apply (
const unsigned int topologyId, T1 &p1 )
379 Operation< Topology >::apply( p1 );
382 template<
class T1,
class T2 >
383 static void apply (
const unsigned int topologyId, T1 &p1, T2 &p2 )
386 Operation< Topology >::apply( p1, p2 );
389 template<
class T1,
class T2,
class T3 >
390 static void apply (
const unsigned int topologyId, T1 &p1, T2 &p2, T3 &p3 )
393 Operation< Topology >::apply( p1, p2, p3 );
396 template<
class T1,
class T2,
class T3,
class T4 >
397 static void apply (
const unsigned int topologyId, T1 &p1, T2 &p2, T3 &p3, T4 &p4 )
400 Operation< Topology >::apply( p1, p2, p3, p4 );
Dune namespace.
Definition: alignment.hh:10
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