3 #ifndef DUNE_GEOMETRY_GENERICGEOMETRY_SUBTOPOLOGIES_HH
4 #define DUNE_GEOMETRY_GENERICGEOMETRY_SUBTOPOLOGIES_HH
9 #include <dune/common/forloop.hh>
10 #include <dune/common/typetraits.hh>
11 #include <dune/common/visibility.hh>
12 #include <dune/common/unused.hh>
19 namespace GenericGeometry
22 template<
class Topology,
unsigned int codim >
25 template<
class Topology,
unsigned int codim,
unsigned int i >
28 template<
class Topology,
unsigned int codim,
unsigned int subcodim >
31 template<
class Topology,
unsigned int codim,
unsigned int subcodim >
34 template<
class Topology,
unsigned int codim,
unsigned int subcodim >
42 template<
class Topology,
unsigned int dim,
unsigned int codim >
45 template<
unsigned int dim,
unsigned int codim >
49 static_assert((dim == Topology :: dimension),
"Wrong dimension");
50 static_assert((codim <= dim),
"Invalid codimension");
56 template<
class BaseTopology,
unsigned int dim,
unsigned int codim >
60 static_assert((dim == Topology :: dimension),
"Wrong dimension");
61 static_assert((codim <= dim),
"Invalid codimension");
67 enum { value = n + 2*m };
70 template<
class BaseTopology,
unsigned int dim >
74 static_assert((dim == Topology :: dimension),
"Wrong dimension");
80 template<
class BaseTopology,
unsigned int dim >
84 static_assert((dim == Topology :: dimension),
"Wrong dimension");
92 template<
class BaseTopology,
unsigned int dim,
unsigned int codim >
96 static_assert((dim == Topology :: dimension),
"Wrong dimension");
97 static_assert((codim <= dim),
"Invalid codimension");
103 enum { value = m+n };
106 template<
class BaseTopology,
unsigned int dim >
110 static_assert((dim == Topology :: dimension),
"Wrong dimension");
116 template<
class BaseTopology,
unsigned int dim >
120 static_assert((dim == Topology :: dimension),
"Wrong dimension");
125 enum { value = m+1 };
129 template<
class Topology,
unsigned int codim >
139 unsigned int size (
unsigned int topologyId,
int dim,
int codim );
146 template<
class Topology,
unsigned int dim,
unsigned int codim,
unsigned int i >
149 template<
unsigned int dim,
unsigned int codim,
unsigned int i >
153 static_assert((dim == Topology :: dimension),
"Wrong dimension");
154 static_assert((codim <= dim),
"Invalid codimension");
158 typedef Topology
type;
161 template<
class BaseTopology,
unsigned int dim,
unsigned int codim,
unsigned int i >
165 static_assert((dim == Topology :: dimension),
"Wrong dimension");
166 static_assert((codim <= dim),
"Invalid codimension");
172 enum { s = (i < n+m ? 0 : 1) };
187 typedef typename conditional< (i < n), PrismSub<true>, BaseSub<false> > :: type :: type
type;
190 template<
class BaseTopology,
unsigned int dim,
unsigned int i >
194 static_assert((dim == Topology :: dimension),
"Wrong dimension");
197 typedef Topology
type;
200 template<
class BaseTopology,
unsigned int dim,
unsigned int i >
204 static_assert((dim == Topology :: dimension),
"Wrong dimension");
210 template<
class BaseTopology,
unsigned int dim,
unsigned int codim,
unsigned int i >
214 static_assert((dim == Topology :: dimension),
"Wrong dimension");
215 static_assert((codim <= dim),
"Invalid codimension" );
233 typedef typename conditional< (i < m), BaseSub<true>, PyramidSub<false> > :: type :: type
type;
236 template<
class BaseTopology,
unsigned int dim,
unsigned int i >
240 static_assert((dim == Topology :: dimension),
"Wrong dimension");
244 typedef Topology
type;
247 template<
class BaseTopology,
unsigned int dim,
unsigned int i >
251 static_assert((dim == Topology :: dimension),
"Wrong dimension");
258 template<
class Topology,
unsigned int codim,
unsigned int i >
273 unsigned int subTopologyId (
unsigned int topologyId,
int dim,
int codim,
unsigned int i );
280 template<
class Topology,
unsigned int codim,
unsigned int subcodim >
290 ForLoop< Builder, 0, Size< Topology, codim > :: value-1 >
294 SubTopologySize (
const SubTopologySize & );
296 DUNE_EXPORT
static const SubTopologySize &instance ()
298 static SubTopologySize inst;
303 static unsigned int size (
unsigned int i )
306 return instance().size_[ i ];
310 template<
class Topology,
unsigned int codim,
unsigned int subcodim >
312 struct SubTopologySize< Topology, codim, subcodim > :: Builder
319 static void apply ( SubTopologySize &subTopologySize )
321 subTopologySize.size_[ i ] = Size< SubTopology, subcodim > :: value;
328 template<
class Topology,
unsigned int codim,
329 unsigned int subdim,
unsigned int subcodim >
333 unsigned int subdim,
unsigned int subcodim >
345 static unsigned int number (
unsigned int i,
unsigned int j )
347 const unsigned int s = (i < n+m ? 0 : 1);
352 const unsigned int ss = (j < ns+ms ? 0 : 1);
358 :: number( i, j-(ns+ss*ms) ) + nb + ss*mb;
366 template<
class BaseTopology,
unsigned int codim,
unsigned int subdim >
372 static unsigned int number (
unsigned int i,
unsigned int j )
374 DUNE_UNUSED_PARAMETER(j);
379 template<
class BaseTopology,
unsigned int codim,
unsigned int subdim >
390 static unsigned int number (
unsigned int i,
unsigned int j )
392 const unsigned int s = (i < n+m ? 0 : 1);
396 const unsigned int ss = (j < ms ? 0 : 1);
406 template<
class BaseTopology,
unsigned int codim,
407 unsigned int subdim,
unsigned int subcodim >
417 static unsigned int number (
unsigned int i,
unsigned int j )
435 template<
class BaseTopology,
unsigned int codim,
unsigned int subdim >
441 static unsigned int number (
unsigned int i,
unsigned int j )
443 DUNE_UNUSED_PARAMETER(j);
448 template<
class BaseTopology,
unsigned int codim,
unsigned int subdim >
458 static unsigned int number (
unsigned int i,
unsigned int j )
475 template<
class Topology,
unsigned int codim,
unsigned int subcodim >
476 class GenericSubTopologyNumbering
478 static_assert((codim <= Topology :: dimension),
"Invalid codimension");
479 static_assert((codim + subcodim <= Topology :: dimension),
"Invalid subcodimension");
484 static unsigned int number (
unsigned int i,
unsigned int j )
486 return (codim == 0 ? j : i );
493 static unsigned int number (
unsigned int i,
unsigned int j )
495 return GenericSubTopologyNumberingHelper
496 < Topology, codim, Topology :: dimension - codim, subcodim >
502 static unsigned int number (
unsigned int i,
unsigned int j )
506 < (codim == 0) || (codim == Topology :: dimension), BorderCodim<true>, InnerCodim<false> >
507 :: type :: number( i, j );
516 void subTopologyNumbering (
unsigned int topologyId,
int dim,
int codim,
unsigned int i,
int subcodim,
517 unsigned int *beginOut,
unsigned int *endOut );
524 template<
class Topology,
unsigned int codim,
unsigned int subcodim >
525 class SubTopologyNumbering
527 typedef GenericSubTopologyNumbering< Topology, codim, subcodim >
530 std :: vector< unsigned int > numbering_[ Size< Topology, codim > :: value ];
533 static unsigned int number (
unsigned int i,
unsigned int j )
536 return instance().numbering_[ i ][ j ];
542 for(
unsigned int i = 0; i < Size< Topology, codim > :: value; ++i )
545 numbering_[ i ].resize( size );
546 for(
unsigned int j = 0; j <
size; ++j )
547 numbering_[ i ][ j ] = GenericNumbering :: number( i, j );
551 DUNE_EXPORT
static const SubTopologyNumbering &instance ()
553 static SubTopologyNumbering inst;
562 template<
class Topology >
565 static const unsigned int dimension = Topology::dimension;
567 template<
class A,
class B >
570 static const unsigned int value = A::value + B::value;
573 template<
int codim >
579 template<
int codim >
582 static void apply (
unsigned int (&offsets)[ dimension+2 ] )
584 offsets[ codim+1 ] = offsets[ codim ] + Size< codim >::value;
589 static const unsigned int staticSize = GenericForLoop< StaticSum, Size, 0, dimension >::value;
594 ForLoop< CalcOffset, 0, dimension >::apply( offsets_ );
595 assert(
size() == staticSize );
598 unsigned int operator() (
const unsigned int codim,
const unsigned int subEntity )
const
600 const unsigned int offset = offsets_[ codim ];
601 assert( offset + subEntity < offsets_[ codim+1 ] );
602 return offset + subEntity;
607 return offsets_[ dimension+1 ];
611 unsigned int offsets_[ dimension+2 ];
618 #endif // #ifndef DUNE_GEOMETRY_GENERICGEOMETRY_SUBTOPOLOGIES_HH
static unsigned int number(unsigned int i, unsigned int j)
Definition: subtopologies.hh:502
Definition: topologytypes.hh:40
static unsigned int number(unsigned int i, unsigned int j)
Definition: subtopologies.hh:441
unsigned int subTopologyId(unsigned int topologyId, int dim, int codim, unsigned int i)
Compute the topology id of a given subentity.
Definition: subtopologies.cc:47
Definition: affinegeometry.hh:18
Definition: subtopologies.hh:43
static unsigned int number(unsigned int i, unsigned int j)
Definition: subtopologies.hh:533
Definition: subtopologies.hh:35
unsigned int size(unsigned int topologyId, int dim, int codim)
Compute the number of subentities of a given codimension.
Definition: subtopologies.cc:16
Pyramid< BaseTopology > Topology
Definition: subtopologies.hh:411
Prism< BaseTopology > Topology
Definition: subtopologies.hh:370
Definition: subtopologies.hh:147
Statically compute the number of subentities of a given codimension.
Definition: subtopologies.hh:23
Definition: topologytypes.hh:56
Point type
Definition: subtopologies.hh:204
Definition: subtopologies.hh:563
Definition: topologytypes.hh:25
Pyramid< BaseTopology > Topology
Definition: subtopologies.hh:439
conditional< (i< n), PrismSub< true >, BaseSub< false > >::type::type type
Definition: subtopologies.hh:187
Prism< BaseTopology > Topology
Definition: subtopologies.hh:383
static unsigned int number(unsigned int i, unsigned int j)
Definition: subtopologies.hh:390
Definition: subtopologies.hh:330
static unsigned int number(unsigned int i, unsigned int j)
Definition: subtopologies.hh:417
Topology type
Definition: subtopologies.hh:194
Topology type
Definition: subtopologies.hh:153
static unsigned int number(unsigned int i, unsigned int j)
Definition: subtopologies.hh:372
conditional< (i< m), BaseSub< true >, PyramidSub< false > >::type::type type
Definition: subtopologies.hh:233
Topology type
Definition: subtopologies.hh:240
Definition: subtopologies.hh:26
Pyramid< BaseTopology > Topology
Definition: subtopologies.hh:452
static unsigned int number(unsigned int i, unsigned int j)
Definition: subtopologies.hh:345
Definition: subtopologies.hh:32
unsigned int size() const
Definition: subtopologies.hh:605
Definition: subtopologies.hh:132
Definition: topologytypes.hh:73
void subTopologyNumbering(unsigned int topologyId, int dim, int codim, unsigned int i, int subcodim, unsigned int *beginOut, unsigned int *endOut)
Definition: subtopologies.cc:85
SubTopologyMapper()
Definition: subtopologies.hh:591
Prism< BaseTopology > Topology
Definition: subtopologies.hh:337
Definition: subtopologies.hh:29
SubTopologyImpl< Topology, Topology::dimension, codim, i >::type type
Definition: subtopologies.hh:261
static unsigned int size(unsigned int i)
Definition: subtopologies.hh:303
Point type
Definition: subtopologies.hh:251
static unsigned int number(unsigned int i, unsigned int j)
Definition: subtopologies.hh:458