agrid.hh

Go to the documentation of this file.
00001 #ifndef DUNE_ALBERTAGRID_IMP_HH
00002 #define DUNE_ALBERTAGRID_IMP_HH
00003 #include <iostream>
00004 #include <fstream>
00005 
00006 #include <vector>
00007 #include <assert.h>
00008 #include <algorithm>
00009 
00015 // only use GRIDDIM when 2 or 3 
00016 #if defined GRIDDIM && GRIDDIM > 1 && GRIDDIM < 4 
00017   #define DIM GRIDDIM
00018   #if defined GRIDDIMWORLD 
00019     #define DIM_OF_WORLD GRIDDIMWORLD
00020   #else  
00021     // DIM_OF_WORLD is set to DIM by default 
00022     #define DIM_OF_WORLD GRIDDIM
00023   #endif
00024 #else
00025   #ifndef ALBERTA_DIM
00026     #error "ALBERTA_DIM needed to compile AlbertaGrid! \n"
00027   #endif
00028 
00029   #ifndef ALBERTA_WORLD_DIM
00030     #ifdef ALBERTA_DIM 
00031       #define ALBERTA_WORLD_DIM ALBERTA_DIM
00032     #else  
00033       #error "ALBERTA_WORLD_DIM needed to compile AlbertaGrid! \n"
00034     #endif
00035   #endif
00036 
00037   #define DIM ALBERTA_DIM
00038   #define DIM_OF_WORLD ALBERTA_WORLD_DIM
00039 #endif
00040 
00041 // Dune includes
00042 #include <dune/common/misc.hh>
00043 #include <dune/common/interfaces.hh>
00044 #include <dune/common/fvector.hh>
00045 #include <dune/common/fmatrix.hh>
00046 #include <dune/grid/common/capabilities.hh>
00047 #include <dune/common/stdstreams.hh>
00048 
00049 #if HAVE_MPI
00050 #include <dune/common/mpicollectivecommunication.hh>
00051 #else
00052 #include <dune/common/collectivecommunication.hh>
00053 #endif
00054 
00055 #include <dune/common/exceptions.hh>
00056 
00057 #include <dune/grid/common/grid.hh>
00058 #include <dune/grid/common/defaultindexsets.hh>
00059 #include <dune/grid/common/sizecache.hh>
00060 #include <dune/grid/common/intersectioniteratorwrapper.hh>
00061 
00062 // stack for index management 
00063 #include <dune/grid/common/indexstack.hh>
00064 
00065 //- Local includes 
00066 // some cpp defines and include of alberta.h
00067 #include "albertaheader.hh"
00068 
00069 // grape data io 
00070 #include <dune/grid/utility/grapedataioformattypes.hh>
00071 
00072 // IndexManager defined in indexstack.hh 
00073 // 10000 is the size of the finite stack used by IndexStack
00074 typedef Dune::IndexStack<int,10000> IndexManagerType;
00075 
00076 //#define CALC_COORD
00077 // some extra functions for handling the Albert Mesh  
00078 #include "albertaextra.hh"
00079 
00080 namespace Dune {
00081   // own exception classes
00082   class AlbertaError   : public Exception {};
00083   class AlbertaIOError : public IOError {};  
00084 }
00085 
00086 // contains a simple memory management for some componds of this grid 
00087 #include "agmemory.hh"
00088 
00089 #include "referencetopo.hh"
00090 #include "indexsets.hh"
00091 
00092 // contains the communication for parallel computing for this grid
00093 #include "agcommunicator.hh"
00094 
00095 namespace Dune 
00096 {
00097 
00098   // i.e. double or float 
00099   typedef ALBERTA REAL albertCtype;
00100 
00101   template<int codim, int dim, class GridImp> class AlbertaGridEntity;
00102   template<int codim, int dim, class GridImp> class AlbertaGridMakeableEntity;
00103   template<int codim, PartitionIteratorType pitype, class GridImp> class AlbertaGridTreeIterator;
00104   template<int codim, PartitionIteratorType pitype, class GridImp> class AlbertaGridLeafIterator;
00105   template<int cd, class GridImp> class AlbertaGridEntityPointer;
00106 
00107   template <int mydim, int cdim, class GridImp> class AlbertaGridGeometry;
00108   template<class GridImp>         class AlbertaGridHierarchicIterator;
00109   template<class GridImp>         class AlbertaGridIntersectionIterator;
00110   template<int dim, int dimworld> class AlbertaGrid;
00111   template<int dim, int dimworld> class AlbertaGridHierarchicIndexSet;
00112 
00113   template <int codim, int dim, class GridImp> 
00114   struct SelectEntityImp
00115   {
00116     typedef AlbertaGridEntity<codim,dim,GridImp> EntityImp;
00117     typedef Dune::Entity<codim, dim, const GridImp, AlbertaGridEntity> Entity;
00118     typedef MakeableInterfaceObject<Entity> EntityObject;
00119   };
00120 
00124   class AlbertaMarkerVector 
00125   {
00126     friend class AlbertaGrid<2,2>;
00127     friend class AlbertaGrid<2,3>;
00128     friend class AlbertaGrid<3,3>;
00129 
00130     enum { vxBufferSize_ = 10000 };
00131   public:
00134     AlbertaMarkerVector (bool meLevel=true) : up2Date_(false), meLevel_(meLevel) {} ;
00135 
00137     bool vertexNotOnElement(const int elIndex, const int vertex) const;
00138 
00140     bool edgeNotOnElement(const int elIndex, const int edge) const;
00141 
00143     bool faceNotOnElement(const int elIndex, const int face) const;
00144 
00146     template <class GridType>
00147     void markNewVertices(GridType &grid, int level);
00148    
00150     template <class GridType>
00151     void markNewLeafVertices(GridType &grid);
00152   
00154     bool up2Date () const { return up2Date_; }
00155 
00157     void unsetUp2Date () { up2Date_ = false; }
00158  
00160     void print() const;
00161 
00162   private:
00163     typedef std::vector<int> ArrayType;
00164     
00165     // built in array to mark on which element a vertex is reached
00166     ArrayType vec_;
00167     ArrayType edgevec_;
00168     ArrayType facevec_;
00169 
00170     // number of vertices 
00171     int numVertex_;
00172 
00173     // true is vertex marker is up to date 
00174     bool up2Date_;
00175     bool meLevel_; 
00176   };
00177 
00178   //**********************************************************************
00179   //
00180   // --AlbertaGridGeometry
00193   //******************************************************
00194   //
00195   //  --Geometry 
00196   //
00197   //******************************************************
00198   template <int mydim, int cdim, class GridImp>
00199   class AlbertaGridGeometry : 
00200     public GeometryDefaultImplementation<mydim,cdim,GridImp,AlbertaGridGeometry>
00201   { 
00202 
00203     typedef AlbertaGridGeometry<mydim,cdim,GridImp> ThisType;
00204 
00206     enum { dimbary=mydim+1};
00207   public:
00209     AlbertaGridGeometry();
00210 
00212     AlbertaGridGeometry(const int child, const int orientation );
00213 
00216     const GeometryType & type () const;
00217 
00219     int corners () const;
00220 
00222     const FieldVector<albertCtype, cdim> & operator[] (int i) const;
00223 
00226     FieldVector<albertCtype, cdim> global (const FieldVector<albertCtype, mydim>& local) const;
00227   
00230     FieldVector<albertCtype, mydim> local (const FieldVector<albertCtype, cdim>& global) const;
00231   
00233     bool checkInside(const FieldVector<albertCtype, mydim>& local) const;
00234 
00258     // A(l) 
00259     albertCtype integrationElement (const FieldVector<albertCtype, mydim>& local) const;
00260 
00261     // volume if geometry  
00262     albertCtype volume () const;
00263 
00268     const FieldMatrix<albertCtype,mydim,mydim>& jacobianInverseTransposed (const FieldVector<albertCtype, mydim>& local) const;
00269 
00270     //***********************************************************************
00272     //***********************************************************************
00275     typedef GridImp GridType;
00276     bool builtGeom(const GridImp & grid, ALBERTA EL_INFO *elInfo, int face, int edge, int vertex);
00277 
00280     template <class GeometryType, class LocalGeomType >
00281     bool builtLocalGeom(const GeometryType & geo , const LocalGeomType & lg, 
00282                         ALBERTA EL_INFO *elInfo, int face);
00283 
00284     // init geometry with zeros 
00286     void initGeom();
00287     FieldVector<albertCtype, cdim>& getCoordVec (int i);
00288 
00291     void print (std::ostream& ss) const;
00292 
00293   private:
00294     // build geometry with local coords of child in reference element 
00295     void buildGeomInFather(const int child, const int orientation);
00296 
00297     // calculate Matrix for Mapping from reference element to actual element
00298     void calcElMatrix () const;
00299  
00301     void buildJacobianInverseTransposed () const; 
00302 
00303     // template method for map the vertices of EL_INFO to the actual 
00304     // coords with face_,edge_ and vertex_ , needes for operator []
00305     int mapVertices (int i) const; 
00306 
00307     // calculates the volume of the element 
00308     albertCtype elDeterminant () const;
00309 
00310     // temporary need vector 
00311     mutable FieldVector<albertCtype, mydim+1> tmpVec_;
00312 
00314     mutable FieldMatrix<albertCtype,mydim+1,cdim> coord_;
00315 
00317     mutable FieldVector<albertCtype, cdim> globalCoord_;
00318 
00320     mutable FieldVector<albertCtype, mydim> localCoord_;
00321 
00322     // make empty EL_INFO 
00323     ALBERTA EL_INFO * makeEmptyElInfo();
00324   
00325     ALBERTA EL_INFO * elInfo_;
00326   
00328     int face_;
00329   
00331     int edge_;
00332   
00334     int vertex_;
00335 
00336     enum { matdim = (mydim > 0) ? mydim : 1 };
00337     mutable FieldMatrix<albertCtype,matdim,matdim> Jinv_; 
00338     mutable FieldMatrix<albertCtype,matdim,matdim> Mtmp_;    
00339   
00340     mutable FieldMatrix<albertCtype,cdim,mydim> elMat_; 
00341     mutable FieldMatrix<albertCtype,matdim,matdim> elMatT_elMat_; 
00342 
00344     mutable bool builtElMat_;
00346     mutable bool builtinverse_;
00347     
00348 
00349     mutable bool calcedDet_; 
00350     mutable albertCtype elDet_; 
00351 
00352     // temporary mem for integrationElement with mydim < cdim 
00353     mutable FieldVector<albertCtype,cdim> tmpV_;
00354     mutable FieldVector<albertCtype,cdim> tmpU_;
00355     mutable FieldVector<albertCtype,cdim> tmpZ_;
00356 
00357     mutable FieldVector<albertCtype,mydim> AT_x_;
00358     const GeometryType myGeomType_;
00359     const albertCtype detFactor_;
00360   };
00361 
00362   //**********************************************************************
00363   //
00364   // --AlbertaGridEntity
00365   // --Entity
00366   //
00373   template<int cd, int dim, class GridImp>
00374   class AlbertaGridEntity : 
00375     public EntityDefaultImplementation <cd,dim,GridImp,AlbertaGridEntity>
00376   {
00377     enum { dimworld = GridImp::dimensionworld };
00378     friend class AlbertaGrid < dim , dimworld >;
00379     friend class AlbertaGridEntity < 0, dim, GridImp>;
00380     friend class AlbertaGridTreeIterator < cd, All_Partition,GridImp>;
00381     friend class AlbertaGridMakeableEntity<cd,dim,GridImp>;
00382     friend class AlbertaGridEntityPointer<cd,GridImp>;
00383 
00384     typedef AlbertaGridGeometry<dim-cd,dimworld,GridImp> GeometryImp;
00385   public:
00386     template <int cc>
00387     struct Codim
00388     {
00389       typedef typename GridImp::template Codim<cc>::EntityPointer EntityPointer;
00390     };
00391 
00392     typedef typename GridImp::template Codim<cd>::Entity Entity;
00393     typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
00394     typedef typename GridImp::template Codim<cd>::Geometry Geometry;
00395     typedef typename GridImp::template Codim<cd>::LevelIterator LevelIterator;
00396 
00398     int level () const;
00399 
00401     int boundaryId () const ;
00402   
00404     AlbertaGridEntity(const GridImp &grid, int level, 
00405                       ALBERTA TRAVERSE_STACK * travStack);
00406  
00408     AlbertaGridEntity(const GridImp &grid, int level, bool);
00409 
00411     AlbertaGridEntity(const AlbertaGridEntity & org);
00412 
00414     PartitionType partitionType() const; 
00415 
00417     const Geometry & geometry () const;
00418 
00419     /*
00420      * works but not in interface anymore.
00421     EntityPointer ownersFather () const; 
00422 
00424     const FieldVector<albertCtype, dim>& positionInOwnersFather () const; 
00425     */
00426   
00427     //***********************************************
00428     //  End of Interface methods 
00429     //***********************************************
00431     ALBERTA EL_INFO *getElInfo () const;
00433     ALBERTA EL *getElement () const;
00434 
00436     void removeElInfo(); 
00437 
00440     int getFEVnum () const;
00441 
00443     bool equals ( const AlbertaGridEntity<cd,dim,GridImp> & i) const;
00444     
00445     // dummy function, only needed for codim 0 
00446     bool leafIt () const { return false; }
00447     
00448     // methods for setting the infos from the albert mesh
00449     void setTraverseStack (ALBERTA TRAVERSE_STACK *travStack);
00450     void setElInfo (ALBERTA EL_INFO *elInfo, int face,
00451                     int edge, int vertex );
00452   
00453     // same as setElInfo just with a entity given 
00454     void setEntity (const AlbertaGridEntity<cd,dim,GridImp> & org);
00455 
00456     // set level of entity 
00457     void setLevel ( int newLevel ); 
00458     void setNewLevel ( int newLevel , bool ) { setLevel(level); }
00459   
00460   private: 
00461     // the grid this entity belong to 
00462     const GridImp &grid_;
00463 
00464     // Alberta element info
00465     ALBERTA EL_INFO *elInfo_;
00466 
00467     // Alberta element 
00468     ALBERTA EL * element_;
00469   
00470     // current traverse stack this entity belongs too
00471     ALBERTA TRAVERSE_STACK * travStack_;
00472 
00474     int level_;
00475 
00476     // type of createable object, just derived from Geometry class
00477     typedef MakeableInterfaceObject<Geometry> GeometryObject;
00478       
00480     GeometryObject geo_;
00482     mutable GeometryImp & geoImp_;
00483   
00485     mutable bool builtgeometry_;  
00486 
00488     mutable FieldVector<albertCtype, dim> localFatherCoords_; 
00489     mutable bool localFCoordCalced_;
00490 
00492     int face_;
00493 
00495     int edge_;
00496   
00498     int vertex_;
00499   };
00500 
00514   //***********************
00515   //  
00516   //  --AlbertaGridEntity
00517   //  --0Entity
00518   //
00519   //***********************
00520   template<int dim, class GridImp>
00521   class AlbertaGridEntity<0,dim,GridImp> : 
00522     public EntityDefaultImplementation <0,dim,GridImp,AlbertaGridEntity>
00523   {
00524     enum { dimworld = GridImp::dimensionworld };
00525     friend class AlbertaGrid < dim , GridImp::dimensionworld >;
00526     friend class AlbertaMarkerVector;
00527     friend class AlbertaGridIntersectionIterator <GridImp>;
00528     friend class AlbertaGridHierarchicIterator <GridImp>;
00529     friend class AlbertaGridTreeIterator <0,All_Partition,GridImp>;
00530     friend class AlbertaGridMakeableEntity<0,dim,GridImp>;
00531     friend class AlbertaGridEntityPointer<0,GridImp>;
00532   public:
00533     template <int cd>
00534     struct Codim
00535     {
00536       typedef typename GridImp::template Codim<cd>::EntityPointer EntityPointer;
00537     };
00538 
00539     typedef typename GridImp::template Codim<0>::Entity Entity;
00540     typedef typename GridImp::template Codim<0>::Geometry Geometry;
00541     typedef AlbertaGridGeometry<dim,dimworld,GridImp> GeometryImp;
00542 
00543     typedef typename GridImp::template Codim<0>::LevelIterator LevelIterator;
00544     typedef typename GridImp::template Codim<0>::HierarchicIterator HierarchicIterator;
00545     typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
00546 
00547     typedef LeafIntersectionIteratorWrapper<GridImp> AlbertaGridLeafIntersectionIteratorType;
00548     typedef AlbertaGridLeafIntersectionIteratorType  AlbertaGridIntersectionIteratorType;
00549     typedef AlbertaGridLeafIntersectionIteratorType  AlbertaGridLevelIntersectionIteratorType;
00550 
00551     enum { dimension = dim };
00552   
00556     ~AlbertaGridEntity() {};
00557 
00559     AlbertaGridEntity(const GridImp &grid, int level, bool leafIt );
00560 
00561     AlbertaGridEntity(const AlbertaGridEntity & org);
00562     
00564     int level () const;
00565 
00567     int boundaryId () const;
00568 
00570     const Geometry & geometry () const;
00571 
00575 
00576     template<int cc> int count () const; 
00577   
00580     template<int cc> typename Codim<cc>::EntityPointer entity (int i) const;
00581 
00584     //template<int cc> void entity (AlbertaGridTreeIterator<cc,dim,dimworld>& it, int i);
00585 
00591     AlbertaGridLeafIntersectionIteratorType ileafbegin () const;
00592     AlbertaGridIntersectionIteratorType ibegin () const
00593     {
00594       return ileafbegin();
00595     }
00596 
00597     AlbertaGridLevelIntersectionIteratorType ilevelbegin () const
00598     {
00599       DUNE_THROW(NotImplemented,"method ilevelbegin not implemented!"); 
00600       return ileafbegin();
00601     }
00602 
00604     AlbertaGridIntersectionIteratorType ileafend () const;
00605     AlbertaGridIntersectionIteratorType iend () const{ return ileafend();}
00606     AlbertaGridLeafIntersectionIteratorType ilevelend () const
00607     {
00608       DUNE_THROW(NotImplemented,"method ilevelend not implemented!"); 
00609       return ibegin();
00610     }
00611 
00613     bool isLeaf () const ; 
00614 
00617     EntityPointer father () const;
00618 
00629     const Geometry & geometryInFather () const;
00630   
00635     AlbertaGridHierarchicIterator<GridImp> hbegin (int maxlevel) const;
00636   
00638     AlbertaGridHierarchicIterator<GridImp> hend (int maxlevel) const;
00639 
00642     bool wasRefined () const ;
00643 
00646     bool mightBeCoarsened () const ;
00647 
00650     bool hasBoundaryIntersections () const ;
00651     
00653     PartitionType partitionType() const; 
00654 
00656     bool equals ( const AlbertaGridEntity<0,dim,GridImp> & i) const;
00657 
00658     //***************************************************************
00659     //  Interface for parallelisation 
00660     //***************************************************************
00661     // set leaf data with processor number  
00662     void setLeafData( int proc );
00663 
00664     // return true if this entity belong to master set of this grid   
00665     bool master() const; 
00666 
00667     // return 0 for elements 
00668     int getFEVnum () const { return 0; } 
00669 
00670     // needed for LevelIterator to compare 
00671     ALBERTA EL_INFO *getElInfo () const;
00672 
00673     // return element for equaltiy in EntityPointer 
00674     ALBERTA EL *getElement () const;
00675 
00676     // set elInfo and Element to nil
00677     void removeElInfo();
00678     
00679     // returns true if entity comes from LeafIterator 
00680     bool leafIt () const { return leafIt_; }
00681     
00682     // face, edge and vertex only for codim > 0, in this
00683     // case just to supply the same interface
00684     void setTraverseStack (ALBERTA TRAVERSE_STACK *travStack);
00685     void setElInfo (ALBERTA EL_INFO *elInfo,
00686                     int face = 0,
00687                     int edge = 0,
00688                     int vertex = 0 );
00689 
00690     // same as setElInfo just with a entity given 
00691     void setEntity (const AlbertaGridEntity<0,dim,GridImp> & org);
00692 
00693   private: 
00695     int nChild () const;
00696     
00698     void makeDescription();
00699 
00701     const GridImp & grid_;
00702 
00704     int level_;
00705 
00707     ALBERTA TRAVERSE_STACK * travStack_;
00708 
00710     ALBERTA EL_INFO *elInfo_;
00711   
00713     ALBERTA EL *element_;
00714 
00715     // local coordinates within father 
00716     typedef MakeableInterfaceObject<Geometry> GeometryObject;
00717 
00719     mutable GeometryObject geoObj_;
00720     mutable GeometryImp & geo_;
00721     mutable bool builtgeometry_;  
00722 
00723     // is true if entity comes from leaf iterator 
00724     bool leafIt_; 
00725   
00726   }; // end of AlbertaGridEntity codim = 0
00727 
00728 
00729   //**********************************************************************
00730   //
00731   // --AlbertaGridEntityPointer
00732   // --EntityPointer
00733   // --EnPointer
00737   template<int cd, class GridImp>
00738   class AlbertaGridEntityPointer :
00739     public EntityPointerDefaultImplementation <cd, GridImp, AlbertaGridEntityPointer<cd,GridImp> >
00740   {
00741     enum { dim       = GridImp::dimension };
00742     enum { dimworld  = GridImp::dimensionworld };
00743 
00744     friend class AlbertaGridEntity<cd,dim,GridImp>;
00745     friend class AlbertaGridEntity< 0,dim,GridImp>;
00746     friend class AlbertaGrid < dim , dimworld >;
00747 
00748   public:
00749     typedef typename GridImp::template Codim<cd>::Entity Entity;
00750     typedef typename SelectEntityImp<cd,dim,GridImp>::EntityImp EntityImp;
00751     typedef typename SelectEntityImp<cd,dim,GridImp>::EntityObject EntityObject;
00752     typedef AlbertaGridEntityPointer<cd,GridImp> Base;
00753   
00755     typedef AlbertaGridEntityPointer<cd,GridImp> AlbertaGridEntityPointerType;
00756 
00758     AlbertaGridEntityPointer(const GridImp & grid, 
00759                              int level,  ALBERTA EL_INFO *elInfo,int face,int edge,int vertex);
00760 
00762     AlbertaGridEntityPointer(const GridImp & grid, ALBERTA TRAVERSE_STACK * stack,
00763                              int level,  ALBERTA EL_INFO *elInfo,int face,int edge,int vertex);
00764 
00766     AlbertaGridEntityPointer(const GridImp & grid, int level , bool isLeaf, bool done);
00767 
00769     AlbertaGridEntityPointer(const AlbertaGridEntityPointerType & org);
00770 
00772     AlbertaGridEntityPointer(const GridImp & , const EntityImp & en);
00773 
00775     AlbertaGridEntityPointer& operator= (const AlbertaGridEntityPointer& org);
00776 
00778     ~AlbertaGridEntityPointer();
00779 
00781     bool equals (const AlbertaGridEntityPointerType& i) const;
00782 
00784     Entity & dereference () const ;
00785 
00787     int level () const ;
00788 
00790     void done ();
00791 
00792   protected:
00794     bool leafIt () const { return isLeaf_; }
00795 
00797     EntityImp & entityImp (); 
00798 
00800     const EntityImp & entityImp () const; 
00801     
00802     // reference to grid 
00803     const GridImp & grid_;
00804 
00806     bool isLeaf_;
00807 
00808     // entity that this EntityPointer points to 
00809     EntityObject * entity_;
00810   };
00811 
00812 
00813   //**********************************************************************
00814   //
00815   // --AlbertaGridHierarchicIterator
00816   // --HierarchicIterator
00826   template<class GridImp>
00827   class AlbertaGridHierarchicIterator :
00828     public AlbertaGridEntityPointer<0,GridImp> ,
00829     public HierarchicIteratorDefaultImplementation <GridImp,AlbertaGridHierarchicIterator>
00830   {
00831   public:
00832     typedef typename GridImp::template Codim<0>::Entity Entity;
00833     typedef typename GridImp::ctype ctype;
00834 
00835     //typedef AlbertaGridMakeableEntity<0,GridImp::dimension,GridImp> EntityImp;
00836     typedef typename SelectEntityImp<0,GridImp::dimension,GridImp>::EntityImp EntityImp;
00837 
00839     AlbertaGridHierarchicIterator(const GridImp &grid,
00840                                   ALBERTA TRAVERSE_STACK *travStack, 
00841                                   int actLevel, int maxLevel, bool leafIt );
00842 
00844     AlbertaGridHierarchicIterator(const GridImp &grid,
00845                                   int actLevel,int maxLevel);
00846   
00848     AlbertaGridHierarchicIterator(const AlbertaGridHierarchicIterator<GridImp> &org);
00849  
00851     AlbertaGridHierarchicIterator<GridImp> & operator = (const AlbertaGridHierarchicIterator<GridImp> &org);
00852  
00854     void increment();
00855 
00856   private:
00857     const int startLevel_;
00858     
00860     int level_;
00861 
00863     int maxlevel_;
00864 
00866     EntityImp & virtualEntity_;
00867 
00870     ALBERTA ManageTravStack manageStack_;
00871 
00873     bool end_;
00874 
00876     ALBERTA EL_INFO * recursiveTraverse(ALBERTA TRAVERSE_STACK * stack);
00877 
00879     ALBERTA EL_INFO * firstChild(ALBERTA TRAVERSE_STACK * stack);
00880 
00882     void makeIterator();
00883   };
00884 
00885 
00886   //**********************************************************************
00887   //
00888   // --AlbertaGridIntersectionIterator
00889   // --IntersectionIterator
00897   template<class GridImp>
00898   class AlbertaGridIntersectionIterator : 
00899     //public AlbertaGridEntityPointer<0,GridImp> ,
00900     public IntersectionIteratorDefaultImplementation <GridImp,AlbertaGridIntersectionIterator>
00901   {
00902     enum { dim      = GridImp::dimension };
00903     enum { dimworld = GridImp::dimensionworld };
00904 
00905     friend class AlbertaGridEntity<0,dim,GridImp>;
00906     typedef AlbertaGridIntersectionIterator<GridImp> ThisType; 
00907   public:
00908     typedef AGMemoryProvider< ThisType > StorageType; 
00909     typedef typename GridImp::template Codim<0>::Entity Entity;
00910     typedef typename GridImp::template Codim<1>::Geometry Geometry;
00911     typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
00912     
00913     typedef typename SelectEntityImp<0,dim,GridImp>::EntityImp EntityImp;
00914     
00915     //typedef AlbertaGridMakeableGeometry<dim-1,dimworld,GridImp> LocalGeometryImp;
00916     typedef AlbertaGridGeometry<dim-1,dimworld,GridImp> LocalGeometryImp;
00917     typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
00918 
00920     enum { dimension=dim };
00922     enum { dimensionworld=dimworld };
00924     typedef typename GridImp::ctype ctype;
00925 
00927     bool equals (const AlbertaGridIntersectionIterator<GridImp> & i) const;
00928 
00930     void increment();
00931 
00933     bool operator==(const AlbertaGridIntersectionIterator<GridImp>& i) const;
00934 
00936     EntityPointer outside() const;
00937 
00939     EntityPointer inside() const;
00940 
00942     AlbertaGridIntersectionIterator(const GridImp & grid,
00943                                     int level);
00944 
00946     AlbertaGridIntersectionIterator(const GridImp & grid,
00947                                     int level,
00948                                     ALBERTA EL_INFO *elInfo,
00949                                     bool leafIt );
00951     AlbertaGridIntersectionIterator(const AlbertaGridIntersectionIterator<GridImp> & org);
00952 
00954     void assign (const AlbertaGridIntersectionIterator<GridImp> & org);
00955   
00957     //~AlbertaGridIntersectionIterator();
00958 
00960     bool boundary () const;
00961 
00963     bool neighbor () const; 
00964 
00966     int boundaryId () const; 
00967       
00972     const LocalGeometry& intersectionSelfLocal () const;
00976     const LocalGeometry& intersectionNeighborLocal () const;
00980     const Geometry& intersectionGlobal () const;
00981 
00983     int numberInSelf () const;
00985     int numberInNeighbor () const;
00986 
00988     int twistInSelf() const;
00989     
00991     int twistInNeighbor() const;
00992 
00995     typedef FieldVector<albertCtype, GridImp::dimensionworld> NormalVecType;
00996     typedef FieldVector<albertCtype, GridImp::dimension-1> LocalCoordType;
00997   
00998     const NormalVecType & unitOuterNormal (const LocalCoordType & local) const;
00999   
01002     const NormalVecType & outerNormal (const LocalCoordType & local) const;
01003 
01006     const NormalVecType & integrationOuterNormal (const LocalCoordType & local) const;
01007 
01009     int level () const; 
01010     
01011     //**********************************************************
01012     //  private methods 
01013     //**********************************************************
01014     
01015     // reset IntersectionIterator  
01016     template <class EntityType> 
01017     void first(const EntityType & en, int level ); 
01018 
01019     // calls EntityPointer done and sets done_ to true
01020     void done (); 
01021 
01022   private:
01023     // returns true if actual neighbor has same level 
01024     bool neighborHasSameLevel () const;
01025     
01027     void makeBegin (const GridImp & grid,
01028                     int level, 
01029                     ALBERTA EL_INFO * elInfo ) const;
01030   
01032     void makeEnd (const GridImp & grid,int level ) const;
01033 
01034     // put objects on stack 
01035     void freeObjects () const;
01036   
01038     void setupVirtEn () const;
01039 
01041     void calcOuterNormal () const;
01042 
01043     // return whether the iterator was called from a LeafIterator entity or
01044     // LevelIterator entity
01045     bool leafIt () const { return leafIt_; }
01047     // private member variables 
01049 
01051     const GridImp& grid_;
01052 
01054     mutable int level_;
01055   
01057     mutable int neighborCount_;
01058 
01062     mutable bool builtNeigh_;
01063 
01064     bool leafIt_;
01065 
01067     mutable ALBERTA EL_INFO * elInfo_;
01068 
01069     typedef MakeableInterfaceObject<LocalGeometry> LocalGeometryObject;
01070    
01071     // the objects holding the real implementations 
01072     mutable LocalGeometryObject fakeNeighObj_;
01073     mutable LocalGeometryObject fakeSelfObj_;
01074     mutable LocalGeometryObject neighGlobObj_;
01075     
01078     mutable LocalGeometryImp & fakeNeigh_;
01081     mutable LocalGeometryImp & fakeSelf_;
01084     mutable LocalGeometryImp & neighGlob_;
01085 
01087     mutable ALBERTA EL_INFO neighElInfo_;
01088 
01089     mutable NormalVecType outNormal_;
01090     mutable NormalVecType unitNormal_;
01091   
01092     // tmp memory for normal calculation 
01093     mutable FieldVector<albertCtype, dimworld> tmpU_;
01094     mutable FieldVector<albertCtype, dimworld> tmpV_;
01095 
01096     // twist seen from the neighbor
01097     mutable int twist_;
01098 
01100     bool done_;
01101   };
01102 
01103 
01104 
01105   
01106 
01107   //**********************************************************************
01108   //
01109   // --AlbertaGridTreeIterator
01110   // --LevelIterator
01111   // --TreeIterator
01112   //
01113   
01114   namespace AlbertaTreeIteratorHelp {
01115     template <class IteratorImp, int dim, int codim>
01116     struct GoNextEntity;
01117   }
01118     
01122   template<int cd, PartitionIteratorType pitype, class GridImp>
01123   class AlbertaGridTreeIterator : 
01124     public AlbertaGridEntityPointer<cd,GridImp> 
01125   {
01126     enum { dim = GridImp::dimension };
01127     friend class AlbertaGridEntity<2,dim,GridImp>;
01128     friend class AlbertaGridEntity<1,dim,GridImp>;
01129     friend class AlbertaGridEntity<0,dim,GridImp>;
01130     friend class AlbertaGrid < dim , GridImp::dimensionworld >;
01131 
01132 
01133     typedef AlbertaGridTreeIterator<cd,pitype,GridImp>  AlbertaGridTreeIteratorType;
01134     typedef AlbertaGridTreeIteratorType ThisType;
01135     friend class AlbertaTreeIteratorHelp::GoNextEntity<ThisType,dim,cd>;
01136   public:
01137   
01138     typedef typename GridImp::template Codim<cd>::Entity Entity;
01139     typedef typename SelectEntityImp<cd,dim,GridImp>::EntityImp EntityImp;
01140     //typedef AlbertaGridMakeableEntity<cd,dim,GridImp> EntityImp;
01141   
01143     AlbertaGridTreeIterator(const AlbertaGridTreeIterator<cd,pitype,GridImp> & org ); 
01144   
01146     AlbertaGridTreeIterator<cd,pitype,GridImp> & operator = (const AlbertaGridTreeIterator<cd,pitype,GridImp> & org ); 
01147   
01149     AlbertaGridTreeIterator(const GridImp & grid, int
01150                             travLevel, int proc, bool leafIt=false );
01151  
01153     AlbertaGridTreeIterator(const GridImp & grid, 
01154                             const AlbertaMarkerVector * vec,
01155                             int travLevel, 
01156                             int proc,
01157                             bool leafIt=false);
01158   
01160     void increment();
01162 
01163   private:
01164     // private Methods
01165     void makeIterator();
01166 
01167     ALBERTA EL_INFO * goFirstElement(ALBERTA TRAVERSE_STACK *stack,
01168                                      ALBERTA MESH *mesh,
01169                                      int level, ALBERTA FLAGS fill_flag);
01170     ALBERTA EL_INFO * traverseElLevel(ALBERTA TRAVERSE_STACK * stack);
01171     ALBERTA EL_INFO * traverseElLevelInteriorBorder(ALBERTA TRAVERSE_STACK * stack);
01172     ALBERTA EL_INFO * traverseElLevelGhosts(ALBERTA TRAVERSE_STACK * stack);
01173  
01174     // the default is, go to next elInfo
01175     //template <int cc>  
01176     ALBERTA EL_INFO * goNextEntity(ALBERTA TRAVERSE_STACK *stack,ALBERTA EL_INFO *elinfo_old);
01177   
01178     // the real go next methods
01179     ALBERTA EL_INFO * goNextElInfo(ALBERTA TRAVERSE_STACK *stack,ALBERTA EL_INFO *elinfo_old);
01180     ALBERTA EL_INFO * goNextFace(ALBERTA TRAVERSE_STACK *stack,
01181                                  ALBERTA EL_INFO *elInfo);
01182     ALBERTA EL_INFO * goNextEdge(ALBERTA TRAVERSE_STACK *stack,
01183                                  ALBERTA EL_INFO *elInfo);
01184     ALBERTA EL_INFO * goNextVertex(ALBERTA TRAVERSE_STACK *stack,
01185                                    ALBERTA EL_INFO *elInfo);
01186 
01187     // search next macro el  
01188     ALBERTA MACRO_EL * nextGhostMacro(ALBERTA MACRO_EL *mel);
01189 
01191     int level_;
01192   
01194     int enLevel_;
01195 
01197     EntityImp & virtualEntity_; 
01198     
01199     // contains ALBERTA traversal stack 
01200     ALBERTA ManageTravStack manageStack_;
01201 
01203     int face_;
01204     int edge_;
01205     int vertex_;
01206 
01207     // knows on which element a point,edge,face is viewed
01208     const AlbertaMarkerVector * vertexMarker_;
01209 
01210     // variable for operator++
01211     bool okReturn_;
01212 
01213     // store processor number of elements
01214     // for ghost walktrough, i.e. walk over ghosts which belong
01215     // tp processor 2 
01216     const int proc_;
01217   };
01218 
01221   template<int cd, PartitionIteratorType pitype, class GridImp>
01222   class AlbertaGridLevelIterator : 
01223     public AlbertaGridTreeIterator<cd,pitype,GridImp> , 
01224     public LevelIteratorDefaultImplementation <cd,pitype,GridImp,AlbertaGridLevelIterator>
01225   {
01226   public:  
01227     typedef typename GridImp::template Codim<cd>::Entity Entity;
01228 
01230     AlbertaGridLevelIterator(const GridImp & grid, int level, int proc) :
01231       AlbertaGridTreeIterator<cd,pitype,GridImp> (grid,level,proc) 
01232     {
01233     }
01234 
01236     AlbertaGridLevelIterator(const GridImp & grid, 
01237                              const AlbertaMarkerVector * vec, int level, int proc) : 
01238       AlbertaGridTreeIterator<cd,pitype,GridImp> (grid,vec,level,proc) 
01239     {
01240     }
01241 
01243     void increment () 
01244     {
01245       AlbertaGridTreeIterator<cd,pitype,GridImp>::increment();
01246     }
01247   };
01248 
01249   //**********************************************************************
01250   //
01251   //  AlbertaGridLeafIterator 
01252   //  --LeafIterator 
01253   //
01254   //**********************************************************************
01256   template<int codim, PartitionIteratorType pitype, class GridImp>
01257   class AlbertaGridLeafIterator : 
01258     public AlbertaGridTreeIterator<codim, pitype, GridImp>, 
01259     public LeafIteratorDefaultImplementation<codim, pitype, GridImp, AlbertaGridLeafIterator>
01260   {
01261   public:  
01262     typedef typename GridImp::template Codim<codim>::Entity Entity;
01263 
01265     AlbertaGridLeafIterator(const GridImp & grid, int level, int proc) :
01266       AlbertaGridTreeIterator<codim,pitype,GridImp> (grid,level,proc,true) 
01267     {
01268     }
01269 
01271     AlbertaGridLeafIterator(const GridImp & grid, 
01272                             const AlbertaMarkerVector * vec, int level, int proc) : 
01273       AlbertaGridTreeIterator<codim, pitype, GridImp> (grid,vec,level,proc,true) 
01274     {
01275     }
01276 
01278     void increment () 
01279     {
01280       AlbertaGridTreeIterator<codim, pitype, GridImp>::increment();
01281     }
01282   };
01283 
01284   //**********************************************************************
01285   //
01286   // --AlbertaGrid
01287   // --Grid
01288   //
01289   //**********************************************************************
01290   
01291   template <int dim, int dimworld> 
01292   struct AlbertaGridFamily 
01293   {
01294     typedef AlbertaGrid<dim,dimworld> GridImp;
01295 
01296     typedef DefaultLevelIndexSet< AlbertaGrid<dim,dimworld> > LevelIndexSetImp;
01297     typedef DefaultLeafIndexSet< AlbertaGrid<dim,dimworld> > LeafIndexSetImp;
01298 
01299     typedef AlbertaGridIdSet<dim,dimworld> IdSetImp; 
01300     typedef int IdType;
01301 
01302     struct Traits
01303     {
01304       typedef GridImp Grid;
01305 
01306       typedef Dune::IntersectionIterator<const GridImp, LeafIntersectionIteratorWrapper > LeafIntersectionIterator;
01307       typedef Dune::IntersectionIterator<const GridImp, LeafIntersectionIteratorWrapper > LevelIntersectionIterator;
01308 
01309       typedef Dune::HierarchicIterator<const GridImp, AlbertaGridHierarchicIterator> HierarchicIterator;
01310 
01311       typedef IdType GlobalIdType;
01312       typedef IdType LocalIdType;
01313 
01314       template <int cd>
01315       struct Codim
01316       {
01317         // IMPORTANT: Codim<codim>::Geometry == Geometry<dim-codim,dimw>
01318         typedef Dune::Geometry<dim-cd, dimworld, const GridImp, AlbertaGridGeometry> Geometry;
01319         typedef Dune::Geometry<dim-cd, dim, const GridImp, AlbertaGridGeometry> LocalGeometry;
01320         // we could - if needed - introduce an other struct for dimglobal of Geometry
01321 
01322         typedef typename SelectEntityImp<cd,dim,GridImp>::Entity Entity; 
01323 
01324         typedef Dune::LevelIterator<cd,All_Partition,const GridImp,AlbertaGridLevelIterator> LevelIterator;
01325 
01326         typedef Dune::LeafIterator<cd,All_Partition,const GridImp,AlbertaGridLeafIterator> LeafIterator;
01327 
01328         typedef Dune::EntityPointer<const GridImp,AlbertaGridEntityPointer<cd,const GridImp> > EntityPointer;
01329 
01330         template <PartitionIteratorType pitype>
01331         struct Partition
01332         {
01333           typedef Dune::LevelIterator<cd,pitype,const GridImp,AlbertaGridLevelIterator> LevelIterator;
01334           typedef Dune::LeafIterator<cd,pitype,const GridImp,AlbertaGridLeafIterator> LeafIterator;
01335         };
01336 
01337       };
01338 
01339       typedef IndexSet<GridImp,LevelIndexSetImp,DefaultLevelIteratorTypes<GridImp> > LevelIndexSet;
01340       typedef IndexSet<GridImp,LeafIndexSetImp,DefaultLeafIteratorTypes<GridImp> > LeafIndexSet;
01341       typedef IdSet<GridImp,IdSetImp,IdType> GlobalIdSet;
01342       typedef IdSet<GridImp,IdSetImp,IdType> LocalIdSet;
01343 
01344 //#if HAVE_MPI 
01345       // use collective communciation with MPI
01346 //      typedef CollectiveCommunication<MPI_Comm> CollectiveCommunication;
01347 //#else 
01348       // use dummy collective communication 
01349       typedef CollectiveCommunication<GridImp> CollectiveCommunication;
01350 //#endif
01351     };
01352   };
01353 
01397   template <int dim, int dimworld>
01398   class AlbertaGrid : 
01399     public GridDefaultImplementation <dim,dimworld,albertCtype, AlbertaGridFamily<dim,dimworld> >,
01400     public HasObjectStream , 
01401     public HasHierarchicIndexSet 
01402   {
01403     friend class AlbertaGridEntity <0,dim,const AlbertaGrid<dim,dimworld> >;
01404     friend class AlbertaGridEntity <1,dim,const AlbertaGrid<dim,dimworld> >;
01405     friend class AlbertaGridEntity <2,dim,const AlbertaGrid<dim,dimworld> >;
01406     friend class AlbertaGridEntity <dim,dim,const AlbertaGrid<dim,dimworld> >;
01407 
01408     friend class AlbertaGridEntityPointer <0,const AlbertaGrid<dim,dimworld> >;
01409     friend class AlbertaGridEntityPointer <1,const AlbertaGrid<dim,dimworld> >;
01410     friend class AlbertaGridEntityPointer <2,const AlbertaGrid<dim,dimworld> >;
01411     friend class AlbertaGridEntityPointer <3,const AlbertaGrid<dim,dimworld> >;
01412 
01413     // friends because of fillElInfo
01414     friend class AlbertaGridTreeIterator<0,All_Partition,AlbertaGrid<dim,dimworld> >;
01415     friend class AlbertaGridTreeIterator<1,All_Partition,AlbertaGrid<dim,dimworld> >;
01416     friend class AlbertaGridTreeIterator<2,All_Partition,AlbertaGrid<dim,dimworld> >;
01417     friend class AlbertaGridTreeIterator<3,All_Partition,AlbertaGrid<dim,dimworld> >;
01418 
01419     friend class AlbertaGridHierarchicIterator<AlbertaGrid<dim,dimworld> >;
01420   
01421     friend class AlbertaGridIntersectionIterator<AlbertaGrid<dim,dimworld> >;
01422     friend class AlbertaGridIntersectionIterator<const AlbertaGrid<dim,dimworld> >;
01423 
01426     //CompileTimeChecker<dimworld != 1>   Do_not_use_AlbertaGrid_for_1d_Grids;   
01427  
01428     typedef AlbertaGrid<dim,dimworld> MyType; 
01429 
01430     friend class AlbertaMarkerVector;
01431     friend class AlbertaGridHierarchicIndexSet<dim,dimworld>;
01432 
01433     // minimum number of elements assumed to be created during adaption 
01434     enum { defaultElementChunk_ = 100 };
01435 
01436     //**********************************************************
01437     // The Interface Methods
01438     //**********************************************************
01439   public: 
01441     typedef AlbertaGridFamily<dim,dimworld> GridFamily;  
01442     typedef GridDefaultImplementation <dim,dimworld,albertCtype,
01443             AlbertaGridFamily<dim,dimworld> > BaseType;
01444 
01446     typedef typename AlbertaGridFamily<dim,dimworld> :: Traits Traits;  
01447 
01449     typedef AlbertaGridHierarchicIndexSet<dim,dimworld> HierarchicIndexSet;
01450 
01451   private:  
01453     typedef typename Traits:: CollectiveCommunication  CollectiveCommunicationType;
01454 
01456     typedef typename Traits::template Codim<0>::LeafIterator LeafIterator;
01457 
01459     typedef typename GridFamily:: LevelIndexSetImp LevelIndexSetImp;
01460     typedef typename GridFamily:: LeafIndexSetImp LeafIndexSetImp;
01461     
01463     typedef typename Traits :: LeafIndexSet LeafIndexSet;
01464 
01466     typedef AlbertaGridIdSet<dim,dimworld> IdSetImp; 
01467     typedef typename Traits :: GlobalIdSet GlobalIdSet; 
01468     typedef typename Traits :: LocalIdSet  LocalIdSet; 
01469 
01470   public:  
01472     typedef typename ALBERTA AlbertHelp::AlbertLeafData<dimworld,dim+1> LeafDataType;
01473 
01474     typedef ObjectStream ObjectStreamType;
01475 
01476     enum { 
01478       numCodim = dim+1 };
01479 
01480     enum { 
01482       MAXL = 64 };
01483 
01484     /*
01485        levInd = true means that a consecutive level index is generated 
01486        if levInd == true the the element number of first macro element is
01487        set to 1 so hasLevelIndex_ can be identified we grid is read from
01488        file */
01490     AlbertaGrid(const std::string macroTriangFilename);
01491   
01492     /* (for internal use only) 
01493        Constructor which reads an ALBERTA macro triangulation file 
01494        or given GridFile , proc is the number of domain , 
01495        levInd = true means that a consecutive level index is generated 
01496        if levInd == true the the element number of first macro element is
01497        set to 1 so hasLevelIndex_ can be identified we grid is read from
01498        file */
01499     //AlbertaGrid(AlbertaGrid<dim,dimworld> & oldGrid, int proc);
01500   
01502     AlbertaGrid();
01503  
01505     ~AlbertaGrid();
01506    
01509     int maxLevel() const;
01510 
01512     template<int cd, PartitionIteratorType pitype>
01513     typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator 
01514     lbegin (int level) const;
01515 
01517     template<int cd, PartitionIteratorType pitype>
01518     typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator 
01519     lend (int level) const;
01520 
01522     template<int cd>  typename Traits::template Codim<cd>::
01523     template Partition<All_Partition>::LevelIterator 
01524     lbegin (int level) const;
01525 
01527     template<int cd>  typename Traits::template Codim<cd>::
01528     template Partition<All_Partition>::LevelIterator 
01529     lend (int level) const;
01530     
01532     template <int codim, PartitionIteratorType pitype>
01533     typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator 
01534     leafbegin () const;
01535 
01537     template <int codim>
01538     typename Traits::template Codim<codim>::LeafIterator 
01539     leafbegin () const;
01540   
01542     template <int codim, PartitionIteratorType pitype>
01543     typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator 
01544     leafend   () const;
01545 
01547     template <int codim>
01548     typename Traits::template Codim<codim>::LeafIterator 
01549     leafend   () const;
01550 
01551   private:  
01553     template <int codim, PartitionIteratorType pitype>
01554     typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator 
01555     leafbegin ( int maxlevel, int proc = -1 ) const;
01556 
01558     template <int codim>
01559     typename Traits::template Codim<codim>::LeafIterator 
01560     leafbegin ( int maxlevel, int proc = -1 ) const;
01561   
01563     template <int codim, PartitionIteratorType pitype>
01564     typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator 
01565     leafend   ( int maxlevel, int proc = -1 ) const;
01566 
01568     template <int codim>
01569     typename Traits::template Codim<codim>::LeafIterator 
01570     leafend   ( int maxlevel, int proc = -1 ) const;
01571 
01573     LeafIterator leafbegin ( int maxlevel, int proc = -1 ) const;
01574   
01576     LeafIterator leafend   ( int maxlevel, int proc = -1 ) const;
01577 
01579     LeafIterator leafbegin () const;
01580   
01582     LeafIterator leafend   () const;
01583     
01584   public:  
01589     int size (int level, int codim) const; 
01590 
01592     int size (int level, GeometryType type) const;
01593 
01595     int size (int codim) const; 
01596 
01598     int size (GeometryType type) const;
01599 
01600   public:
01601     //***************************************************************
01602     //  Interface for Adaptation
01603     //***************************************************************
01610     bool mark( int refCount , const typename Traits::template Codim<0>::EntityPointer & en ) const; 
01611 
01613     int getMark( const typename Traits::template Codim<0>::EntityPointer & ) const; 
01614 private:
01615     bool mark( int refCount , const typename Traits::template Codim<0>::Entity & en ) const; 
01616 
01617 public:
01619     bool globalRefine(int refCount);
01620   
01624     bool adapt ( );
01625 
01627     template <class DofManagerType, class RestrictProlongOperatorType>
01628     bool adapt (DofManagerType &, RestrictProlongOperatorType &, bool verbose=false );
01629   
01631     bool preAdapt ();
01632 
01634     bool postAdapt();
01635 
01638     const CollectiveCommunicationType & comm () const
01639     {
01640       return comm_;
01641     }
01642     
01644     std::string name () const { return "AlbertaGrid"; };
01645   
01646     //**********************************************************
01647     // End of Interface Methods
01648     //**********************************************************
01650     template <GrapeIOFileFormatType ftype>
01651     bool writeGrid( const std::basic_string<char> filename, albertCtype time ) const;
01652   
01654     template <GrapeIOFileFormatType ftype>
01655     bool readGrid( const std::basic_string<char> filename, albertCtype & time );
01656 
01657     /* returns size of mesh include all levels 
01658        max Index of grid entities with given codim 
01659        for outside the min index is 0, the shift has to done inside 
01660        the grid which is of minor cost 
01661     */
01662     int global_size (int codim) const;
01663 
01664     // return number of my processor 
01665     int myRank () const { return myRank_; }; 
01666 
01668     void setNewCoords(const FieldVector<albertCtype, dimworld> & trans, const albertCtype scalar);
01669 
01670     // return hierarchic index set 
01671     const HierarchicIndexSet & hierarchicIndexSet () const { return hIndexSet_; }
01672 
01674     const typename Traits :: LevelIndexSet & levelIndexSet (int level) const;
01675 
01677     const typename Traits :: LeafIndexSet & leafIndexSet () const;
01678   
01680     const GlobalIdSet & globalIdSet () const { return globalIdSet_; }
01681  
01683     const LocalIdSet & localIdSet () const { return globalIdSet_; }
01684 
01685     // access to mesh pointer, needed by some methods
01686     ALBERTA MESH* getMesh () const { return mesh_; }; 
01687 
01688     // return real entity implementation 
01689     template <int cd>
01690     AlbertaGridEntity<cd,dim,const AlbertaGrid<dim,dimworld> >& 
01691     getRealEntity(typename Traits::template Codim<cd>::Entity& entity) 
01692     {
01693       return this->getRealImplementation(entity);
01694     }
01695 
01696   private:
01698     template <int cd>
01699     const AlbertaGridEntity<cd,dim,const AlbertaGrid<dim,dimworld> >& 
01700     getRealEntity(const typename Traits::template Codim<cd>::Entity& entity) const 
01701     {
01702       return this->getRealImplementation(entity);
01703     }
01704 
01705   public:
01706     // create ghost cells 
01707     void createGhosts ();
01708   
01709     // return processor number where entity is master 
01710     template <class EntityType> 
01711     int owner (const EntityType & ) const; 
01712   
01713     // AlbertaGrid internal method for partitioning 
01714     // set processor number of this entity  
01715     template <class EntityType> 
01716     bool partition( int proc , EntityType & ); 
01717 
01718     // unpack recieved ObjectStream 
01719     void unpackAll ( ObjectStreamType & os );
01720   
01721     // pack this entity and all chilcren to ObjectStream 
01722     template <class EntityType> 
01723     void packAll ( ObjectStreamType & os, EntityType & en );
01724 
01725     // pack this entity and all chilcren to ObjectStream 
01726     template <class EntityType> 
01727     void packBorder ( ObjectStreamType & os, EntityType & en );
01728 
01729     // return true if macro element is ghost 
01730     bool isGhost( const ALBERTA MACRO_EL * mel) const;
01731   
01732     // return true if element is neihter interior nor ghost 
01733     bool isNoElement( const ALBERTA MACRO_EL * mel) const;
01734 
01736     const std::vector < GeometryType > & geomTypes (int codim) const 
01737     { 
01738       assert( codim >= 0 );
01739       assert( codim < dim+1 );
01740       return geomTypes_[codim]; 
01741     }
01742 
01743   private:
01744     friend class Conversion<AlbertaGrid<dim, dimworld>, HasObjectStream>;  
01745     friend class Conversion<const AlbertaGrid<dim, dimworld>, HasObjectStream>;
01746 
01747     friend class Conversion<AlbertaGrid<dim, dimworld>, HasHierarchicIndexSet >;  
01748     friend class Conversion<const AlbertaGrid<dim, dimworld>, HasHierarchicIndexSet>;
01749 
01750     // do not use copy constructor 
01751     AlbertaGrid(const MyType& other);
01752     // do not use assigment 
01753     MyType& operator=(const MyType& other);
01754 
01755   private:
01756     typedef std::vector<int> ArrayType;
01757     
01758     ArrayType ghostFlag_; // store ghost information 
01759   
01760     // initialize of some members 
01761     void initGrid(int proc);
01762   
01763     // make the calculation of indexOnLevel and so on.
01764     // extra method because of Reihenfolge
01765     void calcExtras(); 
01766  
01767     // write ALBERTA mesh file  
01768     bool writeGridXdr  ( const std::basic_string<char> filename, albertCtype time ) const;
01769 
01771     bool readGridXdr   ( const std::basic_string<char> filename, albertCtype & time );
01772 
01774     bool readGridAscii ( const std::basic_string<char> filename, albertCtype & time );
01775     
01776     // delete mesh and all vectors 
01777     void removeMesh();
01778 
01779     // pointer to an Albert Mesh, which contains the data
01780     ALBERTA MESH *mesh_;
01781 
01782     // object of collective communication 
01783     CollectiveCommunicationType comm_;
01784 
01785     // number of maxlevel of the mesh
01786     int maxlevel_;
01787 
01788     // true if grid was refined or coarsend
01789     bool wasChanged_; 
01790 
01791     // help vector for setNewCoords 
01792     mutable ArrayType macroVertices_;
01793 
01794   public:  
01795     // this method is new fill_elinfo from ALBERTA but here the neighbor
01796     // relations are calced diffrent, on ervery level there are neighbor
01797     // realtions ( in ALBERTA only on leaf level ), so we needed a new
01798     // fill_elinfo. 
01799     void fillElInfo(int ichild, int actLevel ,const ALBERTA EL_INFO *elinfo_old, 
01800                     ALBERTA EL_INFO *elinfo, bool hierachical, bool leaf=false ) const;
01801   
01802     // calc the neigh[0] 
01803     void firstNeigh(const int ichild,const ALBERTA EL_INFO *elinfo_old, 
01804                     ALBERTA EL_INFO *elinfo, const bool leafLevel) const;
01805   
01806     // calc the neigh[1] 
01807     void secondNeigh(const int ichild, const ALBERTA EL_INFO *elinfo_old, 
01808                      ALBERTA EL_INFO *elinfo, const bool leafLevel) const;
01809   
01810     // calc the neigh[2] 
01811     void thirdNeigh(const int ichild, const ALBERTA EL_INFO *elinfo_old, 
01812                     ALBERTA EL_INFO *elinfo, const bool leafLevel) const;
01813  
01814   private:  
01815     // needed for VertexIterator, mark on which element a vertex is treated 
01816     mutable AlbertaMarkerVector vertexMarkerLeaf_; 
01817 
01818     // needed for VertexIterator, mark on which element a vertex is treated 
01819     mutable AlbertaMarkerVector vertexMarkerLevel_[MAXL]; 
01820     
01821     //***********************************************************************
01822     //  MemoryManagement for Entitys and Geometrys 
01823     //**********************************************************************
01824     typedef typename SelectEntityImp<0,dim,const MyType>::EntityObject EntityObject;
01825   
01826   public:
01827     typedef AGMemoryProvider< EntityObject > EntityProvider;
01828 
01829     typedef AlbertaGridIntersectionIterator< const MyType > IntersectionIteratorImp;
01830     typedef IntersectionIteratorImp LeafIntersectionIteratorImp;
01831     typedef AGMemoryProvider< LeafIntersectionIteratorImp > LeafIntersectionIteratorProviderType;
01832     friend class LeafIntersectionIteratorWrapper< const MyType > ;
01833 
01834     typedef LeafIntersectionIteratorWrapper<const MyType >
01835       AlbertaGridIntersectionIteratorType; 
01836 
01837     LeafIntersectionIteratorProviderType & leafIntersetionIteratorProvider() const { return leafInterItProvider_; }
01838 
01839   private:  
01840     mutable EntityProvider               entityProvider_;
01841     mutable LeafIntersectionIteratorProviderType leafInterItProvider_;
01842    
01843   public:  
01844     template <class IntersectionInterfaceType>
01845     const typename BaseType::
01846     template ReturnImplementationType<IntersectionInterfaceType> :: ImplementationType &
01847     getRealIntersectionIterator(const IntersectionInterfaceType & it) const
01848     {
01849       return this->getRealImplementation(it);
01850     }
01851     
01852     // (for internal use only) return obj pointer to EntityImp 
01853     template <int codim> 
01854     typename SelectEntityImp<codim,dim,const MyType>::EntityObject * 
01855     getNewEntity (int level, bool leafIt ) const;
01856 
01857     // (for internal use only) free obj pointer of EntityImp 
01858     template <int codim>
01859     void freeEntity (typename SelectEntityImp<codim,dim,const MyType>::EntityObject * en) const;
01860 
01861   private:
01862     //*********************************************************************
01863     // organisation of the global index 
01864     //*********************************************************************
01865     // provides the indices for the elements 
01866     IndexManagerType indexStack_[AlbertHelp::numOfElNumVec];
01867   
01868     // the DOF_INT_VECs we need 
01869     // * change to mutable here
01870     mutable ALBERTA AlbertHelp::DOFVEC_STACK dofvecs_;
01871         
01872     const ALBERTA DOF_ADMIN * elAdmin_;
01873 
01874     const ALBERTA REAL_D * coordsVec_;
01875     
01876     // pointer to vec of elNumbers_
01877     const int * elNewVec_;
01878 
01879     // for access in the elNewVec and ownerVec 
01880     const int nv_;
01881     const int dof_; 
01882  
01883   public:  
01884     // make some shortcuts 
01885     void arrangeDofVec(); 
01886 
01887     // return true if el is new 
01888     bool checkElNew ( const ALBERTA EL * el ) const;
01889   
01890     // read global element number from elNumbers_  
01891     const ALBERTA REAL_D & getCoord ( const ALBERTA EL_INFO * elInfo, int vx ) const
01892     {
01893       assert( vx>= 0);
01894       assert( vx < dim+1 );
01895 #ifndef CALC_COORD 
01896       assert(coordsVec_);
01897       return coordsVec_[elInfo->el->dof[vx][0]];
01898 #else 
01899       return elInfo->coord[vx];
01900 #endif
01901     } 
01902 
01903     // read level from elNewCehck vector   
01904     int getLevelOfElement ( const ALBERTA EL * el ) const; 
01905 
01906     // read global element number from elNumbers_  
01907     int getElementNumber ( const ALBERTA EL * el ) const; 
01908 
01909     // read global element number from elNumbers_  
01910     int getEdgeNumber ( const ALBERTA EL * el, int edge ) const; 
01911 
01912     // read global element number from elNumbers_  
01913     int getFaceNumber ( const ALBERTA EL * el, int face ) const; 
01914 
01915     // read global element number from elNumbers_  
01916     int getVertexNumber ( const ALBERTA EL * el, int vx ) const; 
01917 
01918     //********************************************************************
01919     //  organisation of the parallelisation 
01920     //********************************************************************
01921   
01922     // set owner of element, for partioning  
01923     bool setOwner ( const ALBERTA EL * el , int proc );
01924   
01925     // return the processor number of element  
01926     int getOwner ( const ALBERTA EL * el ) const;
01927 
01928     // PartitionType (InteriorEntity , BorderEntity, GhostEntity )
01929     PartitionType partitionType ( ALBERTA EL_INFO * elinfo) const;
01930 
01931   private:
01932 
01933     // pointer to vec  with processor number for each element, 
01934     // access via setOwner and getOwner 
01935     int * ownerVec_;
01936 
01937     // rank of my thread, i.e. number of my processor 
01938     const int myRank_;
01939 
01940     // the hierarchical numbering of AlbertaGrid, unique per codim and processor 
01941     AlbertaGridHierarchicIndexSet<dim,dimworld> hIndexSet_;
01942 
01943     // the id set of this grid 
01944     IdSetImp globalIdSet_; 
01945 
01946     // the level index set, is generated from the HierarchicIndexSet
01947     // is generated, when accessed 
01948     mutable std::vector < LevelIndexSetImp * > levelIndexVec_;
01949   
01950     // the leaf index set, is generated from the HierarchicIndexSet
01951     // is generated, when accessed 
01952     mutable LeafIndexSetImp* leafIndexSet_;
01953 
01955     std::vector < std::vector< GeometryType > > geomTypes_;
01956 
01957     // creates geomType_ vector 
01958     void makeGeomTypes();
01959 
01960     // stack for storing BOUNDARY objects created during mesh creation 
01961     std::stack < BOUNDARY * > bndStack_; 
01962 
01963     typedef SingleTypeSizeCache<MyType> SizeCacheType;
01964     SizeCacheType * sizeCache_;
01965 
01966     // count how much elements where marked 
01967     mutable int coarsenMarked_;
01968     mutable int refineMarked_;
01969 
01970     mutable bool lockPostAdapt_;
01971   }; // end class AlbertaGrid
01972 
01973 
01974   namespace Capabilities
01975   {
01976   
01988   template<int dim, int dimw, int cdim>
01989   struct hasEntity<AlbertaGrid<dim,dimw>, cdim >
01990   {
01991     static const bool v = true;
01992   };
01993 
01997   template<int dim, int dimw>
01998   struct isLevelwiseConforming< AlbertaGrid<dim,dimw> >
01999   {
02000     static const bool v = false;
02001   };
02002   
02006   template<int dim, int dimw>
02007   struct isLeafwiseConforming< AlbertaGrid<dim,dimw> >
02008   {
02009     static const bool v = true;
02010   };
02011 
02015   template<int dim, int dimw>
02016   struct hasHangingNodes< AlbertaGrid<dim,dimw> >
02017   {
02018     static const bool v = false;
02019   };
02020   
02024   template<int dim, int dimw>
02025   struct hasBackupRestoreFacilities< AlbertaGrid<dim,dimw> >
02026   {
02027     static const bool v = true;
02028   };
02029 
02030   } // end namespace Capabilities
02031 
02032 } // namespace Dune
02033 
02034 #include "agmemory.hh"
02035 #include "albertagrid.cc"
02036 
02037 // undef all dangerous defines
02038 #undef DIM
02039 #undef DIM_OF_WORLD
02040 #undef CALC_COORD 
02041 #include "alberta_undefs.hh"
02042 #endif

Generated on 12 Dec 2007 with Doxygen (ver 1.5.1)