1 #ifndef DUNE_FEM_DOFMAPPER_COMPILE_HH 2 #define DUNE_FEM_DOFMAPPER_COMPILE_HH 6 #include <dune/geometry/referenceelements.hh> 7 #include <dune/geometry/typeindex.hh> 21 template<
class Field,
int dim >
25 unsigned int count = refElement.
size( codim );
27 for(
unsigned int i = 0; i < count; ++i )
29 code[ 4*i+0 ] = GlobalGeometryTypeIndex::index( refElement.type( i, codim ) );
42 template<
class Field,
int dim,
class LocalCoefficients >
44 compile (
const Dune::ReferenceElement< Field, dim > &refElement,
45 const LocalCoefficients &localCoefficients )
47 const std::size_t numDofs = localCoefficients.
size();
52 unsigned int numSubEntities = 0;
53 for(
int codim = 0; codim <= dim; ++codim )
54 numSubEntities += refElement.size( codim );
55 assert( numSubEntities > 0 );
62 unsigned int *count[ dim+1 ];
63 count[ 0 ] =
new unsigned int[ numSubEntities ];
65 std::fill( count[ 0 ], count[ 0 ] + numSubEntities, (
unsigned int)0 );
66 for(
int codim = 0; codim < dim; ++codim )
67 count[ codim+1 ] = count[ codim ] + refElement.size( codim );
76 unsigned int numBlocks = 0;
77 for( std::size_t i = 0; i < numDofs; ++i )
79 const LocalKey &key = localCoefficients.localKey( i );
81 const int codim = key.
codim();
84 assert( (codim >= 0) && (codim <= dim) );
85 assert( (subEntity >= 0) && (subEntity < refElement.size( codim )) );
87 if( count[ codim ][ subEntity ] == 0 )
89 ++count[ codim ][ subEntity ];
100 unsigned int next = 0;
101 for(
int codim = 0; codim <= dim; ++codim )
103 for(
int i = 0; i < refElement.size( codim ); ++i )
105 const unsigned int cnt = count[ codim ][ i ];
109 code[ next++ ] = GlobalGeometryTypeIndex::index( refElement.type( i, codim ) );
111 code[ next++ ] = cnt;
113 count[ codim ][ i ] = next;
121 for( std::size_t i = 0; i < numDofs; ++i )
123 const LocalKey &key = localCoefficients.localKey( i );
124 const unsigned int block = count[ key.
codim() ][ key.
subEntity() ];
126 assert( (key.
index() >= 0) && (key.
index() < code[ block-1 ]) );
127 code[ block + key.
index() ] = i;
141 #endif // #ifndef DUNE_FEM_DOFMAPPER_COMPILE_HH unsigned int codim() const
Definition: localkey.hh:27
DofMapperCode compile(const Dune::ReferenceElement< Field, dim > &refElement, const LocalCoefficients &localCoefficients)
Definition: compile.hh:44
Definition: coordinate.hh:4
unsigned int subEntity() const
Definition: localkey.hh:26
DofMapperCode generateCodimensionCode(const Dune::ReferenceElement< Field, dim > &refElement, int codim)
Definition: compile.hh:23
std::size_t size() const
Definition: code.hh:108
unsigned int index() const
Definition: localkey.hh:28
Definition: localkey.hh:20