alugrid/3d/grid.hh

00001 #ifndef DUNE_ALU3DGRIDGRID_HH
00002 #define DUNE_ALU3DGRIDGRID_HH
00003 
00004 //- System includes
00005 #include <vector>
00006 
00007 //- Dune includes
00008 #include <dune/grid/utility/grapedataioformattypes.hh>
00009 #include <dune/grid/common/capabilities.hh>
00010 #include <dune/common/interfaces.hh>
00011 #include <dune/common/bigunsignedint.hh>
00012 #include <dune/common/deprecated.hh>
00013 #include <dune/common/static_assert.hh>
00014 
00015 #include <dune/grid/common/grid.hh>
00016 #include <dune/grid/common/referenceelements.hh>
00017 #include <dune/grid/common/defaultindexsets.hh>
00018 #include <dune/grid/common/sizecache.hh>
00019 #include <dune/grid/common/intersectioniteratorwrapper.hh>
00020 #include <dune/grid/common/datahandleif.hh>
00021 
00022 //- Local includes
00023 #include "alu3dinclude.hh"
00024 #include "topology.hh"
00025 #include "indexsets.hh"
00026 #include "memory.hh"
00027 #include "datahandle.hh"
00028 #include "alu3dutility.hh"
00029 
00030 #if ALU3DGRID_PARALLEL
00031 #include <dune/common/mpicollectivecommunication.hh>
00032 #else 
00033 #include <dune/common/collectivecommunication.hh>
00034 #endif
00035 
00036 namespace Dune {
00037 
00038   // Forward declarations
00039   template<int cd, int dim, class GridImp> 
00040   class ALU3dGridEntity;  
00041   template<int cd, PartitionIteratorType pitype, class GridImp > 
00042   class ALU3dGridLevelIterator;
00043   template<int cd, class GridImp >
00044   class ALU3dGridEntityPointerBase;  
00045   template<int cd, class GridImp >
00046   class ALU3dGridEntityPointer;  
00047   template<int mydim, int coorddim, class GridImp>  
00048   class ALU3dGridGeometry;
00049   template<class GridImp>
00050   class ALU3dGridHierarchicIterator;
00051   template<class GridImp>
00052   class ALU3dGridIntersectionIterator;
00053   template<class GridImp>
00054   class ALU3dGridLevelIntersectionIterator;
00055   template<int codim, PartitionIteratorType pitype, class GridImp>
00056   class ALU3dGridLeafIterator;
00057   template <int mydim, int coorddim, class GridImp>
00058   class ALU3dGridMakeableEntity;
00059   template <class GridImp>
00060   class ALU3dGridFaceGeometryInfo;
00061   template<int dim, int dimworld, ALU3dGridElementType elType> 
00062   class ALU3dGridGlobalIdSet;
00063   template<int dim, int dimworld, ALU3dGridElementType elType> 
00064   class ALU3dGridLocalIdSet;
00065   template<int dim, int dimworld, ALU3dGridElementType elType> 
00066   class ALU3dGridHierarchicIndexSet;
00067   template <class EntityImp>
00068   class ALUMemoryProvider;
00069   template<int dim, int dimworld, ALU3dGridElementType elType> 
00070   class ALU3dGrid;
00071   template <class GridImp, int codim>
00072   struct ALU3dGridEntityFactory; 
00073 
00074   //**********************************************************************
00075   //
00076   // --ALU3dGrid
00077   // --Grid
00078   //
00079   //**********************************************************************
00080   template <int dim, int dimworld, ALU3dGridElementType elType>
00081   struct ALU3dGridFamily   
00082   {
00084     typedef ALU3dGridLocalIdSet<dim,dimworld,elType> LocalIdSetImp;
00085     
00086 #if ALU3DGRID_PARALLEL
00088     typedef ALU3dGridGlobalIdSet<dim,dimworld,elType> GlobalIdSetImp;
00089 #else 
00090     typedef ALU3dGridGlobalIdSet<dim,dimworld,elType> GlobalIdSetImp;
00091     //typedef LocalIdSetImp GlobalIdSetImp;
00092 #endif
00093     
00095     typedef DefaultLevelIndexSet<ALU3dGrid < dim, dimworld, elType > >  LevelIndexSetImp; 
00097     typedef DefaultLeafIndexSet<ALU3dGrid < dim, dimworld, elType > >   LeafIndexSetImp; 
00098 
00100     typedef ALUGridId<ALUMacroKey> GlobalIdType;
00101 
00103     typedef int LocalIdType;
00104 
00105     typedef ALU3dGrid<dim,dimworld,elType> GridImp;
00106 
00107     struct Traits
00108     {
00110       typedef int LocalIdType;
00111 
00113       typedef ALUGridId<ALUMacroKey> GlobalIdType;
00114       
00115       typedef ALU3dGrid<dim,dimworld,elType> Grid;
00116 
00117       typedef Dune::IntersectionIterator<const GridImp, LeafIntersectionIteratorWrapper> IntersectionIterator;
00118       
00119       typedef Dune::IntersectionIterator<const GridImp, LeafIntersectionIteratorWrapper > LeafIntersectionIterator;
00120       // only for forward compatibility 
00121       typedef Dune::IntersectionIterator<const GridImp, LeafIntersectionIteratorWrapper > LeafIntersection;
00122       typedef Dune::IntersectionIterator<const GridImp, LevelIntersectionIteratorWrapper> LevelIntersectionIterator;
00123       // only for forward compatibility 
00124       typedef Dune::IntersectionIterator<const GridImp, LevelIntersectionIteratorWrapper> LevelIntersection;
00125 
00126       typedef Dune::HierarchicIterator<const GridImp, ALU3dGridHierarchicIterator> HierarchicIterator;
00127 
00128       template <int cd>
00129       struct Codim
00130       {
00131         // IMPORTANT: Codim<codim>::Geometry == Geometry<dim-codim,dimw>
00132         typedef Dune::Geometry<dim-cd, dimworld, const GridImp, ALU3dGridGeometry> Geometry;
00133         typedef Dune::Geometry<dim-cd, dim, const GridImp, ALU3dGridGeometry> LocalGeometry;
00134         // we could - if needed - introduce an other struct for dimglobal of Geometry
00135         typedef Dune::Entity<cd, dim, const GridImp, ALU3dGridEntity> Entity;
00136 
00137         typedef Dune::LevelIterator<cd,All_Partition,const GridImp,ALU3dGridLevelIterator> LevelIterator;
00138 
00139         typedef Dune::LeafIterator<cd,All_Partition,const GridImp,ALU3dGridLeafIterator> LeafIterator;
00140 
00141         typedef Dune::EntityPointer<const GridImp,ALU3dGridEntityPointer<cd,const GridImp> > EntityPointer;
00142 
00143         template <PartitionIteratorType pitype>
00144         struct Partition
00145         {
00146           typedef Dune::LevelIterator<cd,pitype,const GridImp,ALU3dGridLevelIterator> LevelIterator;
00147           typedef Dune::LeafIterator<cd,pitype,const GridImp,ALU3dGridLeafIterator> LeafIterator;
00148         };
00149 
00150       };
00151 
00152       typedef IndexSet<GridImp,LevelIndexSetImp,DefaultLevelIteratorTypes<GridImp> > LevelIndexSet;
00153       typedef IndexSet<GridImp,LeafIndexSetImp,DefaultLeafIteratorTypes<GridImp> > LeafIndexSet;
00154       typedef IdSet<GridImp,LocalIdSetImp,LocalIdType> LocalIdSet;
00155 
00156 #if ALU3DGRID_PARALLEL
00157       typedef IdSet<GridImp,GlobalIdSetImp,GlobalIdType> GlobalIdSet;
00158       typedef Dune :: CollectiveCommunication<MPI_Comm> CollectiveCommunication;
00159 #else 
00160       // in serial we use LocalIdSet as GlobalIdSet because it much faster
00161       // that global id set 
00162       typedef LocalIdSet GlobalIdSet;
00163       typedef Dune :: CollectiveCommunication<Grid> CollectiveCommunication;
00164 #endif
00165     };
00166   };
00167 
00188   template <int dim, int dimworld, ALU3dGridElementType elType>
00189   class ALU3dGrid : 
00190     public GridDefaultImplementation<dim, dimworld, alu3d_ctype, ALU3dGridFamily <dim,dimworld,elType> >,
00191     public HasObjectStream, 
00192     public HasHierarchicIndexSet 
00193   {
00194     // type of base class 
00195     typedef GridDefaultImplementation<dim, dimworld, alu3d_ctype, ALU3dGridFamily <dim,dimworld,elType> > BaseType;
00196     
00197     dune_static_assert(dim      == 3, "ALU3dGrid only implemented for 3dp");
00198     dune_static_assert(dimworld == 3, "ALU3dGrid only implemented for 3dw");
00199 
00200     typedef ALU3dGrid<dim,dimworld,elType> MyType; 
00201     typedef ALU3dGrid<dim,dimworld,elType> ThisType; 
00202 
00203     friend class ALU3dGridEntity <0,dim,MyType>;
00204     friend class ALU3dGridEntity <0,dim,const MyType>;
00205     friend class ALU3dGridEntity <1,dim,const MyType>;
00206     friend class ALU3dGridEntity <2,dim,const MyType>;
00207     friend class ALU3dGridEntity <3,dim,const MyType>;
00208     friend class ALU3dGridIntersectionIterator<MyType>;
00209 
00210     friend class ALU3dGridEntityPointerBase<0,const MyType >;
00211     friend class ALU3dGridEntityPointerBase<1,const MyType >;
00212     friend class ALU3dGridEntityPointer<1,const MyType >;
00213     friend class ALU3dGridEntityPointerBase<2,const MyType >;
00214     friend class ALU3dGridEntityPointer<2,const MyType >;
00215     friend class ALU3dGridEntityPointerBase<3,const MyType >;
00216     friend class ALU3dGridEntityPointer<3,const MyType >;
00217   
00218     friend class ALU3dGridIntersectionIterator<const MyType>;
00219     friend class ALU3dGridHierarchicIterator<const MyType>;
00220 
00221     friend class ALU3dGridHierarchicIndexSet<dim,dimworld,elType>;
00222     friend class ALU3dGridGlobalIdSet<dim,dimworld,elType>;
00223     friend class ALU3dGridLocalIdSet<dim,dimworld,elType>;
00224 
00225     //**********************************************************
00226     // The Interface Methods
00227     //**********************************************************
00228   public:
00229     enum { refineStepsForHalf = 1 };
00230     
00231     static const ALU3dGridElementType elementType = elType;
00232     typedef typename ALU3DSPACE GatherScatterType::ObjectStreamType ObjectStreamType;
00233 
00234     typedef ALU3dGridFamily<dim,dimworld,elType> GridFamily; 
00235     
00236     friend class Conversion< ALU3dGrid<dim,dimworld,elementType> , HasObjectStream > ;  
00237     friend class Conversion< const ALU3dGrid<dim,dimworld,elementType> , HasObjectStream > ; 
00238 
00239     friend class Conversion< ALU3dGrid<dim,dimworld,elementType> , HasHierarchicIndexSet > ;  
00240     friend class Conversion< const ALU3dGrid<dim,dimworld,elementType> , HasHierarchicIndexSet > ; 
00241 
00243     typedef typename ALU3dGridFamily < dim , dimworld , elType > :: Traits Traits;
00244 
00245   protected:  
00246     typedef MakeableInterfaceObject<typename Traits::template Codim<0>::Geometry> GeometryObject;
00247     friend class LocalGeometryStorage< GeometryObject , 8 >; 
00248 
00249   public: 
00250     
00252     typedef ALU3dGridHierarchicIndexSet<dim,dimworld,elType> HierarchicIndexSet;
00253 
00254     
00256     typedef typename GridFamily :: LevelIndexSetImp  LevelIndexSetImp; 
00258     typedef typename GridFamily :: LeafIndexSetImp  LeafIndexSetImp; 
00259 
00261     typedef typename SelectType<elType == tetra,
00262                           ReferenceSimplex<alu3d_ctype, dim>,
00263                           ReferenceCube   <alu3d_ctype, dim> >::Type ReferenceElementType;
00264 
00265   protected:
00267     typedef typename ALU3dGridFamily < dim , dimworld , elType > :: LocalIdSetImp LocalIdSetImp;
00268     
00270     typedef typename ALU3dGridFamily < dim , dimworld , elType > :: GlobalIdSetImp GlobalIdSetImp;
00271    
00273     typedef typename Traits :: GlobalIdSet GlobalIdSet;
00274     
00276     typedef typename Traits :: LocalIdSet LocalIdSet;
00277     
00279     typedef ALU3dGridLeafIterator<0, All_Partition, MyType> LeafIteratorImp;
00280     typedef typename Traits::template Codim<0>::LeafIterator LeafIteratorType;
00281     typedef typename Traits::template Codim<0>::LeafIterator LeafIterator;
00282     
00283     typedef ALU3dGridHierarchicIterator<MyType> HierarchicIteratorImp;
00284       
00285     typedef typename Traits :: CollectiveCommunication
00286       CollectiveCommunicationType;
00287 
00289     enum { 
00291       MAXL = 64 };
00292 
00294     enum { 
00296       newElementsChunk_ = 128 };
00297 
00299     enum { 
00303       refineEstimate_ = 8 };
00304 
00305   protected:
00308 #if ALU3DGRID_PARALLEL
00309     ALU3dGrid(const std::string macroTriangFilename , MPI_Comm mpiComm = MPI_COMM_WORLD );
00310 #else 
00311     ALU3dGrid(const std::string macroTriangFilename , int myrank = -1);
00312 #endif
00313   public:  
00314   
00316     ~ALU3dGrid();
00317 
00319     std::string name () const; 
00320    
00324     int maxLevel() const;
00325 
00327     template<int cd, PartitionIteratorType pitype>
00328     typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator
00329     lbegin (int level) const;
00330   
00332     template<int cd, PartitionIteratorType pitype>
00333     typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator
00334     lend (int level) const;
00335   
00337     template<int cd>
00338     typename Traits::template Codim<cd>::
00339     template Partition<All_Partition>::LevelIterator 
00340     lbegin (int level) const;
00341 
00343     template<int cd>
00344     typename Traits::template Codim<cd>::
00345     template Partition<All_Partition>::LevelIterator 
00346     lend (int level) const;
00347 
00348   private:  
00350     template <int codim, PartitionIteratorType pitype>
00351     typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator
00352     leafbegin(int level) const;
00353 
00355     template <int codim, PartitionIteratorType pitype>
00356     typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator
00357     leafend(int level) const;
00358 
00360     template <int codim>
00361     typename Traits::template Codim<codim>::LeafIterator
00362     leafbegin(int level) const;
00363 
00365     template <int codim>
00366     typename Traits::template Codim<codim>::LeafIterator
00367     leafend(int level) const;
00368 
00370     LeafIteratorType leafbegin (int level) const;
00371 
00373     LeafIteratorType leafend (int level) const;
00374 
00376     LeafIteratorType leafbegin () const;
00377 
00379     LeafIteratorType leafend () const;
00380 
00381   public:
00383     template <int codim, PartitionIteratorType pitype>
00384     typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator
00385     leafbegin() const;
00386 
00388     template <int codim, PartitionIteratorType pitype>
00389     typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator
00390     leafend() const;
00391 
00393     template <int codim>
00394     typename Traits::template Codim<codim>::LeafIterator
00395     leafbegin() const;
00396 
00398     template <int codim>
00399     typename Traits::template Codim<codim>::LeafIterator
00400     leafend() const;
00401 
00402   private:
00404     template <int codim, PartitionIteratorType pitype>
00405     typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator
00406     createLeafIteratorBegin (int level) const;
00407 
00409     template <int codim, PartitionIteratorType pitype>
00410     typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator
00411     createLeafIteratorEnd(int level) const;
00412     
00413   public:  
00415     int size (int level, int cd) const;
00416 
00418     int size (int codim) const;
00419 
00421     int size (int level, GeometryType type) const;
00422 
00424     int size (GeometryType type) const;
00425 
00427     int global_size (int cd) const ;
00428 
00429     // (no interface method) number of grid entities in the entire grid for given codim
00430     int hierSetSize (int cd) const;
00431 
00433     const GlobalIdSet & globalIdSet () const { 
00434 #if ALU3DGRID_PARALLEL
00435       if(!globalIdSet_) globalIdSet_ = new GlobalIdSetImp(*this); 
00436       return *globalIdSet_; 
00437 #else 
00438       // use local id set in serial 
00439       return localIdSet();
00440 #endif
00441     }
00442 
00444     const LocalIdSet & localIdSet () const { return localIdSet_; }
00445 
00447     const typename Traits :: LeafIndexSet & leafIndexSet () const; 
00448 
00450     const typename Traits :: LevelIndexSet & levelIndexSet (int level) const;
00451 
00456     bool loadBalance ();
00457   
00484     template <class DataHandle>
00485     bool loadBalance (DataHandle & data);
00486  
00488     int ghostSize (int level, int codim) const; 
00489 
00491     int overlapSize (int level, int codim) const { return 0; } 
00492 
00494     int ghostSize (int codim) const;
00495 
00497     int overlapSize (int codim) const { return 0; } 
00498 
00500     template<class DataHandleImp,class DataTypeImp>
00501     void communicate (CommDataHandleIF<DataHandleImp,DataTypeImp> & data, 
00502         InterfaceType iftype, CommunicationDirection dir, int level) const;
00503 
00507     template<class DataHandleImp,class DataTypeImp>
00508     void communicate (CommDataHandleIF<DataHandleImp,DataTypeImp> & data, 
00509         InterfaceType iftype, CommunicationDirection dir) const;
00510 
00511   private:
00512     typedef ALU3DSPACE GatherScatter GatherScatterType;
00514     void doCommunication (
00515                     GatherScatterType & vertexData,
00516                     GatherScatterType & edgeData,
00517                     GatherScatterType & faceData,
00518                     GatherScatterType & elementData,
00519                     InterfaceType iftype, CommunicationDirection dir) const; 
00520 
00521   public:
00523     const CollectiveCommunicationType & comm () const { return ccobj_; }
00524  
00526     bool preAdapt ( );
00527 
00529     void postAdapt ( );
00530 
00532     bool adapt ( );
00533 
00540     template <class DofManagerType, class RestrictProlongOperatorType>
00541     bool adapt (DofManagerType &dm, RestrictProlongOperatorType &rp, bool verbose=false );
00542 
00544     bool globalRefine(int refCount);
00545 
00546     //**********************************************************
00547     // End of Interface Methods
00548     //**********************************************************
00551     template <GrapeIOFileFormatType ftype>
00552     bool writeGrid( const std::string filename, alu3d_ctype time ) const ;
00553 
00554     bool writeGrid_Xdr( const std::string filename, alu3d_ctype time ) const ;
00556     bool writeGrid_Ascii( const std::string filename, alu3d_ctype time, bool scientific = false ) const ;
00557   
00560     template <GrapeIOFileFormatType ftype>
00561     bool readGrid( const std::string filename, alu3d_ctype & time );
00562 
00563     // (no interface method) get hierarchic index set of the grid
00564     const HierarchicIndexSet & hierarchicIndexSet () const { return hIndexSet_; }
00565 
00566     // set max of given mxl and actual maxLevel 
00567     // for loadBalance 
00568     void setMaxLevel (int mxl);
00569  
00570     // no interface method, but has to be public 
00571     void updateStatus ();
00572  
00574     bool mark( int refCount , const typename Traits::template Codim<0>::EntityPointer & ep );
00575     
00577     int getMark( const typename Traits::template Codim<0>::EntityPointer & ) const;
00578   private:
00579     bool mark( int refCount , const typename Traits::template Codim<0>::Entity & en );
00580     
00581   public:
00582     template <class IntersectionInterfaceType>
00583     const typename BaseType::
00584     template ReturnImplementationType<IntersectionInterfaceType> :: ImplementationType & 
00585     getRealIntersectionIterator(const IntersectionInterfaceType & it) const 
00586     {
00587       return this->getRealImplementation(it);
00588     }
00589 
00591     const std::vector<GeometryType>& geomTypes (int codim) const { return geomTypes_[codim]; }
00592     
00593     // return reference to org ALU3dGrid 
00594     // private method, but otherwise we have to friend class all possible
00595     // types of LevelIterator ==> later
00596     ALU3DSPACE GitterImplType & myGrid() const;
00597 
00599     const ReferenceElementType & referenceElement() const { return referenceElement_; }
00600 
00601   protected:
00603     ALU3dGrid( const MyType & g );
00604   
00606     ALU3dGrid<dim,dimworld,elType>& 
00607     operator = (const MyType & g); 
00608   
00610     void calcExtras();
00611   
00613     void calcMaxLevel();
00614   
00616     void recalcGlobalSize();
00617 
00619     void checkMacroGridFile (const std::string filename);
00620 
00622     void checkMacroGrid ();
00623 
00624     // the real ALU grid 
00625     mutable ALU3DSPACE GitterImplType * mygrid_;
00626 #if ALU3DGRID_PARALLEL
00627     ALU3DSPACE MpAccessMPI mpAccess_;
00628 #endif
00629 
00630     // collective comm, same as mpAccess_, only Peters "generic" (haha)version 
00631     CollectiveCommunicationType ccobj_;
00632 
00633   public:
00634     // number of links to other processors, for internal use only 
00635     int nlinks () const { 
00636 #if ALU3DGRID_PARALLEL
00637       return mpAccess_.nlinks();
00638 #else
00639       // if no other processors exist then links is 0 
00640       return 0; 
00641 #endif
00642     }
00643 
00644   private:
00645     // max level of grid 
00646     int maxlevel_; 
00647 
00648     // count how much elements where marked 
00649     mutable int coarsenMarked_;
00650     mutable int refineMarked_;
00651 
00652     // at the moment the number of different geom types is 1 
00653     enum { numberOfGeomTypes = 1 };
00654     std::vector< std::vector<GeometryType> > geomTypes_; 
00655 
00656     // create GeomTypes 
00657     void makeGeomTypes ();
00658   
00659     // our hierarchic index set 
00660     HierarchicIndexSet hIndexSet_;
00661 
00662     // out global id set 
00663     mutable GlobalIdSetImp * globalIdSet_; 
00664 
00665     // out global id set 
00666     LocalIdSetImp localIdSet_;
00667 
00668     // the level index set ( default type )
00669     mutable std::vector < LevelIndexSetImp * > levelIndexVec_;
00670 
00671     // the leaf index set
00672     mutable LeafIndexSetImp * leafIndexSet_;
00673  
00674     // the entity codim 0 
00675   public:
00676     typedef MakeableInterfaceObject<typename Traits::template Codim<0>::Entity> EntityObject; 
00677     typedef MakeableInterfaceObject<typename Traits::template Codim<1>::Entity> FaceObject; 
00678     typedef MakeableInterfaceObject<typename Traits::template Codim<2>::Entity> EdgeObject; 
00679     typedef MakeableInterfaceObject<typename Traits::template Codim<3>::Entity> VertexObject; 
00680   private:
00681     typedef ALUMemoryProvider< EntityObject > EntityProvider;
00682     typedef ALUMemoryProvider< FaceObject >   FaceProvider;
00683     typedef ALUMemoryProvider< EdgeObject >   EdgeProvider;
00684     typedef ALUMemoryProvider< VertexObject > VertexProvider;
00685   
00686     template <int codim> 
00687     inline MakeableInterfaceObject<typename Traits::template Codim<codim>::Entity> * 
00688     getNewEntity ( int level = -1 ) const
00689     {
00690       return ALU3dGridEntityFactory<MyType,codim>::getNewEntity(*this,level);
00691     }
00692 
00693     template <int codim>
00694     inline void freeEntity (MakeableInterfaceObject<typename Traits::template Codim<codim>::Entity> * en) const
00695     {
00696       ALU3dGridEntityFactory<MyType,codim>::freeEntity(*this, en);
00697     }
00698   
00699     mutable EntityProvider   entityProvider_;
00700     mutable FaceProvider     faceProvider_;
00701     mutable EdgeProvider     edgeProvider_;
00702     mutable VertexProvider   vertexProvider_;
00703   
00704     // the reference element 
00705     ReferenceElementType referenceElement_;
00706 
00707     typedef ALU3dGridVertexList VertexListType; 
00708     mutable VertexListType vertexList_[MAXL];   
00709 
00710     mutable ALU3dGridItemListType ghostLeafList_[dim];   
00711     mutable ALU3dGridItemListType ghostLevelList_[dim][MAXL];   
00712     
00713     mutable ALU3dGridItemListType levelEdgeList_[MAXL];   
00714 
00715     typedef ALU3dGridLeafVertexList LeafVertexListType; 
00716     mutable LeafVertexListType leafVertexList_;
00717   public:  
00718     LeafVertexListType & getLeafVertexList() const 
00719     {
00720       if( !leafVertexList_.up2Date() ) leafVertexList_.setupVxList(*this);
00721       return leafVertexList_;
00722     }
00723 
00724     int getLevelOfLeafVertex(const ALU3DSPACE VertexType & vertex) const
00725     {
00726       assert( leafVertexList_.up2Date() );
00727       return leafVertexList_.getLevel(vertex);
00728     }
00729       
00730     VertexListType & getVertexList(int level) const 
00731     {
00732       assert( level >= 0 );
00733       assert( level <= maxLevel() );
00734       VertexListType & vxList = vertexList_[level];
00735       if(!vxList.up2Date()) vxList.setupVxList(*this,level);
00736       return vxList; 
00737     }
00738     
00739     ALU3dGridItemListType & getGhostLeafList(int codim) const
00740     {
00741       assert( codim >= 1 );
00742       assert( codim <= 3 );
00743       return ghostLeafList_[codim-1];
00744     }
00745     
00746     ALU3dGridItemListType & getGhostLevelList(int codim, int level) const
00747     {
00748       assert( codim >= 1 );
00749       assert( codim <= 3 );
00750 
00751       assert( level >= 0 );
00752       assert( level <= maxLevel() );
00753       return ghostLevelList_[codim-1][level];
00754     }
00755     
00756     ALU3dGridItemListType & getEdgeList(int level) const 
00757     { 
00758       assert( level >= 0 );
00759       assert( level <= maxLevel() );
00760       return levelEdgeList_[level]; 
00761     }
00762   private:  
00763     
00764     // the type of our size cache 
00765     typedef SingleTypeSizeCache<MyType> SizeCacheType;
00766     SizeCacheType * sizeCache_;
00767 
00768     // new intersection iterator is a wrapper which get itersectioniteratoimp as pointers
00769   public:    
00770     typedef ALU3dGridIntersectionIterator<const ThisType>
00771       IntersectionIteratorImp;
00772     typedef ALU3dGridIntersectionIterator<const ThisType>
00773       LeafIntersectionIteratorImp;
00774     typedef ALU3dGridLevelIntersectionIterator<const ThisType>
00775       LevelIntersectionIteratorImp;
00776 
00777     typedef ALUMemoryProvider< LeafIntersectionIteratorImp > LeafIntersectionIteratorProviderType;
00778     typedef ALUMemoryProvider< LevelIntersectionIteratorImp >   LevelIntersectionIteratorProviderType;
00779   private:
00780     friend class LeafIntersectionIteratorWrapper < const ThisType > ;
00781     friend class LevelIntersectionIteratorWrapper< const ThisType > ;
00782     // return reference to intersectioniterator storage
00783     LeafIntersectionIteratorProviderType & leafIntersetionIteratorProvider() const { return leafInterItProvider_; }
00784     mutable LeafIntersectionIteratorProviderType leafInterItProvider_;
00785     LevelIntersectionIteratorProviderType & levelIntersetionIteratorProvider() const { return levelInterItProvider_; }
00786     mutable LevelIntersectionIteratorProviderType levelInterItProvider_;
00787 
00788     friend class ALU3dGridEntityFactory<MyType,0>;
00789     friend class ALU3dGridEntityFactory<MyType,1>;
00790     friend class ALU3dGridEntityFactory<MyType,2>;
00791     friend class ALU3dGridEntityFactory<MyType,3>;
00792 
00793     // variable to ensure that postAdapt ist called after adapt
00794     bool lockPostAdapt_;
00795   }; // end class ALU3dGrid
00796 
00797   template <class GridImp>
00798   struct ALU3dGridEntityFactory<GridImp,0>
00799   {
00800     enum { codim = 0 };
00801     typedef typename GridImp :: template Codim<codim> :: Entity Entity;
00802     typedef MakeableInterfaceObject<Entity> EntityObject;
00803     typedef typename EntityObject :: ImplementationType EntityImp;
00804     
00805     inline static EntityObject * 
00806     getNewEntity (const GridImp& grid, int level)
00807     {
00808       return grid.entityProvider_.getEntityObject( grid, level, (EntityImp *) 0);
00809     }
00810 
00811     inline static void freeEntity(const GridImp& grid, EntityObject * e )
00812     {
00813       grid.entityProvider_.freeObject( e );
00814     }
00815   };
00816 
00817   template <class GridImp>
00818   struct ALU3dGridEntityFactory<GridImp,1>
00819   {
00820     enum { codim = 1 };
00821     typedef typename GridImp :: template Codim<codim> :: Entity Entity;
00822     typedef MakeableInterfaceObject<Entity> EntityObject;
00823     typedef typename EntityObject :: ImplementationType EntityImp;
00824     
00825     inline static EntityObject * 
00826     getNewEntity (const GridImp& grid, int level)
00827     {
00828       return grid.faceProvider_.getEntityObject( grid, level, (EntityImp *) 0);
00829     }
00830 
00831     inline static void freeEntity(const GridImp& grid, EntityObject * e )
00832     {
00833       grid.faceProvider_.freeObject( e );
00834     }
00835   };
00836 
00837   template <class GridImp>
00838   struct ALU3dGridEntityFactory<GridImp,2>
00839   {
00840     enum { codim = 2 };
00841     typedef typename GridImp :: template Codim<codim> :: Entity Entity;
00842     typedef MakeableInterfaceObject<Entity> EntityObject;
00843     typedef typename EntityObject :: ImplementationType EntityImp;
00844     
00845     inline static EntityObject * 
00846     getNewEntity (const GridImp& grid, int level)
00847     {
00848       return grid.edgeProvider_.getEntityObject( grid, level, (EntityImp *) 0);
00849     }
00850 
00851     inline static void freeEntity(const GridImp& grid, EntityObject * e )
00852     {
00853       grid.edgeProvider_.freeObject( e );
00854     }
00855   };
00856   
00857   template <class GridImp>
00858   struct ALU3dGridEntityFactory<GridImp,3>
00859   {
00860     enum { codim = 3 };
00861     typedef typename GridImp :: template Codim<codim> :: Entity Entity;
00862     typedef MakeableInterfaceObject<Entity> EntityObject;
00863     typedef typename EntityObject :: ImplementationType EntityImp;
00864     
00865     inline static EntityObject * 
00866     getNewEntity (const GridImp& grid, int level)
00867     {
00868       return grid.vertexProvider_.getEntityObject( grid, level, (EntityImp *) 0);
00869     }
00870 
00871     inline static void freeEntity(const GridImp& grid, EntityObject * e )
00872     {
00873       grid.vertexProvider_.freeObject( e );
00874     }
00875   };
00876 
00877 
00878     bool checkMacroGrid ( ALU3dGridElementType elType , 
00879                           const std::string filename );
00880     const char* elType2Name( ALU3dGridElementType elType );
00881 
00882   namespace Capabilities {
00883     
00884     template<int dim, int dimw, Dune::ALU3dGridElementType elType, int cdim>
00885     struct hasEntity<Dune::ALU3dGrid<dim, dimw, elType>, cdim >
00886     {
00887       static const bool v = true;
00888     };
00889     
00890     template <int dim, int dimw, ALU3dGridElementType elType>
00891     struct isParallel<const ALU3dGrid<dim, dimw, elType> > {
00892       static const bool v = true;
00893     };
00894 
00895   template<int dim, int dimw, Dune::ALU3dGridElementType elType>
00896   struct isLevelwiseConforming< ALU3dGrid<dim,dimw,elType> >
00897   {
00898     static const bool v = true;
00899   };
00900   
00901   template<int dim, int dimw, Dune::ALU3dGridElementType elType>
00902   struct hasHangingNodes< ALU3dGrid<dim,dimw,elType> >
00903   {
00904     static const bool v = true;
00905   };
00906 
00907   template<int dim, int dimw, Dune::ALU3dGridElementType elType>
00908   struct hasBackupRestoreFacilities< ALU3dGrid<dim,dimw,elType> >
00909   {
00910     static const bool v = true;
00911   };
00912 
00913   } // end namespace Capabilities
00914   
00915 } // end namespace Dune
00916 
00917 #include "grid_imp.cc"
00918 #endif

Generated on 6 Nov 2008 with Doxygen (ver 1.5.6) [logfile].