1#ifndef DUNE_FEM_DOFMAPPER_CODE_HH
2#define DUNE_FEM_DOFMAPPER_CODE_HH
20 typedef const unsigned int *ConstIterator;
21 typedef unsigned int *Iterator;
23 DofMapperCode (
unsigned int numBlocks,
unsigned int numDofs )
25 code_ =
new unsigned int[
size( numBlocks, numDofs ) ];
26 code_[ 0 ] = numBlocks;
33 code_ =
new unsigned int[
size( 0, 0 ) ];
34 code_[ 1 ] = code_[ 0 ] = 0;
37 DofMapperCode (
const DofMapperCode &other )
39 code_ =
new unsigned int[ other.size() ];
40 std::copy( ConstIterator( other.code_ ), other.end(), code_ );
48 const DofMapperCode &operator= (
const DofMapperCode &other )
50 if(
size() != other.size() )
53 code_ =
new unsigned int[ other.size() ];
55 std::copy( ConstIterator( other.code_ ), other.end(), code_ );
78 template<
class Functor >
79 void operator() ( Functor f )
const
81 for( ConstIterator it = begin(); it != end(); )
83 const unsigned int gtIndex = *(it++);
84 const unsigned int subEntity = *(it++);
85 unsigned int nDofs = *(it++);
86 f( gtIndex, subEntity, ConstIterator( it ), ConstIterator( it + nDofs ) );
91 unsigned int numBlocks ()
const {
return code_[ 0 ]; }
92 unsigned int numDofs ()
const {
return code_[ 1 ]; }
94 friend std::ostream &operator<< ( std::ostream &out,
const DofMapperCode &code )
96 out <<
"{ " << code.numBlocks() <<
", " << code.numDofs();
97 for( DofMapperCode::ConstIterator it = code.begin(); it != code.end(); ++it )
103 ConstIterator begin ()
const {
return code_ + 2; }
104 Iterator begin () {
return code_ + 2; }
105 ConstIterator end ()
const {
return code_ +
size(); }
106 Iterator end () {
return code_ +
size(); }
108 std::size_t
size ()
const {
return size( numBlocks(), numDofs() ); }
116 static std::size_t
size (
unsigned int numBlocks,
unsigned int numDofs )
118 return 2 + 3*numBlocks + numDofs;
150 class DofMapperCodeWriter
151 :
public DofMapperCode
154 DofMapperCodeWriter (
unsigned int numBlocks,
unsigned int numDofs )
155 : DofMapperCode( numBlocks, numDofs )
158 const unsigned int &operator[] (
unsigned int i )
const
160 assert( (std::ptrdiff_t)i < end() - begin() );
164 unsigned int &operator[] (
unsigned int i )
166 assert( (std::ptrdiff_t)i < end() - begin() );
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75