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 >
29 class SubTopologySize;
31 template<
class Topology,
unsigned int codim,
unsigned int subcodim >
32 class GenericSubTopologyNumbering;
34 template<
class Topology,
unsigned int codim,
unsigned int subcodim >
35 class SubTopologyNumbering;
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");
155 static_assert((i < Size< Topology, codim > :: value),
"Invalid subentity index");
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");
167 static_assert((i < Size< Topology, codim > :: value),
"Invalid subentity index");
172 enum { s = (i < n+m ? 0 : 1) };
187 typedef typename std::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");
195 static_assert((i < Size< Topology, 0 > :: value),
"Invalid subentity index");
200 template<
class BaseTopology,
unsigned int dim,
unsigned int i >
204 static_assert((dim == Topology :: dimension),
"Wrong dimension");
205 static_assert((i < Size< Topology, dim > :: value),
"Invalid subentity index");
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" );
216 static_assert((i < Size< Topology, codim > :: value),
"Invalid subentity index");
233 typedef typename std::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");
241 static_assert((i < Size< Topology, 0 > :: value),
"Invalid subentity index");
247 template<
class BaseTopology,
unsigned int dim,
unsigned int i >
251 static_assert((dim == Topology :: dimension),
"Wrong dimension");
252 static_assert((i < Size< Topology, dim > :: value),
"Invalid subentity index");
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 >
303 static unsigned int size (
unsigned int i )
306 return instance().size_[ i ];
310 template<
class Topology,
unsigned int codim,
unsigned int subcodim >
314 typedef GenericGeometry :: SubTopologySize< Topology, codim, subcodim >
316 typedef typename GenericGeometry :: SubTopology< Topology, codim, i > :: type
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 >
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 )
496 <
Topology, codim, Topology :: dimension - codim, subcodim >
502 static unsigned int number (
unsigned int i,
unsigned int j )
505 return std::conditional
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 >
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_ );
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 ];
Definition affinegeometry.hh:19
void subTopologyNumbering(unsigned int topologyId, int dim, int codim, unsigned int i, int subcodim, unsigned int *beginOut, unsigned int *endOut)
Definition subtopologies.cc:85
unsigned int size(unsigned int topologyId, int dim, int codim)
Compute the number of subentities of a given codimension.
Definition subtopologies.cc:16
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
Statically compute the number of subentities of a given codimension.
Definition subtopologies.hh:131
@ value
Definition subtopologies.hh:132
Definition subtopologies.hh:260
SubTopologyImpl< Topology, Topology::dimension, codim, i >::type type
Definition subtopologies.hh:261
Definition subtopologies.hh:282
static unsigned int size(unsigned int i)
Definition subtopologies.hh:303
Definition subtopologies.hh:477
static unsigned int number(unsigned int i, unsigned int j)
Definition subtopologies.hh:502
Definition subtopologies.hh:526
static unsigned int number(unsigned int i, unsigned int j)
Definition subtopologies.hh:533
Definition subtopologies.hh:43
Definition subtopologies.hh:147
Topology type
Definition subtopologies.hh:158
std::conditional<(i< n), PrismSub< true >, BaseSub< false > >::type::type type
Definition subtopologies.hh:187
Topology type
Definition subtopologies.hh:197
Point type
Definition subtopologies.hh:207
std::conditional<(i< m), BaseSub< true >, PyramidSub< false > >::type::type type
Definition subtopologies.hh:233
Topology type
Definition subtopologies.hh:244
Point type
Definition subtopologies.hh:255
Definition subtopologies.hh:313
GenericGeometry ::SubTopologySize< Topology, codim, subcodim > SubTopologySize
Definition subtopologies.hh:315
static void apply(SubTopologySize &subTopologySize)
Definition subtopologies.hh:319
GenericGeometry::SubTopology< Topology, codim, i >::type SubTopology
Definition subtopologies.hh:317
Definition subtopologies.hh:330
Prism< BaseTopology > Topology
Definition subtopologies.hh:337
static unsigned int number(unsigned int i, unsigned int j)
Definition subtopologies.hh:345
Prism< BaseTopology > Topology
Definition subtopologies.hh:370
static unsigned int number(unsigned int i, unsigned int j)
Definition subtopologies.hh:372
Prism< BaseTopology > Topology
Definition subtopologies.hh:383
static unsigned int number(unsigned int i, unsigned int j)
Definition subtopologies.hh:390
static unsigned int number(unsigned int i, unsigned int j)
Definition subtopologies.hh:417
Pyramid< BaseTopology > Topology
Definition subtopologies.hh:411
Pyramid< BaseTopology > Topology
Definition subtopologies.hh:439
static unsigned int number(unsigned int i, unsigned int j)
Definition subtopologies.hh:441
static unsigned int number(unsigned int i, unsigned int j)
Definition subtopologies.hh:458
Pyramid< BaseTopology > Topology
Definition subtopologies.hh:452
Definition subtopologies.hh:564
unsigned int size() const
Definition subtopologies.hh:605
static const unsigned int staticSize
Definition subtopologies.hh:589
unsigned int operator()(const unsigned int codim, const unsigned int subEntity) const
Definition subtopologies.hh:598
SubTopologyMapper()
Definition subtopologies.hh:591
Definition topologytypes.hh:26
Definition topologytypes.hh:41
Definition topologytypes.hh:57
Definition topologytypes.hh:73
Definition topologytypes.hh:271