From 24eaa75125cd2581dd35af1ba5ee3a990701c5c8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Robert=20Kl=C3=B6fkorn?= <robertk@dune-project.org>
Date: Wed, 26 Oct 2005 15:58:57 +0000
Subject: [PATCH] size methods use size cache and not index sets anymore.

removed deprecated index,globalIndex and subIndex methods.

[[Imported from SVN: r3312]]
---
 grid/alu3dgrid/entity.hh     | 26 +++++--------------------
 grid/alu3dgrid/entity_imp.cc | 37 ------------------------------------
 grid/alu3dgrid/grid.hh       |  5 +++++
 grid/alu3dgrid/grid_imp.cc   | 22 +++++++++++++++++----
 4 files changed, 28 insertions(+), 62 deletions(-)

diff --git a/grid/alu3dgrid/entity.hh b/grid/alu3dgrid/entity.hh
index 69a23af7a..40a411f54 100644
--- a/grid/alu3dgrid/entity.hh
+++ b/grid/alu3dgrid/entity.hh
@@ -124,13 +124,6 @@ namespace Dune {
     //! level of this element
     int level () const;
 
-    //! index is unique and consecutive per level and codim
-    //! used for access to degrees of freedom
-    int index () const DUNE_DEPRECATED;
-
-    //! index is unique within the grid hierachie and per codim
-    int globalIndex () const DUNE_DEPRECATED;
-
     //! return partition type of this entity ( see grid.hh )
     PartitionType partitionType() const;
 
@@ -261,12 +254,6 @@ namespace Dune {
     //! level of this element
     int level () const ;
 
-    //! index is unique and consecutive per level and codim used for access to degrees of freedo
-    int index () const DUNE_DEPRECATED;
-
-    //! index is unique within the grid hierachie and per codim
-    int globalIndex () const DUNE_DEPRECATED;
-
     //! geometry of this entity
     const Geometry & geometry () const;
 
@@ -278,14 +265,6 @@ namespace Dune {
      */
     template<int cc> int count () const ;
 
-    //! return index of sub entity with codim = cc and local number i
-    //! i.e. return global number of vertex i
-    template<int cc> int subIndex (int i) const DUNE_DEPRECATED;
-
-    //! return index of sub entity with codim = cc and local number i
-    //! i.e. return global number of vertex i
-    template<int cc> int getSubIndex (int i) const;
-
     //! Provide access to mesh entity i of given codimension. Entities
     //!  are numbered 0 ... count<cc>()-1
     template <int cc>
@@ -360,6 +339,11 @@ namespace Dune {
 
     void setEntity ( const ALU3dGridEntity<0,dim,GridImp> & org );
 
+    //! return index of sub entity with codim = cc and local number i
+    //! i.e. return global number of vertex i
+    //! for use in hierarchical index set
+    template<int cc> int getSubIndex (int i) const;
+
   private:
     typedef typename ALU3dImplTraits<GridImp::elementType>::IMPLElementType IMPLElementType;
 
diff --git a/grid/alu3dgrid/entity_imp.cc b/grid/alu3dgrid/entity_imp.cc
index 36195ccaa..a0119aadf 100644
--- a/grid/alu3dgrid/entity_imp.cc
+++ b/grid/alu3dgrid/entity_imp.cc
@@ -98,19 +98,6 @@ namespace Dune {
     localFCoordCalced_ = false;
   }
 
-  template<int cd, int dim, class GridImp>
-  inline int ALU3dGridEntity<cd,dim,GridImp> :: index () const
-  {
-    const Entity en (*this);
-    return grid_.levelIndexSet(en.level()).index(en);
-  }
-
-  template<int cd, int dim, class GridImp>
-  inline int ALU3dGridEntity<cd,dim,GridImp> :: globalIndex () const
-  {
-    return gIndex_;
-  }
-
   template<int cd, int dim, class GridImp>
   inline int ALU3dGridEntity<cd,dim,GridImp> :: getIndex () const
   {
@@ -338,19 +325,6 @@ namespace Dune {
     return geoInFather_;
   }
 
-  template<int dim, class GridImp>
-  inline int ALU3dGridEntity<0,dim,GridImp> :: index() const
-  {
-    const Entity en (*this);
-    return grid_.levelIndexSet(en.level()).index(en);
-  }
-
-  template<int dim, class GridImp>
-  inline int ALU3dGridEntity<0,dim,GridImp> :: globalIndex() const
-  {
-    return glIndex_;
-  }
-
   template<int dim, class GridImp>
   inline int ALU3dGridEntity<0,dim,GridImp> :: getIndex() const
   {
@@ -410,17 +384,6 @@ namespace Dune {
     }
   };
 
-  // this method os deprecated
-  template<int dim, class GridImp>
-  template<int cc>
-  inline int ALU3dGridEntity<0,dim,GridImp> :: subIndex (int i) const
-  {
-    dwarn << "This method is deprecated: " << __FILE__ << " line: " <<  __LINE__ << "\n";
-    assert(item_ != 0);
-    typedef typename  ALU3dImplTraits<GridImp::elementType>::IMPLElementType IMPLElType;
-    return IndexWrapper<IMPLElType,GridImp::elementType,cc>::subIndex ( *item_ ,i);
-  }
-
   template<int dim, class GridImp>
   template<int cc>
   inline int ALU3dGridEntity<0,dim,GridImp> :: getSubIndex (int i) const
diff --git a/grid/alu3dgrid/grid.hh b/grid/alu3dgrid/grid.hh
index 31805faf4..4bb27a6ca 100644
--- a/grid/alu3dgrid/grid.hh
+++ b/grid/alu3dgrid/grid.hh
@@ -15,6 +15,7 @@
 #include "../common/referenceelements.hh"
 #include "../common/defaultindexsets.hh"
 #include "../common/leafindexset.hh"
+#include "../common/sizecache.hh"
 
 //- Local includes
 #include "alu3dinclude.hh"
@@ -540,6 +541,10 @@ namespace Dune {
 
     typedef ALU3dGridVertexList VertexListType;
     mutable VertexListType vertexList_[MAXL];
+
+    // the type of our size cache
+    typedef SingleTypeSizeCache<MyType, (elType == tetra) ? simplex : cube> SizeCacheType;
+    SizeCacheType * sizeCache_;
   }; // end class ALU3dGrid
 
   template <class GridImp, int codim>
diff --git a/grid/alu3dgrid/grid_imp.cc b/grid/alu3dgrid/grid_imp.cc
index 239da85ad..e7e6dd1e2 100644
--- a/grid/alu3dgrid/grid_imp.cc
+++ b/grid/alu3dgrid/grid_imp.cc
@@ -69,6 +69,7 @@ namespace Dune {
       , hIndexSet_ (*this)
       , globalIdSet_(*this), localIdSet_(*this)
       , levelIndexVec_(MAXL,0) , leafIndexSet_(0)
+      , sizeCache_ (0)
   {
     mygrid_ = new ALU3DSPACE GitterImplType (macroTriangFilename.c_str()
 #ifdef _ALU3DGRID_PARALLEL_
@@ -106,6 +107,7 @@ namespace Dune {
       , hIndexSet_ (*this)
       , globalIdSet_(*this), localIdSet_(*this)
       , levelIndexVec_(MAXL,0) , leafIndexSet_(0)
+      , sizeCache_ (0)
   {}
 #else
   template <int dim, int dimworld, ALU3dGridElementType elType>
@@ -131,6 +133,7 @@ namespace Dune {
       , globalIdSet_ (*this)
       , localIdSet_ (*this)
       , levelIndexVec_(MAXL,0) , leafIndexSet_(0)
+      , sizeCache_ (0)
   {
     DUNE_THROW(GridError,"Do not use copy constructor of ALU3dGrid! \n");
   }
@@ -150,6 +153,7 @@ namespace Dune {
       if(levelIndexVec_[i]) delete levelIndexVec_[i];
     }
     if(leafIndexSet_) delete leafIndexSet_;
+    if(sizeCache_) delete sizeCache_;sizeCache_ = 0;
     if(mygrid_) delete mygrid_;
   }
 
@@ -158,7 +162,13 @@ namespace Dune {
   {
     // if we dont have this level return 0
     if( (level > maxlevel_) || (level < 0) ) return 0;
-    return levelIndexSet(level).size(codim,this->geomTypes(codim)[0]);
+
+    assert( codim >= 0);
+    assert( codim < dim+1 );
+
+    assert( levelIndexSet(level).size(codim,this->geomTypes(codim)[0]) ==
+            sizeCache_->size(level,codim) );
+    return sizeCache_->size(level,codim);
   }
 
   template <int dim, int dimworld, ALU3dGridElementType elType>
@@ -172,7 +182,10 @@ namespace Dune {
   template <int dim, int dimworld, ALU3dGridElementType elType>
   inline int ALU3dGrid<dim, dimworld, elType>::size(int codim) const
   {
-    return leafIndexSet().size(codim);
+    assert( codim >= 0 );
+    assert( codim < dim +1 );
+    assert( leafIndexSet().size(codim) == sizeCache_->size(codim) );
+    return sizeCache_->size(codim);
   }
 
   template <int dim, int dimworld, ALU3dGridElementType elType>
@@ -189,8 +202,6 @@ namespace Dune {
   {
     calcMaxlevel();
     calcExtras();
-
-    //myGrid().printsize();
   }
 
   template <int dim, int dimworld, ALU3dGridElementType elType>
@@ -214,6 +225,9 @@ namespace Dune {
 
     for(unsigned int i=0; i<MAXL; i++) vertexList_[i].unsetUp2Date();
 
+    if(sizeCache_) delete sizeCache_;
+    sizeCache_ = new SizeCacheType (*this,true);
+
     coarsenMarked_ = 0;
     refineMarked_  = 0;
   }
-- 
GitLab