3 #ifndef DUNE_GEOMETRY_GENERICGEOMETRY_SUBTOPOLOGIES_HH
4 #define DUNE_GEOMETRY_GENERICGEOMETRY_SUBTOPOLOGIES_HH
9 #include <dune/common/forloop.hh>
10 #include <dune/common/static_assert.hh>
11 #include <dune/common/typetraits.hh>
12 #include <dune/common/visibility.hh>
13 #include <dune/common/unused.hh>
20 namespace GenericGeometry
23 template<
class Topology,
unsigned int codim >
26 template<
class Topology,
unsigned int codim,
unsigned int i >
29 template<
class Topology,
unsigned int codim,
unsigned int subcodim >
32 template<
class Topology,
unsigned int codim,
unsigned int subcodim >
35 template<
class Topology,
unsigned int codim,
unsigned int subcodim >
43 template<
class Topology,
unsigned int dim,
unsigned int codim >
46 template<
unsigned int dim,
unsigned int codim >
50 dune_static_assert( (dim == Topology :: dimension),
"Wrong dimension" );
51 dune_static_assert( (codim <= dim),
"Invalid codimension" );
57 template<
class BaseTopology,
unsigned int dim,
unsigned int codim >
61 dune_static_assert( (dim == Topology :: dimension),
"Wrong dimension" );
62 dune_static_assert( (codim <= dim),
"Invalid codimension" );
68 enum { value = n + 2*m };
71 template<
class BaseTopology,
unsigned int dim >
75 dune_static_assert( (dim == Topology :: dimension),
"Wrong dimension" );
81 template<
class BaseTopology,
unsigned int dim >
85 dune_static_assert( (dim == Topology :: dimension),
"Wrong dimension" );
93 template<
class BaseTopology,
unsigned int dim,
unsigned int codim >
97 dune_static_assert( (dim == Topology :: dimension),
"Wrong dimension" );
98 dune_static_assert( (codim <= dim),
"Invalid codimension" );
104 enum { value = m+n };
107 template<
class BaseTopology,
unsigned int dim >
111 dune_static_assert( (dim == Topology :: dimension),
"Wrong dimension" );
117 template<
class BaseTopology,
unsigned int dim >
121 dune_static_assert( (dim == Topology :: dimension),
"Wrong dimension" );
126 enum { value = m+1 };
130 template<
class Topology,
unsigned int codim >
140 unsigned int size (
unsigned int topologyId,
int dim,
int codim );
147 template<
class Topology,
unsigned int dim,
unsigned int codim,
unsigned int i >
150 template<
unsigned int dim,
unsigned int codim,
unsigned int i >
154 dune_static_assert( (dim == Topology :: dimension),
"Wrong dimension" );
155 dune_static_assert( (codim <= dim),
"Invalid codimension" );
157 "Invalid subentity index" );
163 template<
class BaseTopology,
unsigned int dim,
unsigned int codim,
unsigned int i >
167 dune_static_assert( (dim == Topology :: dimension),
"Wrong dimension" );
168 dune_static_assert( (codim <= dim),
"Invalid codimension" );
170 "Invalid subentity index" );
175 enum { s = (i < n+m ? 0 : 1) };
190 typedef typename conditional< (i < n), PrismSub<true>, BaseSub<false> > :: type :: type
type;
193 template<
class BaseTopology,
unsigned int dim,
unsigned int i >
197 dune_static_assert( (dim == Topology :: dimension),
"Wrong dimension" );
199 "Invalid subentity index" );
204 template<
class BaseTopology,
unsigned int dim,
unsigned int i >
208 dune_static_assert( (dim == Topology :: dimension),
"Wrong dimension" );
210 "Invalid subentity index" );
215 template<
class BaseTopology,
unsigned int dim,
unsigned int codim,
unsigned int i >
219 dune_static_assert( (dim == Topology :: dimension),
"Wrong dimension" );
220 dune_static_assert( (codim <= dim),
"Invalid codimension" );
222 "Invalid subentity index" );
239 typedef typename conditional< (i < m), BaseSub<true>, PyramidSub<false> > :: type :: type
type;
242 template<
class BaseTopology,
unsigned int dim,
unsigned int i >
246 dune_static_assert( (dim == Topology :: dimension),
"Wrong dimension" );
248 "Invalid subentity index" );
254 template<
class BaseTopology,
unsigned int dim,
unsigned int i >
258 dune_static_assert( (dim == Topology :: dimension),
"Wrong dimension" );
260 "Invalid subentity index" );
266 template<
class Topology,
unsigned int codim,
unsigned int i >
281 unsigned int subTopologyId (
unsigned int topologyId,
int dim,
int codim,
unsigned int i );
288 template<
class Topology,
unsigned int codim,
unsigned int subcodim >
298 ForLoop< Builder, 0, Size< Topology, codim > :: value-1 >
302 SubTopologySize (
const SubTopologySize & );
304 DUNE_EXPORT
static const SubTopologySize &instance ()
306 static SubTopologySize inst;
311 static unsigned int size (
unsigned int i )
314 return instance().size_[ i ];
318 template<
class Topology,
unsigned int codim,
unsigned int subcodim >
320 struct SubTopologySize< Topology, codim, subcodim > :: Builder
327 static void apply ( SubTopologySize &subTopologySize )
329 subTopologySize.size_[ i ] = Size< SubTopology, subcodim > :: value;
336 template<
class Topology,
unsigned int codim,
337 unsigned int subdim,
unsigned int subcodim >
341 unsigned int subdim,
unsigned int subcodim >
353 static unsigned int number (
unsigned int i,
unsigned int j )
355 const unsigned int s = (i < n+m ? 0 : 1);
360 const unsigned int ss = (j < ns+ms ? 0 : 1);
366 :: number( i, j-(ns+ss*ms) ) + nb + ss*mb;
374 template<
class BaseTopology,
unsigned int codim,
unsigned int subdim >
380 static unsigned int number (
unsigned int i,
unsigned int j )
382 DUNE_UNUSED_PARAMETER(j);
387 template<
class BaseTopology,
unsigned int codim,
unsigned int subdim >
398 static unsigned int number (
unsigned int i,
unsigned int j )
400 const unsigned int s = (i < n+m ? 0 : 1);
404 const unsigned int ss = (j < ms ? 0 : 1);
414 template<
class BaseTopology,
unsigned int codim,
415 unsigned int subdim,
unsigned int subcodim >
425 static unsigned int number (
unsigned int i,
unsigned int j )
443 template<
class BaseTopology,
unsigned int codim,
unsigned int subdim >
449 static unsigned int number (
unsigned int i,
unsigned int j )
451 DUNE_UNUSED_PARAMETER(j);
456 template<
class BaseTopology,
unsigned int codim,
unsigned int subdim >
466 static unsigned int number (
unsigned int i,
unsigned int j )
483 template<
class Topology,
unsigned int codim,
unsigned int subcodim >
484 class GenericSubTopologyNumbering
486 dune_static_assert( (codim <= Topology :: dimension),
"Invalid codimension" );
487 dune_static_assert( (codim + subcodim <= Topology :: dimension),
488 "Invalid subcodimension" );
493 static unsigned int number (
unsigned int i,
unsigned int j )
495 return (codim == 0 ? j : i );
502 static unsigned int number (
unsigned int i,
unsigned int j )
504 return GenericSubTopologyNumberingHelper
505 < Topology, codim, Topology :: dimension - codim, subcodim >
511 static unsigned int number (
unsigned int i,
unsigned int j )
515 < (codim == 0) || (codim == Topology :: dimension), BorderCodim<true>, InnerCodim<false> >
516 :: type :: number( i, j );
525 void subTopologyNumbering (
unsigned int topologyId,
int dim,
int codim,
unsigned int i,
int subcodim,
526 unsigned int *beginOut,
unsigned int *endOut );
533 template<
class Topology,
unsigned int codim,
unsigned int subcodim >
534 class SubTopologyNumbering
536 typedef GenericSubTopologyNumbering< Topology, codim, subcodim >
539 std :: vector< unsigned int > numbering_[ Size< Topology, codim > :: value ];
542 static unsigned int number (
unsigned int i,
unsigned int j )
545 return instance().numbering_[ i ][ j ];
551 for(
unsigned int i = 0; i < Size< Topology, codim > :: value; ++i )
554 numbering_[ i ].resize( size );
555 for(
unsigned int j = 0; j <
size; ++j )
556 numbering_[ i ][ j ] = GenericNumbering :: number( i, j );
560 DUNE_EXPORT
static const SubTopologyNumbering &instance ()
562 static SubTopologyNumbering inst;
571 template<
class Topology >
574 static const unsigned int dimension = Topology::dimension;
576 template<
class A,
class B >
579 static const unsigned int value = A::value + B::value;
582 template<
int codim >
588 template<
int codim >
591 static void apply (
unsigned int (&offsets)[ dimension+2 ] )
593 offsets[ codim+1 ] = offsets[ codim ] + Size< codim >::value;
598 static const unsigned int staticSize = GenericForLoop< StaticSum, Size, 0, dimension >::value;
603 ForLoop< CalcOffset, 0, dimension >::apply( offsets_ );
604 assert(
size() == staticSize );
607 unsigned int operator() (
const unsigned int codim,
const unsigned int subEntity )
const
609 const unsigned int offset = offsets_[ codim ];
610 assert( offset + subEntity < offsets_[ codim+1 ] );
611 return offset + subEntity;
616 return offsets_[ dimension+1 ];
620 unsigned int offsets_[ dimension+2 ];
627 #endif // #ifndef DUNE_GEOMETRY_GENERICGEOMETRY_SUBTOPOLOGIES_HH
SubTopologyMapper()
Definition: subtopologies.hh:600
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
static unsigned int number(unsigned int i, unsigned int j)
Definition: subtopologies.hh:542
SubTopologyImpl< Topology, Topology::dimension, codim, i >::type type
Definition: subtopologies.hh:269
static unsigned int number(unsigned int i, unsigned int j)
Definition: subtopologies.hh:425
Point type
Definition: subtopologies.hh:212
static unsigned int number(unsigned int i, unsigned int j)
Definition: subtopologies.hh:353
Definition: topologytypes.hh:57
unsigned int size() const
Definition: subtopologies.hh:614
Point type
Definition: subtopologies.hh:263
Statically compute the number of subentities of a given codimension.
Definition: subtopologies.hh:24
Definition: subtopologies.hh:133
Definition: subtopologies.hh:30
Pyramid< BaseTopology > Topology
Definition: subtopologies.hh:460
conditional< (i< n), PrismSub< true >, BaseSub< false > >::type::type type
Definition: subtopologies.hh:190
static unsigned int size(unsigned int i)
Definition: subtopologies.hh:311
unsigned int size(unsigned int topologyId, int dim, int codim)
Compute the number of subentities of a given codimension.
Definition: subtopologies.cc:16
conditional< (i< m), BaseSub< true >, PyramidSub< false > >::type::type type
Definition: subtopologies.hh:239
Definition: subtopologies.hh:338
Definition: subtopologies.hh:36
Definition: topologytypes.hh:41
Prism< BaseTopology > Topology
Definition: subtopologies.hh:345
Topology type
Definition: subtopologies.hh:160
static unsigned int number(unsigned int i, unsigned int j)
Definition: subtopologies.hh:398
Prism< BaseTopology > Topology
Definition: subtopologies.hh:378
Definition: topologytypes.hh:74
Definition: topologytypes.hh:26
Definition: subtopologies.hh:148
void subTopologyNumbering(unsigned int topologyId, int dim, int codim, unsigned int i, int subcodim, unsigned int *beginOut, unsigned int *endOut)
Definition: subtopologies.cc:85
Prism< BaseTopology > Topology
Definition: subtopologies.hh:391
static unsigned int number(unsigned int i, unsigned int j)
Definition: subtopologies.hh:449
Pyramid< BaseTopology > Topology
Definition: subtopologies.hh:447
static unsigned int number(unsigned int i, unsigned int j)
Definition: subtopologies.hh:511
Definition: subtopologies.hh:33
Definition: subtopologies.hh:572
static unsigned int number(unsigned int i, unsigned int j)
Definition: subtopologies.hh:466
static unsigned int number(unsigned int i, unsigned int j)
Definition: subtopologies.hh:380
Topology type
Definition: subtopologies.hh:251
Definition: subtopologies.hh:44
Pyramid< BaseTopology > Topology
Definition: subtopologies.hh:419
Topology type
Definition: subtopologies.hh:201
Definition: subtopologies.hh:27