diff --git a/grid/albertagrid/albertagrid.cc b/grid/albertagrid/albertagrid.cc index bebc35c475a1f323bbd7b23c932e21537e035b92..8f8b87a44f8fd4dbc37f10e796fb10d648dba937 100644 --- a/grid/albertagrid/albertagrid.cc +++ b/grid/albertagrid/albertagrid.cc @@ -2824,13 +2824,15 @@ namespace Dune inline bool AlbertaMarkerVector:: notOnThisElement(ALBERTA EL * el, int elIndex, int level, int vertex) { - return (vec_[level][ vertex ] != elIndex); + if(meLevel_) return (vec_[level][ vertex ] != elIndex); + return (vec_[0][ vertex ] != elIndex); } inline bool AlbertaMarkerVector:: edgeNotOnElement(ALBERTA EL * el, int elIndex, int level, int edgenum) { - return (edgevec_[level][ edgenum ] != elIndex); + if(meLevel_) return (edgevec_[level][ edgenum ] != elIndex); + return (edgevec_[0][ edgenum ] != elIndex); } template <class GridType, int dim> @@ -2858,6 +2860,7 @@ namespace Dune template <class GridType> inline void AlbertaMarkerVector::markNewVertices(GridType &grid) { + assert( meLevel_ == true ); enum { dim = GridType::dimension }; enum { dimworld = GridType::dimensionworld }; @@ -2894,6 +2897,56 @@ namespace Dune if( vec[num] == -1 ) vec[num] = elindex; } +#if DIM == 3 + // mark edges for this element + MarkEdges<GridType,dim>::mark(grid,edgevec, + el,(grid.template getRealEntity<0> (*it)).template count<2> (), elindex ); +#endif + } + // remember the number of entity on level and codim = 0 + } + up2Date_ = true; + } + template <class GridType> + inline void AlbertaMarkerVector::markNewLeafVertices(GridType &grid) + { + assert( meLevel_ == false ); + enum { dim = GridType::dimension }; + enum { dimworld = GridType::dimensionworld }; + + int nvx = grid.hierarchicIndexSet().size(dim); +#if DIM == 3 + int edg = grid.hierarchicIndexSet().size(dim-1); +#endif + + int level=0; + { + Array<int> & vec = vec_[level]; + if(vec.size() < nvx) vec.resize( nvx + vxBufferSize_ ); + +#if DIM == 3 + Array<int> & edgevec = edgevec_[level]; + if(edgevec.size() < edg) edgevec.resize( edg + vxBufferSize_ ); + for(int i=0; i<edgevec.size(); i++) edgevec[i] = -1; +#endif + + for(int i=0; i<vec.size(); i++) vec[i] = -1; + + //typedef AlbertaGridMakeableEntity<0,dim,const GridType> MakeableEntityImp; + typedef typename GridType::template Codim<0>::LeafIterator IteratorType; + IteratorType endit = grid.template leafend<0> (); + for(IteratorType it = grid.template leafbegin<0> (); it != endit; ++it) + { + const ALBERTA EL * el = + (grid.template getRealEntity<0> (*it)).getElInfo()->el; + + int elindex = grid.hierarchicIndexSet().index(*it); + for(int local=0; local<dim+1; local++) + { + int num = el->dof[local][0]; // vertex num + if( vec[num] == -1 ) vec[num] = elindex; + } + #if DIM == 3 // mark edges for this element MarkEdges<GridType,dim>::mark(grid,edgevec, @@ -2936,7 +2989,9 @@ namespace Dune , leafIndexSet_ (0) , geomTypes_(1,simplex) { - vertexMarker_ = new AlbertaMarkerVector (); + // true created Level Marker + vertexMarkerLevel_ = new AlbertaMarkerVector (true); + vertexMarkerLeaf_ = new AlbertaMarkerVector (false); for(int i=0; i<AlbertHelp::numOfElNumVec; i++) dofvecs_.elNumbers[i] = 0; dofvecs_.elNewCheck = 0; @@ -2991,7 +3046,8 @@ namespace Dune file.close(); } - vertexMarker_ = new AlbertaMarkerVector (); + vertexMarkerLevel_ = new AlbertaMarkerVector (true); + vertexMarkerLeaf_ = new AlbertaMarkerVector (false); ALBERTA AlbertHelp::initIndexManager_elmem_cc(indexStack_); if(makeNew) @@ -3027,7 +3083,8 @@ namespace Dune ALBERTA MESH * oldMesh = oldGrid.getMesh(); - vertexMarker_ = new AlbertaMarkerVector (); + vertexMarkerLevel_ = new AlbertaMarkerVector (true); + vertexMarkerLeaf_ = new AlbertaMarkerVector (false); ALBERTA AlbertHelp::initIndexManager_elmem_cc(indexStack_); DUNE_THROW(AlbertaError,"To be revised!"); @@ -3048,7 +3105,8 @@ namespace Dune if(leafIndexSet_) delete leafIndexSet_; - if(vertexMarker_) delete vertexMarker_; + if(vertexMarkerLevel_) delete vertexMarkerLevel_; + if(vertexMarkerLeaf_ ) delete vertexMarkerLeaf_; for(int i=0; i<AlbertHelp::numOfElNumVec; i++) if(dofvecs_.elNumbers[i]) ALBERTA free_dof_int_vec(dofvecs_.elNumbers[i]); @@ -3081,9 +3139,9 @@ namespace Dune { if((dim == codim) || ((dim == 3) && (codim == 2)) ) { - if( ! (*vertexMarker_).up2Date() ) vertexMarker_->markNewVertices(*this); + if( ! (*vertexMarkerLevel_).up2Date() ) vertexMarkerLevel_->markNewVertices(*this); } - return AlbertaGridLevelIterator<codim,pitype,const MyType> (*this,vertexMarker_,level,proc); + return AlbertaGridLevelIterator<codim,pitype,const MyType> (*this,vertexMarkerLevel_,level,proc); } template < int dim, int dimworld > template<int codim, PartitionIteratorType pitype> @@ -3099,9 +3157,9 @@ namespace Dune { if((dim == codim) || ((dim == 3) && (codim == 2)) ) { - if( ! (*vertexMarker_).up2Date() ) vertexMarker_->markNewVertices(*this); + if( ! (*vertexMarkerLevel_).up2Date() ) vertexMarkerLevel_->markNewVertices(*this); } - return AlbertaGridLevelIterator<codim,All_Partition,const MyType> (*this,vertexMarker_,level,proc); + return AlbertaGridLevelIterator<codim,All_Partition,const MyType> (*this,vertexMarkerLevel_,level,proc); } template < int dim, int dimworld > template<int codim> @@ -3118,9 +3176,9 @@ namespace Dune { if((dim == codim) || ((dim == 3) && (codim == 2)) ) { - if( ! (*vertexMarker_).up2Date() ) vertexMarker_->markNewVertices(*this); + if( ! (*vertexMarkerLeaf_).up2Date() ) vertexMarkerLeaf_->markNewLeafVertices(*this); } - return AlbertaGridLeafIterator<codim, pitype, const MyType> (*this,vertexMarker_,level,proc); + return AlbertaGridLeafIterator<codim, pitype, const MyType> (*this,vertexMarkerLeaf_,level,proc); } template < int dim, int dimworld > @@ -3179,7 +3237,7 @@ namespace Dune inline typename AlbertaGrid<dim,dimworld>::LeafIterator AlbertaGrid < dim, dimworld >::leafbegin (int level, int proc ) const { - return AlbertaGridLeafIterator<0, All_Partition, const MyType> (*this,vertexMarker_,level,proc); + return AlbertaGridLeafIterator<0, All_Partition, const MyType> (*this,vertexMarkerLeaf_,level,proc); } template < int dim, int dimworld > @@ -3823,7 +3881,8 @@ namespace Dune maxlevel_ = ALBERTA AlbertHelp::calcMaxLevel(mesh_); // unset up2Dat status, if lbegin is called then this status is updated - vertexMarker_->unsetUp2Date(); + vertexMarkerLevel_->unsetUp2Date(); + vertexMarkerLeaf_->unsetUp2Date(); // if levelIndexSet exists, then update now for(unsigned int i=0; i<levelIndexVec_.size(); i++) @@ -3977,7 +4036,8 @@ namespace Dune if( !readParameter(filename,"Time",time) ) time = 0.0; - vertexMarker_ = new AlbertaMarkerVector (); assert(vertexMarker_); + vertexMarkerLevel_ = new AlbertaMarkerVector (true); assert(vertexMarkerLevel_); + vertexMarkerLeaf_ = new AlbertaMarkerVector (false); assert(vertexMarkerLeaf_); ALBERTA AlbertHelp::initIndexManager_elmem_cc(indexStack_); initGrid(myRank_);