1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 // vi: set et ts=4 sw=2 sts=2: 3 #ifndef DUNE_ALBERTA_ENTITYSEED_HH 4 #define DUNE_ALBERTA_ENTITYSEED_HH 5 6 #include <dune/grid/albertagrid/elementinfo.hh> 7 #include <dune/grid/albertagrid/meshpointer.hh> 8 9 namespace Dune 10 { 11 12 // Internal Forward Declarations 13 // ----------------------------- 14 15 template< int codim, class Grid > 16 class AlbertaGridEntitySeed; 17 18 19 20 // External Forward Declarations 21 // ----------------------------- 22 23 template< int dim, int dimworld > 24 class AlbertaGrid; 25 26 27 28 #if HAVE_ALBERTA 29 30 // AlbertaGridEntitySeed (for higher codimension) 31 // ---------------------------------------------- 32 33 template< int codim, int dim, int dimworld > 34 class AlbertaGridEntitySeed< codim, const AlbertaGrid< dim, dimworld > > 35 { 36 public: 37 typedef AlbertaGrid< dim, dimworld > Grid; 38 39 static const int codimension = codim; 40 static const int dimension = dim; 41 static const int mydimension = dimension - codimension; 42 static const int dimensionworld = dimworld; 43 44 typedef Alberta::MeshPointer< dimension > MeshPointer; 45 typedef Alberta::ElementInfo< dimension > ElementInfo; 46 typedef typename ElementInfo::Seed Seed; 47 48 typedef typename Grid::template Codim< codimension >::Entity Entity; 49 AlbertaGridEntitySeed()50 AlbertaGridEntitySeed ( ) 51 {} 52 AlbertaGridEntitySeed(const ElementInfo & elementInfo,int subEntity)53 AlbertaGridEntitySeed ( const ElementInfo &elementInfo, int subEntity ) 54 : seed_( elementInfo.seed() ), 55 subEntity_( subEntity ) 56 {} 57 isValid() const58 bool isValid () const 59 { 60 return seed_.isValid(); 61 } 62 elementInfo(const MeshPointer & mesh) const63 ElementInfo elementInfo ( const MeshPointer &mesh ) const { return ElementInfo( mesh, seed_ ); } subEntity() const64 int subEntity () const { return subEntity_; } 65 66 private: 67 Seed seed_; 68 int subEntity_; 69 }; 70 71 72 73 // AlbertaGridEntitySeed (for codimension 0) 74 // ----------------------------------------- 75 76 template< int dim, int dimworld > 77 class AlbertaGridEntitySeed< 0, const AlbertaGrid< dim, dimworld > > 78 { 79 public: 80 typedef AlbertaGrid< dim, dimworld > Grid; 81 82 static const int codimension = 0; 83 static const int dimension = dim; 84 static const int mydimension = dimension - codimension; 85 static const int dimensionworld = dimworld; 86 87 typedef Alberta::MeshPointer< dimension > MeshPointer; 88 typedef Alberta::ElementInfo< dimension > ElementInfo; 89 typedef typename ElementInfo::Seed Seed; 90 91 typedef typename Grid::template Codim< codimension >::Entity Entity; 92 AlbertaGridEntitySeed()93 AlbertaGridEntitySeed ( ) 94 {} 95 AlbertaGridEntitySeed(const ElementInfo & elementInfo)96 explicit AlbertaGridEntitySeed ( const ElementInfo &elementInfo ) 97 : seed_( elementInfo.seed() ) 98 {} 99 isValid() const100 bool isValid () const 101 { 102 return seed_.isValid(); 103 } 104 elementInfo(const MeshPointer & mesh) const105 ElementInfo elementInfo ( const MeshPointer &mesh ) const { return ElementInfo( mesh, seed_ ); } subEntity() const106 int subEntity () const { return 0; } 107 108 private: 109 Seed seed_; 110 }; 111 112 #endif // #if HAVE_ALBERTA 113 114 } // end namespace Dune 115 116 #endif // #ifndef DUNE_ALBERTA_ENTITYSEED_HH 117