dune-grid  2.2.0
alugrid/2d/grid.hh
Go to the documentation of this file.
00001 #ifndef DUNE_ALU2DGRIDGRID_HH
00002 #define DUNE_ALU2DGRIDGRID_HH
00003 
00004 //- System includes
00005 #include "alu2dinclude.hh"
00006 #include <iostream>
00007 #include <vector>
00008 
00009 //- Dune includes
00010 #include <dune/grid/utility/grapedataioformattypes.hh>
00011 #include <dune/grid/common/capabilities.hh>
00012 #include <dune/grid/alugrid/common/interfaces.hh>
00013 #include <dune/common/deprecated.hh>
00014 #include <dune/common/static_assert.hh>
00015 
00016 #include <dune/grid/common/grid.hh>
00017 #include <dune/grid/alugrid/common/declaration.hh>
00018 #include <dune/grid/alugrid/common/defaultindexsets.hh>
00019 #include <dune/grid/common/sizecache.hh>
00020 #include <dune/grid/common/defaultgridview.hh>
00021 #include <dune/common/mpihelper.hh>
00022 
00023 #include <dune/grid/alugrid/common/intersectioniteratorwrapper.hh>
00024 
00025 // bnd projection stuff 
00026 #include <dune/grid/common/boundaryprojection.hh>
00027 #include <dune/grid/alugrid/2d/bndprojection.hh>
00028 
00029 //- Local includes
00030 #include "indexsets.hh"
00031 #include <dune/grid/alugrid/common/objectfactory.hh>
00032 #include "datahandle.hh"
00033 
00034 namespace Dune {
00035 
00036   // Forward declarations
00037   template<int cd, int dim, class GridImp> 
00038   class ALU2dGridEntity;  
00039   template<int cd, PartitionIteratorType pitype, class GridImp > 
00040   class ALU2dGridLevelIterator;
00041   template<int cd, class GridImp >
00042   class ALU2dGridEntityPointer;  
00043   template<int cd, class GridImp >
00044   class ALU2dGridEntitySeed;
00045   template<int mydim, int coorddim, class GridImp>  
00046   class ALU2dGridMakeableGeometry;
00047   template<int mydim, int cdim, class GridImp>  
00048   class ALU2dGridGeometry;
00049   template<class GridImp>
00050   class ALU2dGridHierarchicIterator;    
00051   template<class GridImp>
00052   class ALU2dGridIntersectionBase;
00053   template<class GridImp>
00054   class ALU2dGridLevelIntersectionIterator;
00055   template<class GridImp>
00056   class ALU2dGridLeafIntersectionIterator;  
00057   template<int codim, PartitionIteratorType pitype, class GridImp>  
00058   class ALU2dGridLeafIterator;
00059   template <int mydim, int coorddim, class GridImp>
00060   class ALU2dGridMakeableEntity;
00061   template <class GridImp>
00062   class ALU2dGridFaceGeometryInfo;
00063   template< int dim, int dimworld, ALU2DSPACE ElementType eltype >
00064   class ALU2dGridLocalIdSet;
00065   template< int dim, int dimworld, ALU2DSPACE ElementType eltype >
00066   class ALU2dGridHierarchicIndexSet;
00067   template <class EntityImp>
00068   class ALUMemoryProvider;
00069   template< int dim, int dimworld, ALU2DSPACE ElementType eltype >
00070   class ALU2dGrid;
00071   template <class GridImp, class GeometryImp, int nChild>
00072   class ALULocalGeometryStorage;
00073   
00074   class ALU2dObjectStream;
00075 
00076   // Internal Forward Declarations
00077   // -----------------------------
00078 
00079   template < int dimw, class Comm >
00080   struct ALUGridBaseGrid< 2, dimw, cube, Comm >
00081   {
00082     typedef ALU2dGrid< 2, dimw, ALU2DSPACE quadrilateral >  BaseGrid ;
00083   };
00084 
00085   template < int dimw, class Comm >
00086   struct ALUGridBaseGrid< 2, dimw, simplex, Comm >
00087   {
00088     typedef ALU2dGrid< 2, dimw, ALU2DSPACE triangle >  BaseGrid ;
00089   };
00090 
00091 
00092   //
00093   // --ALU2dGrid
00094   // --Grid
00095   //
00096   //**********************************************************************
00097   template< int dim, int dimworld, ALU2DSPACE ElementType eltype >
00098   struct ALU2dGridFamily   
00099   {
00100     typedef ALU2dGrid< dim, dimworld, eltype > GridImp;
00101 
00103     typedef ALU2dGridLocalIdSet<dim,dimworld,eltype> GlobalIdSetImp;
00104 
00106     typedef ALU2dGridLocalIdSet<dim,dimworld,eltype> LocalIdSetImp;
00107            
00108     typedef int GlobalIdType;
00109     typedef int LocalIdType;
00110 
00111     struct Traits
00112     {
00113       typedef GridImp Grid;
00114 
00115       typedef Dune :: Intersection< const GridImp, LeafIntersectionWrapper > LeafIntersection;
00116       typedef Dune :: Intersection< const GridImp, LevelIntersectionWrapper > LevelIntersection;
00117 
00118       typedef Dune::IntersectionIterator<const GridImp, LeafIntersectionIteratorWrapper, LeafIntersectionWrapper > IntersectionIterator;      
00119       typedef Dune::IntersectionIterator<const GridImp, LeafIntersectionIteratorWrapper, LeafIntersectionWrapper > LeafIntersectionIterator;      
00120       typedef Dune::IntersectionIterator<const GridImp, LevelIntersectionIteratorWrapper, LevelIntersectionWrapper > LevelIntersectionIterator;      
00121       
00122       typedef Dune::EntityIterator< 0, const GridImp, ALU2dGridHierarchicIterator< const GridImp > > HierarchicIterator;
00123 
00124       typedef DuneBoundaryProjection< dimworld > DuneBoundaryProjectionType;
00125       typedef std::vector< const DuneBoundaryProjectionType *> DuneBoundaryProjectionVector;
00126 
00127       template <int cd>
00128       struct Codim
00129       {
00130         // IMPORTANT: Codim<codim>::Geometry == Geometry<dim-codim,dimw>
00131         typedef ALU2dGridGeometry< dim-cd, dimworld, const GridImp > GeometryImpl;
00132         typedef ALU2dGridGeometry< dim-cd, dim, const GridImp > LocalGeometryImpl;
00133         typedef Dune::Geometry< dim-cd, dimworld, const GridImp, ALU2dGridGeometry > Geometry;
00134         typedef Dune::Geometry< dim-cd, dim, const GridImp, ALU2dGridGeometry > LocalGeometry;
00135 
00136         // we could - if needed - introduce an other struct for dimglobal of Geometry
00137         typedef Dune::Entity<cd, dim, const GridImp, ALU2dGridEntity> Entity;
00138 
00139         typedef ALU2dGridEntityPointer< cd, const GridImp > EntityPointerImpl;
00140         typedef Dune::EntityPointer< const GridImp, EntityPointerImpl > EntityPointer;
00141 
00142         // minimal information to generate entities
00143         typedef ALU2dGridEntitySeed< cd , const GridImp > EntitySeed ;
00144 
00145         template <PartitionIteratorType pitype>
00146         struct Partition
00147         {
00148           typedef Dune::EntityIterator< cd, const GridImp, ALU2dGridLevelIterator< cd, pitype, const GridImp > > LevelIterator;
00149           typedef Dune::EntityIterator< cd, const GridImp, ALU2dGridLeafIterator< cd, pitype, const GridImp > > LeafIterator;
00150         };
00151 
00152         typedef typename Partition< All_Partition >::LevelIterator LevelIterator;
00153         typedef typename Partition< All_Partition >::LeafIterator LeafIterator;
00154 
00155       };
00156 
00157       template <PartitionIteratorType pitype>
00158       struct Partition
00159       {
00160         typedef Dune::GridView<DefaultLevelGridViewTraits<const GridImp,pitype> > 
00161         LevelGridView;
00162         typedef Dune::GridView<DefaultLeafGridViewTraits<const GridImp,pitype> > 
00163         LeafGridView;
00164       };
00165 
00167       typedef DefaultIndexSet< GridImp, typename Codim<0>::LevelIterator > LevelIndexSetImp;
00169       typedef DefaultIndexSet< GridImp, typename Codim<0>::LeafIterator > LeafIndexSetImp;
00170 
00171       typedef IndexSet<GridImp,LevelIndexSetImp> LevelIndexSet;
00172       typedef LeafIndexSetImp LeafIndexSet;
00173       typedef IdSet<GridImp,GlobalIdSetImp,GlobalIdType> GlobalIdSet;
00174       typedef IdSet<GridImp,LocalIdSetImp,LocalIdType> LocalIdSet;
00175 
00176 #if ALU2DGRID_PARALLEL
00177       typedef Dune :: CollectiveCommunication< MPI_Comm >
00178         CollectiveCommunication;
00179 #else 
00180       typedef Dune :: CollectiveCommunication< GridImp >
00181         CollectiveCommunication;
00182 #endif
00183     };
00184 
00186     typedef typename Traits :: LevelIndexSetImp  LevelIndexSetImp;
00187 
00189     typedef typename Traits :: LeafIndexSetImp   LeafIndexSetImp;
00190   }; // end of ALU2dGridFamily
00191 
00192 
00207   template< int dim, int dimworld, ALU2DSPACE ElementType eltype >
00208   class ALU2dGrid
00209   : public GridDefaultImplementation< dim, dimworld, alu2d_ctype, ALU2dGridFamily< dim, dimworld, eltype > >,
00210     public HasObjectStream, 
00211     public HasHierarchicIndexSet 
00212   {
00213     typedef ALU2dGrid< dim, dimworld, eltype > ThisType; 
00214     typedef GridDefaultImplementation< dim, dimworld, alu2d_ctype, ALU2dGridFamily< dim, dimworld, eltype > > BaseType;
00215 
00216     dune_static_assert( dim == 2, "ALU2dGrid only implemented for grid dim 2." );
00217     dune_static_assert( dimworld == 2 || dimworld == 3, "ALU2dGrid only implemented for world dim 2 or 3." );
00218 
00219   public:
00220     static const ALU2DSPACE ElementType elementType = eltype;
00221 
00222     typedef typename ALU2dGridFamily< dim, dimworld, elementType >::Traits Traits;
00223 
00224     // new intersection iterator is a wrapper which get itersectioniteratoimp as pointers
00225     typedef ALU2dGridLeafIntersectionIterator <const ThisType>  LeafIntersectionIteratorImp;
00226     typedef ALU2dGridLevelIntersectionIterator<const ThisType>  LevelIntersectionIteratorImp;
00227 
00228     typedef ALUGridObjectFactory< ThisType >  GridObjectFactoryType;
00229 
00230   private:
00231 
00232     typedef typename ALU2dImplTraits<dimworld, elementType >::HmeshType HmeshType ;
00233     typedef typename ALU2dImplTraits<dimworld, elementType >::HElementType HElementType ;
00234     typedef typename ALU2dImplTraits<dimworld, elementType >::ElementType ElementType ;
00235     
00236     template< class > friend class DGFBaseFactory;
00237 
00238     template< int, int, class > friend class ALU2dGridEntity;
00239    
00240     friend class ALU2dGridGeometry<0,dimworld,const ThisType>;
00241     friend class ALU2dGridGeometry<1,dimworld,const ThisType>;
00242     friend class ALU2dGridGeometry<dim,dimworld,const ThisType>;
00243     template< class, class, int > friend class ALULocalGeometryStorage;
00244  
00245     friend class ALU2dGridEntityPointer<0,const ThisType>;
00246     friend class ALU2dGridEntityPointer<1,const ThisType>;
00247     friend class ALU2dGridEntityPointer<dim,const ThisType>;
00248     
00249     friend class ALU2dGridHierarchicIndexSet<dim,dimworld,elementType>;
00250 
00251     friend class ALU2dGridIntersectionBase < const ThisType > ;
00252     friend class ALU2dGridLevelIntersectionIterator< const ThisType > ;
00253     friend class ALU2dGridLeafIntersectionIterator< const ThisType > ;
00254 
00255     //**********************************************************
00256     // The Interface Methods
00257     //**********************************************************
00258   protected:
00259     typedef MakeableInterfaceObject<typename Traits::template
00260             Codim<0>::Geometry> GeometryObject;
00261     friend class ALULocalGeometryStorage<const ThisType, GeometryObject, 4 >;
00262     friend class ALULocalGeometryStorage<const ThisType, GeometryObject, 2 >;
00263     
00264   public:  
00265    
00267     typedef ALU2dGridObjectStream ObjectStreamType;
00268     typedef ObjectStreamType  InStreamType ;
00269     typedef ObjectStreamType  OutStreamType ;
00270 
00272     typedef ALU2dGridFamily < dim, dimworld, eltype > GridFamily;
00273 
00275     typedef ALU2dGridHierarchicIndexSet<dim,dimworld,elementType> HierarchicIndexSet;
00276     
00278     typedef ALU2dGridLocalIdSet<dim,dimworld,elementType> LocalIdSetImp;
00279     typedef LocalIdSetImp GlobalIdSetImp;
00280 
00282     typedef typename Traits :: GlobalIdSet GlobalIdSet;
00283     
00285     typedef typename Traits :: LocalIdSet LocalIdSet;
00286    
00287 
00289     typedef typename GridFamily :: LevelIndexSetImp  LevelIndexSetImp;
00291     typedef typename GridFamily :: LeafIndexSetImp  LeafIndexSetImp;
00292     
00294     typedef ALU2dGridLeafIterator<0, All_Partition, const ThisType> LeafIteratorImp;
00295     typedef typename Traits::template Codim<0>::LeafIterator LeafIteratorType;
00296     typedef typename Traits::template Codim<0>::LeafIterator LeafIterator;
00297     
00299     typedef ALU2dGridLevelIterator<0, All_Partition, const ThisType> LevelIteratorImp;
00300     typedef typename Traits::template Codim<0>::LevelIterator LevelIteratorType;
00301     typedef typename Traits::template Codim<0>::LevelIterator LevelIterator;       
00302     
00303     typedef ALU2dGridHierarchicIterator<ThisType> HierarchicIteratorImp;
00304 
00305     typedef typename Traits::CollectiveCommunication CollectiveCommunicationType;
00306 
00307 
00309     enum { 
00311       MAXL = 64 };
00312 
00314     enum {
00316       newElementsChunk_ = 100 };
00317 
00319     enum {
00323       refineEstimate_ = 40 };
00324         
00326     typedef typename Traits :: DuneBoundaryProjectionType DuneBoundaryProjectionType;
00328     typedef typename Traits :: DuneBoundaryProjectionVector DuneBoundaryProjectionVector;
00329 
00330 #ifdef ALUGRID_VERTEX_PROJECTION
00331 
00332     typedef ALUGridSpace :: VertexProjection< dimworld > ALUGridVertexProjectionType;
00333 #endif
00334 
00335 
00336   protected:
00337 
00338     friend class ALUGridBoundaryProjection< ThisType >;
00339     friend class ALU2dGridBoundaryProjection< ThisType >;
00340     // type of ALUGrid boundary projection wrapper 
00341     typedef ALU2dGridBoundaryProjection< ThisType > ALUGridBoundaryProjectionType;
00342 
00345     //- --constructor
00346     ALU2dGrid(const std::string macroTriangFilename, 
00347               const int nrOfHangingNodes,
00348               const DuneBoundaryProjectionType*, 
00349               const DuneBoundaryProjectionVector*,
00350               std::istream* macroFile = 0); 
00351 
00352     // method creating mesh object  
00353     HmeshType* createGrid(const std::string&,
00354                           const int, 
00355                           std::istream* );
00356 
00358     explicit ALU2dGrid( int );
00359     
00360   public: 
00362     ~ALU2dGrid();
00363 
00366     int maxLevel() const;
00367            
00370     template<int cd, PartitionIteratorType pitype>
00371     typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator
00372     lbegin (int level) const; 
00373   
00375     template<int cd, PartitionIteratorType pitype>
00376     typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator
00377     lend (int level) const;
00378       
00380     template<int cd>
00381     typename Traits::template Codim<cd>::
00382     template Partition<All_Partition>::LevelIterator 
00383     lbegin (int level) const;
00384 
00386     template<int cd>
00387     typename Traits::template Codim<cd>::
00388     template Partition<All_Partition>::LevelIterator 
00389     lend (int level) const;
00390     
00392     LevelIteratorType lbegin (int level) const;
00393 
00395     LevelIteratorType lend (int level) const;
00396         
00398     template <int codim, PartitionIteratorType pitype>
00399     typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator
00400     leafbegin() const;
00401 
00403     template <int codim, PartitionIteratorType pitype>
00404     typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator
00405     leafend() const;
00406 
00408     template <int codim>
00409     typename Traits::template Codim<codim>::LeafIterator
00410     leafbegin() const;
00411 
00413     template <int codim>
00414     typename Traits::template Codim<codim>::LeafIterator
00415     leafend() const;
00416   
00417   private:  
00419     LeafIteratorType leafbegin () const;
00420 
00422     LeafIteratorType leafend () const;    
00423   
00424   public:  
00426     int size (int level, int cd) const;
00427     
00429     int size (int codim) const;
00430     
00432     int size (int level, GeometryType type) const;
00433 
00435     int size (GeometryType type) const;
00436 
00438     const std::vector<GeometryType>& geomTypes (int codim) const { return geomTypes_[codim]; }
00439     
00440     //****************************************************************
00441     // index and id sets 
00442     //****************************************************************
00443 
00445     const GlobalIdSet & globalIdSet () const; 
00446 
00448     const LocalIdSet & localIdSet () const;
00449     
00451     int hierSetSize (int cd) const;
00452     
00454     const HierarchicIndexSet & hierarchicIndexSet () const ;
00455     
00457     const typename Traits :: LeafIndexSet & leafIndexSet () const;
00458     
00460     const typename Traits :: LevelIndexSet & levelIndexSet (int level) const;   
00461     
00462     
00463     //**********************************************************
00464     // End of Interface Methods
00465     //**********************************************************
00466     
00467     // return reference to org ALU2dGrid 
00468     // private method, but otherwise we have to friend class all possible
00469     // types of LevelIterator ==> later
00470     HmeshType & myGrid();
00471     HmeshType & myGrid() const;
00472 
00474     void globalRefine ( int refCount );
00475 
00476     template< class GridImp, class DataHandle >
00477     void globalRefine ( int refCount, AdaptDataHandleInterface< GridImp, DataHandle > &hamdle );
00478     
00480     bool preAdapt ( );
00481     
00483     void postAdapt ( );
00484     
00488     bool adapt ();
00489 
00490     template< class GridImp, class DataHandle >
00491     bool adapt ( AdaptDataHandleInterface< GridImp, DataHandle > &handle );
00492     
00493     // refine grid
00494     bool refineGrid();
00495    
00497     int getMark(const typename Traits::template Codim<0>::Entity & e) const;
00498 
00500     bool mark( int refCount , const typename Traits::template Codim<0>::Entity & e);                  
00501     
00503     const CollectiveCommunicationType & comm() const;
00504   private:
00505     CollectiveCommunicationType comm_;
00506     
00507     void updateStatus();
00508     
00509     void calcMaxlevel();
00510     
00511     void calcExtras();
00512    
00513     // clear refinement marker of element and all children 
00514     void hierarchicClear( HElementType *el );
00515   public:
00516     typedef MakeableInterfaceObject<typename Traits::template Codim<0>::Entity> EntityObject;
00517     typedef MakeableInterfaceObject<typename Traits::template Codim<1>::Entity> FaceObject;
00518     typedef MakeableInterfaceObject<typename Traits::template Codim<2>::Entity> VertexObject;
00519     
00520   protected:  
00521     // create GeomTypes
00522     void makeGeomTypes ();
00523     
00524     friend class Conversion<ALU2dGrid<dim, dimworld,eltype>, HasObjectStream>;
00525     friend class Conversion<const ALU2dGrid<dim, dimworld,eltype>, HasObjectStream>;
00526 
00527     friend class Conversion<ALU2dGrid<dim, dimworld,eltype>, HasHierarchicIndexSet>;
00528     friend class Conversion<const ALU2dGrid<dim, dimworld,eltype>, HasHierarchicIndexSet>;
00529 
00530   private:  
00532     ALU2dGrid( const ThisType & g );
00533   
00535     ThisType & operator = (const ThisType & g); 
00536 
00537   protected:  
00538     // check macro file and return const char * to filename 
00539     const char * checkMacroGridFile(const std::string & filename);
00540   
00542     mutable HmeshType* mygrid_;
00543 
00544     // return reference to grid 
00545     HmeshType& mesh() const {
00546       assert(mygrid_);
00547       return *mygrid_;
00548     }
00549 
00550 #ifdef USE_SMP_PARALLEL
00551     std::vector< GridObjectFactoryType > factoryVec_;
00552 #else
00553     GridObjectFactoryType factory_;
00554 #endif
00555 
00557     HierarchicIndexSet hIndexSet_;
00558 
00560     LocalIdSetImp localIdSet_;
00561  
00563     mutable std::vector < LevelIndexSetImp * > levelIndexVec_;
00564         
00565     // at the moment the number of different geom types is 1
00566     enum { numberOfGeomTypes = 1 };
00567     std::vector< std::vector<GeometryType> > geomTypes_;
00568     
00570     mutable LeafIndexSetImp * leafIndexSet_;
00571 
00572     int maxLevel_;
00573     int refineMarked_ , coarsenMarked_;
00574     const int nrOfHangingNodes_;
00575     
00577     typedef SizeCache<ThisType> SizeCacheType;
00578     SizeCacheType * sizeCache_;
00579 
00580     // flag to make sure postAdapt is called after adapt 
00581     bool lockPostAdapt_;
00582 
00583     // pointer to Dune boundary projection 
00584     const DuneBoundaryProjectionType* bndPrj_;
00585 
00586     // pointer to Dune boundary projection 
00587     const DuneBoundaryProjectionVector* bndVec_;
00588  
00589     // boundary projection for vertices  
00590     ALUGridBoundaryProjectionType* vertexProjection_ ;
00591 
00592     const DuneBoundaryProjectionType *globalProjection () const
00593     {
00594       return bndPrj_;
00595     }
00596 
00598     const DuneBoundaryProjectionType* boundaryProjection(const int segmentIndex) const
00599     {
00600       if( bndPrj_ )
00601       {
00602         return bndPrj_;
00603       }
00604       else
00605       {
00606         // note pointer can be zero (identity mapping)
00607         assert( bndVec_ );
00608         assert( segmentIndex < (int) bndVec_->size() );
00609         return (*bndVec_)[ segmentIndex ];
00610       }
00611     }
00612 
00613   public:  
00615     size_t numBoundarySegments () const
00616     { 
00617 #ifdef ALUGRID_VERTEX_PROJECTION
00618       return myGrid().numMacroBndSegments();
00619 #else 
00620       derr << "Method available in any version of ALUGrid > 1.14 \n";
00621       return 0;
00622 #endif
00623     }
00624 
00626     bool hasBoundaryProjection() const
00627     {
00628       return (vertexProjection_ != 0);
00629     }
00630 
00631     using BaseType :: getRealImplementation ;
00632 
00633   public:
00634     template< class IntersectionType >
00635     const typename BaseType
00636       :: template ReturnImplementationType< IntersectionType>
00637       :: ImplementationType &
00638     getRealIntersection ( const IntersectionType &intersection ) const
00639     {
00640       return this->getRealImplementation( intersection );
00641     }
00642 
00643     const GridObjectFactoryType& factory() const {
00644 #ifdef USE_SMP_PARALLEL
00645       assert( (int) factoryVec_.size() > GridObjectFactoryType :: threadNumber() );
00646       return factoryVec_[ GridObjectFactoryType :: threadNumber() ];
00647 #else
00648       return factory_;
00649 #endif
00650     }
00651 
00652   protected:
00653     // max level of grid
00654     int maxlevel_;
00655     friend class IntersectionIteratorWrapper < const ThisType, LeafIntersectionIteratorImp > ;
00656     friend class IntersectionIteratorWrapper < const ThisType, LevelIntersectionIteratorImp > ;
00657     friend class LeafIntersectionIteratorWrapper < const ThisType > ;
00658     friend class LevelIntersectionIteratorWrapper< const ThisType > ;
00659 
00660     mutable ALU2dGridMarkerVector marker_[MAXL];
00661   public: 
00662     typedef ALU2dGridLeafMarkerVector ALU2dGridLeafMarkerVectorType;
00663   private:  
00664     // always update this marker!!!
00665     mutable ALU2dGridLeafMarkerVectorType leafMarker_;
00666 
00667   public: 
00668     template < class EntitySeed >
00669     typename Traits :: template Codim< EntitySeed :: codimension > :: EntityPointer
00670     entityPointer( const EntitySeed& seed ) const
00671     {
00672       enum { codim = EntitySeed :: codimension };
00673       typedef typename Traits :: template Codim< codim > :: EntityPointer EntityPointer;
00674       typedef ALU2dGridEntityPointer < codim, const ThisType > ALUPointer ;
00675       return ALUPointer( factory(), seed ) ;
00676     }
00677 
00680     ALU2dGridMarkerVector & getMarkerVector(int level) const
00681     {
00682       assert( level >= 0);
00683       assert( level <= MAXL);
00684       return marker_[level];
00685     }
00686 
00689     ALU2dGridLeafMarkerVectorType & getLeafMarker() const
00690     {
00691       return leafMarker_;
00692     }
00693     
00696     template <GrapeIOFileFormatType ftype>
00697     bool writeGrid( const std::string filename, alu2d_ctype time ) const ;
00698 
00699     bool writeGrid_Xdr( const std::string filename, alu2d_ctype time ) const ;
00700     bool writeGrid_Ascii( const std::string filename, alu2d_ctype time ) const ;
00701   
00704     template <GrapeIOFileFormatType ftype>
00705     bool readGrid( const std::string filename, alu2d_ctype & time );
00706 
00707   protected:
00710     bool nonConform () const 
00711     { 
00712       return (nrOfHangingNodes_ > 0);
00713     }
00714 
00715 #if ALU2DGRID_PARALLEL
00716     typedef RankManager<ThisType> RankManagerType;
00717     RankManagerType rankManager_;
00718   public:    
00719     const RankManagerType& rankManager() const 
00720     {
00721       return rankManager_;
00722     }
00723 #endif
00724 
00725   public:
00727     template<class DataHandleImp,class DataTypeImp>
00728     void communicate (CommDataHandleIF<DataHandleImp,DataTypeImp> & data, 
00729         InterfaceType iftype, CommunicationDirection dir, int level) const;
00730 
00734     template<class DataHandleImp,class DataTypeImp>
00735     void communicate (CommDataHandleIF<DataHandleImp,DataTypeImp> & data, 
00736         InterfaceType iftype, CommunicationDirection dir) const;
00737 
00738     int ghostSize ( int level, int codim ) const
00739     {
00740       return ghostSize( codim );
00741     }
00742 
00743     int ghostSize ( int codim ) const
00744     {
00745 #if ALU2DGRID_PARALLEL
00746       return 1;
00747 #else
00748       return 0;
00749 #endif
00750     }
00751 
00753     bool loadBalance() ;
00754 
00756     template<class DataHandle>
00757     bool loadBalance(DataHandle& data) ;
00758 
00759     void checkManager() { 
00760 #if ALU2DGRID_PARALLEL
00761       rankManager_.notifyMarking () ; 
00762 #endif
00763     }
00764 
00765   }; // end class ALU2dGrid
00766 
00767   namespace Capabilities 
00768   {
00769     template<int dim, int dimw, ALU2DSPACE ElementType eltype, int cdim>
00770     struct hasEntity<ALU2dGrid<dim,dimw,eltype>, cdim >
00771     {
00772       static const bool v = true;
00773     };
00774 
00775     template<int dim, int dimw, ALU2DSPACE ElementType eltype>
00776     struct isLevelwiseConforming< ALU2dGrid<dim,dimw,eltype> >
00777     {
00778       static const bool v = false;
00779     };
00780 
00781   } // end namespace Capabilities
00782   
00783 } // end namespace Dune
00784 
00785 #include "entity.hh"
00786 #include "geometry.hh"
00787 #include <dune/grid/alugrid/2d/intersection.hh>
00788 #include <dune/grid/alugrid/2d/iterator.hh>
00789 
00790 #include "grid_imp.cc"
00791 
00792 #endif