dune-grid
2.1.1
|
00001 #ifndef DUNE_GEOGRID_INDEXSETS_HH 00002 #define DUNE_GEOGRID_INDEXSETS_HH 00003 00004 #include <vector> 00005 00006 #include <dune/common/typetraits.hh> 00007 00008 #include <dune/grid/common/gridenums.hh> 00009 #include <dune/grid/common/indexidset.hh> 00010 00011 #include <dune/grid/geometrygrid/capabilities.hh> 00012 00013 namespace Dune 00014 { 00015 00016 // External Forward Declarations 00017 // ----------------------------- 00018 00019 template< class HostGrid, class CoordFunction, class Allocator > 00020 class GeometryGrid; 00021 00022 00023 00024 namespace GeoGrid 00025 { 00026 00027 // IndexSet 00028 // -------- 00029 00030 template< class Grid, class HostIndexSet > 00031 class IndexSet 00032 : public Dune::IndexSet< Grid, IndexSet< Grid, HostIndexSet >, typename HostIndexSet::IndexType > 00033 { 00034 typedef IndexSet< Grid, HostIndexSet > This; 00035 00036 typedef typename remove_const< Grid >::type::Traits Traits; 00037 00038 typedef typename Traits::HostGrid HostGrid; 00039 00040 public: 00041 typedef Dune::IndexSet< Grid, This, typename HostIndexSet::IndexType > Base; 00042 00043 static const int dimension = Grid::dimension; 00044 00045 typedef typename Base::IndexType IndexType; 00046 00047 IndexSet ( const HostIndexSet &hostIndexSet ) 00048 : hostIndexSet_( &hostIndexSet ) 00049 {} 00050 00051 using Base::index; 00052 using Base::subIndex; 00053 00054 template< int cc > 00055 IndexType index ( const typename Traits::template Codim< cc >::Entity &entity ) const 00056 { 00057 return Grid::getRealImplementation( entity ).index( hostIndexSet() ); 00058 } 00059 00060 template< int cc > 00061 IndexType subIndex ( const typename Traits::template Codim< cc >::Entity &entity, int i, unsigned int codim ) const 00062 { 00063 return Grid::getRealImplementation( entity ).subIndex( hostIndexSet(), i, codim ); 00064 } 00065 00066 IndexType size ( GeometryType type ) const 00067 { 00068 return hostIndexSet().size( type ); 00069 } 00070 00071 int size ( int codim ) const 00072 { 00073 return hostIndexSet().size( codim ); 00074 } 00075 00076 template< class Entity > 00077 bool contains ( const Entity &entity ) const 00078 { 00079 return Grid::getRealImplementation( entity ).isContained( hostIndexSet() ); 00080 } 00081 00082 const std::vector< GeometryType > &geomTypes ( int codim ) const 00083 { 00084 return hostIndexSet().geomTypes( codim ); 00085 } 00086 00087 private: 00088 const HostIndexSet &hostIndexSet () const 00089 { 00090 assert( hostIndexSet_ != 0 ); 00091 return *hostIndexSet_; 00092 } 00093 00094 const HostIndexSet *hostIndexSet_; 00095 }; 00096 00097 } 00098 00099 } 00100 00101 #endif // #ifndef DUNE_GEOGRID_INDEXSETS_HH