albertagrid/entity.hh

00001 #ifndef DUNE_ALBERTA_ENTITY_HH
00002 #define DUNE_ALBERTA_ENTITY_HH
00003 
00004 #include <dune/grid/common/entity.hh>
00005 #include <dune/grid/common/intersectioniteratorwrapper.hh>
00006 
00007 #include <dune/grid/albertagrid/elementinfo.hh>
00008 #include <dune/grid/albertagrid/geometry.hh>
00009 
00010 namespace Dune
00011 {
00012 
00013   // Forward Declarations
00014   // --------------------
00015 
00016   template< int codim, class GridImp >
00017   class AlbertaGridEntityPointer;
00018 
00019   template< int codim, class GridImp, bool leafIterator >
00020   class AlbertaGridTreeIterator;
00021 
00022   template< class GridImp >
00023   class AlbertaGridHierarchicIterator;
00024 
00025   template< class GridImp >
00026   class AlbertaGridIntersectionIterator;
00027 
00028 
00029 
00030   // AlbertaGridEntity
00031   // -----------------
00032 
00039   template< int codim, int dim, class GridImp >
00040   class AlbertaGridEntity
00041   : public EntityDefaultImplementation< codim, dim, GridImp, AlbertaGridEntity >
00042   {
00043     typedef AlbertaGridEntity< codim, dim, GridImp > This;
00044 
00045     enum { dimworld = GridImp::dimensionworld };
00046     friend class AlbertaGrid< dim , dimworld >;
00047     friend class AlbertaGridEntity< 0, dim, GridImp>;
00048 
00049     template< int, class, bool > friend class AlbertaGridTreeIterator;
00050     friend class AlbertaGridEntityPointer< codim, GridImp >;
00051 
00052   public:
00053     static const int dimension = dim;
00054     static const int codimension = codim;
00055     static const int mydimension = dimension - codimension;
00056 
00057     template< int cd >
00058     struct Codim
00059     {
00060       typedef typename GridImp::template Codim< cd >::EntityPointer EntityPointer;
00061     };
00062 
00063     typedef typename GridImp::template Codim< codim >::Entity Entity;
00064     typedef typename GridImp::template Codim< codim >::Geometry Geometry;
00065     typedef typename GridImp::template Codim< codim >::LevelIterator LevelIterator;
00066 
00067     typedef Alberta::ElementInfo< dimension > ElementInfo;
00068 
00069   private:
00070     typedef MakeableInterfaceObject< Geometry > GeometryObject;
00071     typedef typename GeometryObject::ImplementationType GeometryImp;
00072 
00073   public:
00075     AlbertaGridEntity ( const GridImp &grid );
00076  
00078     AlbertaGridEntity ( const This &other );
00079 
00081     int level () const;
00082 
00084     PartitionType partitionType() const; 
00085 
00087     const Geometry & geometry () const;
00088 
00090     GeometryType type () const;
00091 
00092     //***********************************************
00093     //  End of Interface methods 
00094     //***********************************************
00096     ALBERTA EL_INFO *getElInfo () const;
00098     ALBERTA EL *getElement () const;
00099 
00100     const ElementInfo &elementInfo () const
00101     {
00102       return elementInfo_;
00103     }
00104 
00106     bool equals ( const This &other ) const;
00107     
00108     void clearElement ();
00109     void setElement ( const ElementInfo &elementInfo, int subEntity );
00110 
00111     // same as setElInfo just with a entity given 
00112     void setEntity ( const This &other );
00113 
00115     const GridImp &grid () const
00116     {
00117       return grid_;
00118     }
00119 
00121     int subEntity () const
00122     {
00123       return subEntity_;
00124     }
00125 
00126   private:
00127     const GeometryImp &geoImp () const
00128     {
00129       return GridImp :: getRealImplementation( geo_ );
00130     }
00131 
00132     GeometryImp &geoImp ()
00133     {
00134       return GridImp :: getRealImplementation( geo_ );
00135     }
00136 
00137   private: 
00138     // grid this entity belong to 
00139     const GridImp &grid_;
00140 
00141     // ALBERTA element info
00142     ElementInfo elementInfo_;
00143 
00144     // number of the subentity within the element (in ALBERTA numbering)
00145     int subEntity_;
00146 
00147     // current geometry
00148     GeometryObject geo_;
00149   };
00150 
00151 
00152 
00166   //***********************
00167   //  
00168   //  --AlbertaGridEntity
00169   //  --0Entity
00170   //
00171   //***********************
00172   template< int dim, class GridImp >
00173   class AlbertaGridEntity< 0, dim, GridImp >
00174   : public EntityDefaultImplementation< 0, dim, GridImp, AlbertaGridEntity >
00175   {
00176     typedef AlbertaGridEntity< 0, dim, GridImp > This;
00177 
00178     enum { dimworld = GridImp::dimensionworld };
00179     friend class AlbertaGrid < dim , GridImp::dimensionworld >;
00180     friend class AlbertaGridIntersectionIterator <GridImp>;
00181     friend class AlbertaGridHierarchicIterator< GridImp >;
00182     template< int, class, bool > friend class AlbertaGridTreeIterator;
00183     friend class AlbertaGridEntityPointer<0,GridImp>;
00184 
00185   public:
00186     static const int dimension = dim;
00187     static const int codimension = 0;
00188     static const int mydimension = dimension - codimension;
00189 
00190     template< int codim >
00191     struct Codim
00192     {
00193       typedef typename GridImp::template Codim< codim >::EntityPointer
00194         EntityPointer;
00195     };
00196 
00197     typedef typename GridImp::template Codim< 0 >::Entity Entity;
00198     typedef typename GridImp::template Codim< 0 >::Geometry Geometry;
00199     typedef typename GridImp::template Codim< 0 >::LocalGeometry LocalGeometry;
00200     typedef AlbertaGridGeometry<dim,dimworld,GridImp> GeometryImp;
00201 
00202     typedef typename GridImp::template Codim<0>::LevelIterator LevelIterator;
00203     typedef typename GridImp::template Codim<0>::HierarchicIterator HierarchicIterator;
00204     typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
00205 
00206     typedef LeafIntersectionIteratorWrapper<GridImp> AlbertaGridLeafIntersectionIteratorType;
00207     typedef AlbertaGridLeafIntersectionIteratorType  AlbertaGridIntersectionIteratorType;
00208     typedef AlbertaGridLeafIntersectionIteratorType  AlbertaGridLevelIntersectionIteratorType;
00209 
00210     typedef Alberta::ElementInfo< dimension > ElementInfo;
00211 
00215     ~AlbertaGridEntity() {};
00216 
00218     AlbertaGridEntity ( const GridImp &grid );
00219 
00220     AlbertaGridEntity(const AlbertaGridEntity & org);
00221     
00223     int level () const;
00224 
00226     int boundaryId () const;
00227 
00229     const Geometry & geometry () const;
00230 
00232     GeometryType type () const;
00233 
00237 
00238     template<int cc> int count () const; 
00239   
00242     template<int cc> typename Codim<cc>::EntityPointer entity (int i) const;
00243 
00246     //template<int cc> void entity (AlbertaGridTreeIterator<cc,dim,dimworld>& it, int i);
00247 
00253     AlbertaGridLeafIntersectionIteratorType ileafbegin () const;
00254 
00256     AlbertaGridIntersectionIteratorType ileafend () const;
00257 
00258     AlbertaGridLevelIntersectionIteratorType ilevelbegin () const
00259     {
00260       DUNE_THROW( NotImplemented, "method ilevelbegin not implemented for AlbertaGrid." );
00261       return ileafend();
00262     }
00263 
00264     AlbertaGridLeafIntersectionIteratorType ilevelend () const
00265     {
00266       DUNE_THROW( NotImplemented, "method ilevelend not implemented for AlbertaGrid." );
00267       return ileafend();
00268     }
00269 
00271     bool isLeaf () const; 
00272 
00275     EntityPointer father () const;
00276 
00285     const LocalGeometry &geometryInFather () const;
00286   
00291     HierarchicIterator hbegin (int maxlevel) const;
00292   
00294     HierarchicIterator hend (int maxlevel) const;
00295 
00298       bool wasRefined () const DUNE_DEPRECATED {return isNew();}
00299 
00302     bool mightBeCoarsened () const DUNE_DEPRECATED { return mightVanish(); }
00303 
00306     bool isNew () const;
00307 
00310     bool mightVanish () const;
00311 
00314     bool hasBoundaryIntersections () const ;
00315     
00317     PartitionType partitionType() const; 
00318 
00320     bool equals ( const AlbertaGridEntity<0,dim,GridImp> & i) const;
00321 
00322     //***************************************************************
00323     //  Interface for parallelisation 
00324     //***************************************************************
00325     // set leaf data with processor number  
00326     void setLeafData( int proc );
00327 
00328     // return true if this entity belong to master set of this grid   
00329     bool master() const; 
00330 
00331     // needed for LevelIterator to compare 
00332     ALBERTA EL_INFO *getElInfo () const;
00333 
00334     const ElementInfo &elementInfo () const
00335     {
00336       return elementInfo_;
00337     }
00338 
00339     // return element for equaltiy in EntityPointer 
00340     ALBERTA EL *getElement () const;
00341 
00342     void clearElement ();
00343     void setElement ( const ElementInfo &elementInfo, int subEntity );
00344 
00345     // same as setElInfo just with a entity given 
00346     void setEntity ( const This &other);
00347 
00349     const GridImp &grid () const
00350     {
00351       return grid_;
00352     }
00353 
00355     int subEntity () const
00356     {
00357       return 0;
00358     }
00359 
00360   private: 
00362     int nChild () const;
00363 
00364     GeometryImp &geoImp () const
00365     {
00366       return GridImp :: getRealImplementation( geo_ );
00367     }
00368 
00370     const GridImp & grid_;
00371 
00372     // Alberta element info
00373     ElementInfo elementInfo_;
00374 
00375     // local coordinates within father 
00376     typedef MakeableInterfaceObject<Geometry> GeometryObject;
00377 
00379     mutable GeometryObject geo_;
00380     mutable bool builtgeometry_;  
00381   }; // end of AlbertaGridEntity codim = 0
00382 
00383 }
00384 
00385 #endif

Generated on Sun Nov 15 22:28:40 2009 for dune-grid by  doxygen 1.5.6