- Home
- About DUNE
- Download
- Documentation
- Community
- Development
00001 #ifndef DUNE_ALU2DGRIDINDEXSETS_HH 00002 #define DUNE_ALU2DGRIDINDEXSETS_HH 00003 00004 //- System includes 00005 #include <vector> 00006 00007 //- Dune includes 00008 #include <dune/common/stdstreams.hh> 00009 #include <dune/common/bigunsignedint.hh> 00010 00011 #include <dune/grid/common/grid.hh> 00012 #include <dune/grid/common/indexidset.hh> 00013 00014 00015 //- Local includes 00016 #include "alu2dinclude.hh" 00017 00018 namespace Dune 00019 { 00020 00021 // External Forward Declarations 00022 // ----------------------------- 00023 00024 template< int dim, int dimworld, ALU2DSPACE ElementType eltype > 00025 class ALU2dGrid; 00026 00027 template<int cd, int dim, class GridImp> 00028 class ALU2dGridEntity; 00029 00030 00031 00032 // ALU2dGridHierarchicIndexSet 00033 // --------------------------- 00034 00036 template <int dim, int dimworld, ALU2DSPACE ElementType eltype> 00037 class ALU2dGridHierarchicIndexSet : 00038 public IndexSet< ALU2dGrid< dim, dimworld, eltype >, 00039 ALU2dGridHierarchicIndexSet< dim, dimworld, eltype >, int > 00040 { 00041 typedef ALU2dGridHierarchicIndexSet< dim, dimworld, eltype > This; 00042 00043 typedef ALU2dGrid< dim, dimworld, eltype > GridType; 00044 enum { numCodim = dim+1 }; // i.e. 3 00045 00046 friend class ALU2dGrid< dim, dimworld, eltype >; 00047 00048 ALU2dGridHierarchicIndexSet( const GridType &grid ) 00049 : grid_( grid ) 00050 {} 00051 00052 public: 00053 typedef typename GridType::Traits::template Codim<0>::Entity EntityCodim0Type; 00054 00056 template< int codim > 00057 int index ( const typename GridType::Traits::template Codim< codim >::Entity &entity ) const 00058 { 00059 return GridType::getRealImplementation( entity ).getIndex(); 00060 } 00061 00063 template< class Entity > 00064 int index ( const Entity &entity ) const 00065 { 00066 return GridType::getRealImplementation( entity ).getIndex(); 00067 } 00068 00070 int subIndex ( const EntityCodim0Type &e, int i, unsigned int codim ) const 00071 { 00072 return grid_.getRealImplementation( e ).subIndex( i, codim); 00073 } 00074 00077 int size ( GeometryType type ) const 00078 { 00079 const int codim = dim-type.dim(); 00080 assert( grid_.geomTypes(codim).size() == 1 ); 00081 if( type != grid_.geomTypes(codim)[0] ) return 0; 00082 // return size of hierarchic index set 00083 return grid_.hierSetSize(codim); 00084 } 00085 00087 int size ( int codim ) const 00088 { 00089 // return size of hierarchic index set 00090 return grid_.hierSetSize(codim); 00091 } 00092 00094 const std::vector<GeometryType>& geomTypes (int codim) const 00095 { 00096 return grid_.geomTypes(codim); 00097 } 00098 00100 template <class EntityType> 00101 bool contains (const EntityType &) const { return true; } 00102 00103 private: 00104 // our Grid 00105 const GridType & grid_; 00106 }; 00107 00108 //*********************************************************** 00109 // 00110 // --LocalIdSet 00111 // 00112 //*********************************************************** 00113 00115 template <int dim, int dimworld, ALU2DSPACE ElementType eltype> 00116 class ALU2dGridLocalIdSet : 00117 public IdSet < ALU2dGrid< dim, dimworld, eltype >, 00118 ALU2dGridLocalIdSet< dim, dimworld, eltype >, int > 00119 { 00120 typedef ALU2dGrid< dim, dimworld, eltype > GridType; 00121 typedef typename GridType :: HierarchicIndexSet HierarchicIndexSetType; 00122 00123 friend class ALU2dGrid< dim, dimworld, eltype >; 00124 00125 // this means that only up to 300000000 entities are allowed 00126 enum { codimMultiplier = 300000000 }; 00127 typedef typename GridType::Traits::template Codim<0>::Entity EntityCodim0Type; 00128 00129 // create local id set , only for the grid allowed 00130 ALU2dGridLocalIdSet(const GridType & grid) : hset_(grid.hierarchicIndexSet()) 00131 { 00132 for(int i=0; i<dim+1; i++) 00133 codimStart_[i] = i*codimMultiplier; 00134 } 00135 00136 // fake method to have the same method like GlobalIdSet 00137 void updateIdSet() {} 00138 00139 public: 00141 typedef int IdType; 00142 00145 using IdSet < GridType , ALU2dGridLocalIdSet, IdType > :: subId; 00146 00148 template <class EntityType> 00149 int id (const EntityType & ep) const 00150 { 00151 enum { cd = EntityType :: codimension }; 00152 assert( hset_.size(cd) < codimMultiplier ); 00153 return codimStart_[cd] + hset_.index(ep); 00154 } 00155 00157 template <int codim> 00158 int id (const typename GridType:: template Codim<codim> :: Entity & ep) const 00159 { 00160 //enum { cd = EntityType :: codimension }; 00161 assert( hset_.size(codim) < codimMultiplier ); 00162 return codimStart_[codim] + hset_.index(ep); 00163 } 00164 00166 int subId ( const EntityCodim0Type &e, int i, unsigned int codim ) const 00167 { 00168 assert( hset_.size( codim ) < codimMultiplier ); 00169 return codimStart_[ codim ] + hset_.subIndex( e, i, codim ); 00170 } 00171 00172 private: 00173 // our HierarchicIndexSet 00174 const HierarchicIndexSetType & hset_; 00175 00176 // store start of each codim numbers 00177 int codimStart_[dim+1]; 00178 }; 00179 00180 } // end namespace Dune 00181 00182 #endif
Generated on Fri Apr 29 2011 with Doxygen (ver 1.7.1) [doxygen-log,error-log].