1#ifndef DUNE_FEM_DOFMAPPER_COMPILE_HH
2#define DUNE_FEM_DOFMAPPER_COMPILE_HH
8#include <dune/geometry/referenceelements.hh>
11#include <dune/fem/space/mapper/code.hh>
12#include <dune/fem/space/mapper/localkey.hh>
23 template<
class RefElement,
24 std::enable_if_t< std::is_same< std::decay_t< decltype( std::declval< const RefElement & >().size( 0 ) ) >,
int >::value,
int > = 0,
25 std::enable_if_t< std::is_same< std::decay_t<
decltype( std::declval< const RefElement & >().type( 0, 0 ) ) >, GeometryType >::value,
int > = 0 >
26 inline DofMapperCode generateCodimensionCode (
const RefElement &refElement,
int codim,
unsigned int blockSize = 1 )
28 unsigned int count = refElement.size( codim );
29 DofMapperCodeWriter code( count, count*blockSize );
31 for(
unsigned int i = 0; i < count; ++i )
35 code[ pos++ ] = blockSize;
36 for(
unsigned int j = 0; j < blockSize; ++j )
37 code[ pos++ ] = i*blockSize + j;
47 template<
class RefElement,
class LocalCoefficients,
48 std::enable_if_t< std::is_same< std::decay_t< decltype( std::declval< const RefElement & >().size( 0 ) ) >,
int >::value,
int > = 0,
49 std::enable_if_t< std::is_same< std::decay_t<
decltype( std::declval< const RefElement & >().type( 0, 0 ) ) >, GeometryType >::value,
int > = 0 >
50 inline DofMapperCode compile (
const RefElement &refElement,
const LocalCoefficients &localCoefficients )
52 const int dim = RefElement::dimension;
54 const std::size_t numDofs = localCoefficients.size();
59 unsigned int numSubEntities = 0;
60 for(
int codim = 0; codim <= dim; ++codim )
61 numSubEntities += refElement.size( codim );
62 assert( numSubEntities > 0 );
69 unsigned int *count[ dim+1 ];
70 count[ 0 ] =
new unsigned int[ numSubEntities ];
72 std::fill( count[ 0 ], count[ 0 ] + numSubEntities, (
unsigned int)0 );
73 for(
int codim = 0; codim < dim; ++codim )
74 count[ codim+1 ] = count[ codim ] + refElement.size( codim );
83 unsigned int numBlocks = 0;
84 for( std::size_t i = 0; i < numDofs; ++i )
86 const LocalKey &key = localCoefficients.localKey( i );
88 const int codim = key.codim();
89 const int subEntity = key.subEntity();
91 assert( (codim >= 0) && (codim <= dim) );
92 assert( (subEntity >= 0) && (subEntity < refElement.size( codim )) );
94 if( count[ codim ][ subEntity ] == 0 )
96 ++count[ codim ][ subEntity ];
105 DofMapperCodeWriter code( numBlocks, numDofs );
107 unsigned int next = 0;
108 for(
int codim = 0; codim <= dim; ++codim )
110 for(
int i = 0; i < refElement.size( codim ); ++i )
112 const unsigned int cnt = count[ codim ][ i ];
118 code[ next++ ] = cnt;
120 count[ codim ][ i ] = next;
128 for( std::size_t i = 0; i < numDofs; ++i )
130 const LocalKey &key = localCoefficients.localKey( i );
131 const unsigned int block = count[ key.codim() ][ key.subEntity() ];
133 assert( (key.index() >= 0) && (key.index() < code[ block-1 ]) );
134 code[ block + key.index() ] = i;
static constexpr std::size_t index(const GeometryType >)
Compute the index for the given geometry type over all dimensions.
Definition: typeindex.hh:138
Dune namespace.
Definition: alignedallocator.hh:13
Helper classes to provide indices for geometrytypes for use in a vector.