dune-fem  2.8-git
mapgeomtype.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_MISC_MAPGEOMTYPE_HH
2 #define DUNE_FEM_MISC_MAPGEOMTYPE_HH
3 
4 //- C++ includes
5 #include <vector>
6 
7 //- dune-geometry includes
8 #include <dune/geometry/type.hh>
9 #include <dune/geometry/typeindex.hh>
10 
11 
12 namespace Dune
13 {
14 
15  namespace Fem
16  {
17 
18  // MapGeometryType
19  // ---------------
20 
21  template< int dim, class T >
23  {
25  static const int dimension = dim;
26 
28  MapGeometryType ( const T &value = T() )
29  {
30  const size_t size = Dune::LocalGeometryTypeIndex::size( dimension - 1 );
31  data_.resize( size, 0 );
32  }
33 
35  const int &operator[] ( const GeometryType &type ) const
36  {
37  const size_t index = Dune::LocalGeometryTypeIndex::index( type );
38  return data_[ index ];
39  }
40 
42  int &operator[] ( const GeometryType &type )
43  {
44  return const_cast< int & >( static_cast< const MapGeometryType & >( *this ).operator[]( type ) );
45  }
46 
47  private:
48  std::vector< T > data_;
49  };
50 
51  } // namespace Fem
52 
53 } // namespace Dune
54 
55 #endif // #ifndef DUNE_FEM_MISC_MAPGEOMTYPE_HH
Definition: bindguard.hh:11
Definition: mapgeomtype.hh:23
static const int dimension
dimension
Definition: mapgeomtype.hh:25
const int & operator[](const GeometryType &type) const
return const reference to data
Definition: mapgeomtype.hh:35
MapGeometryType(const T &value=T())
constructor
Definition: mapgeomtype.hh:28