- Home
- About DUNE
- Download
- Documentation
- Community
- Development
00001 #ifndef DUNE_GEOGRID_PERSISTENTCONTAINER_HH 00002 #define DUNE_GEOGRID_PERSISTENTCONTAINER_HH 00003 00004 #include <dune/common/typetraits.hh> 00005 #include <dune/grid/utility/persistentcontainer.hh> 00006 #include <dune/grid/geometrygrid.hh> 00007 00008 namespace Dune 00009 { 00010 // PersistentContainer for GeometryGrid 00011 // ------------------------------------ 00012 00013 template< class HostGrid, class CoordFunction, class Data, class Allocator > 00014 class PersistentContainer< GeometryGrid< HostGrid, CoordFunction, Allocator >, Data, Allocator > 00015 : public PersistentContainer< HostGrid, Data, Allocator > 00016 { 00017 typedef PersistentContainer< HostGrid, Data, Allocator > Base; 00018 00019 public: 00020 typedef GeometryGrid< HostGrid, CoordFunction, Allocator > GridType; 00021 00022 typedef typename GridType::template Codim< 0 >::Entity ElementType; 00023 00024 PersistentContainer ( const GridType &grid, const int codim, const Allocator &allocator = Allocator() ) 00025 : Base( grid.hostGrid(), codim, allocator ), 00026 grid_(grid) 00027 {} 00028 00029 template< class Entity > 00030 const Data &operator[] ( const Entity &entity ) const 00031 { 00032 static const bool fake = ! Capabilities::hasHostEntity< GridType, Entity::codimension >::v; 00033 integral_constant<bool,fake> a; 00034 return data(entity,a); 00035 } 00036 00037 template< class Entity > 00038 Data &operator[] ( const Entity &entity ) 00039 { 00040 static const bool fake = ! Capabilities::hasHostEntity< GridType, Entity::codimension >::v; 00041 integral_constant<bool,fake> a; 00042 return data(entity,a); 00043 } 00044 00045 const Data &operator() ( const ElementType &element, const int subEntity ) const 00046 { 00047 return Base::operator()( GridType::template getHostEntity<0>( element ), subEntity ); 00048 } 00049 00050 Data &operator() ( const ElementType &element, const int subEntity ) 00051 { 00052 return Base::operator()( GridType::template getHostEntity<0>( element ), subEntity ); 00053 } 00054 00055 protected: 00056 template< class EntityImpl > 00057 const Data &data ( const EntityImpl &entity, integral_constant<bool, false > ) const 00058 { 00059 return Base::operator[]( GridType::template getHostEntity<EntityImpl::codimension>( entity) ); 00060 } 00061 00062 template< class EntityImpl > 00063 Data &data ( const EntityImpl &entity, integral_constant<bool, false > ) 00064 { 00065 return Base::operator[]( GridType::template getHostEntity<EntityImpl::codimension>( entity) ); 00066 } 00067 00068 template< class EntityImpl > 00069 const Data &data ( const EntityImpl &entity, integral_constant<bool, true > ) const 00070 { 00071 return Base::operator()( entity.hostElement(). entity.subEntity() ); 00072 } 00073 00074 template< class EntityImpl > 00075 Data &data ( const EntityImpl &entity, integral_constant<bool, true > ) 00076 { 00077 return Base::operator()( entity.hostElement(). entity.subEntity() ); 00078 } 00079 00080 private: 00081 const GridType &grid_; 00082 }; 00083 } // end namespace Dune 00084 00085 #endif // end DUNE_PERSISTENTCONTAINER_HH
Generated on Fri Apr 29 2011 with Doxygen (ver 1.7.1) [doxygen-log,error-log].