diff --git a/dune/alugrid/3d/datahandle.hh b/dune/alugrid/3d/datahandle.hh index 59dd9688a26c5a6c49cbb47e69a95909f51aedb4..417ba795922eb2dc343bd73fad7c1c8e35091b43 100644 --- a/dune/alugrid/3d/datahandle.hh +++ b/dune/alugrid/3d/datahandle.hh @@ -691,7 +691,7 @@ namespace ALUGrid realFather_.setElement( father ); rp_.postRefinement( reFather_ ); - // resert refinement markers + // reset refinement markers father.resetRefinedTag(); for( HElementType *son = father.down(); son ; son = son->next() ) son->resetRefinedTag(); diff --git a/dune/alugrid/3d/grid.hh b/dune/alugrid/3d/grid.hh index b89680e02ad4d293338d7298e7ad07b16a1858d6..96d2f9a93c5f335805e39bc206a05c075113dd01 100644 --- a/dune/alugrid/3d/grid.hh +++ b/dune/alugrid/3d/grid.hh @@ -905,6 +905,9 @@ namespace Dune // load balance and compress memory if possible void finalizeGridCreation(); + //! clear all entity new markers + void clearIsNewMarkers( ); + private: typedef ALU3DSPACE GatherScatter GatherScatterType; @@ -915,7 +918,7 @@ namespace Dune //! returns if a least one entity was marked for coarsening bool preAdapt ( ); - //! clear all entity new markers + //! clear all entity new markers if lockPostAdapt_ is set void postAdapt ( ); /** \brief @copydoc Dune::Grid::adapt() */ diff --git a/dune/alugrid/3d/grid_imp.cc b/dune/alugrid/3d/grid_imp.cc index b1ae5ff6518a3856055e842869ef2d495cbf3fff..63369f923d694876e5e1a401487fcd3b5fc069a9 100644 --- a/dune/alugrid/3d/grid_imp.cc +++ b/dune/alugrid/3d/grid_imp.cc @@ -485,45 +485,55 @@ namespace Dune // post process grid template< ALU3dGridElementType elType, class Comm > alu_inline - void ALU3dGrid< elType, Comm >::postAdapt () + void ALU3dGrid< elType, Comm >::clearIsNewMarkers () { - { - // old fashioned way - typedef ALU3DSPACE ALU3dGridLeafIteratorWrapper< 0, All_Partition, Comm > IteratorType; - IteratorType w (*this, maxLevel(), nlinks() ); - - typedef typename IteratorType::val_t val_t; - typedef typename ALU3dImplTraits< elType, Comm >::IMPLElementType IMPLElementType; - - for (w.first () ; ! w.done () ; w.next ()) - { - val_t & item = w.item(); + // old fashioned way + typedef ALU3DSPACE ALU3dGridLeafIteratorWrapper< 0, All_Partition, Comm > IteratorType; + IteratorType w (*this, maxLevel(), nlinks() ); + + typedef typename IteratorType::val_t val_t; + typedef typename ALU3dImplTraits< elType, Comm >::IMPLElementType IMPLElementType; + + for (w.first () ; ! w.done () ; w.next ()) + { + val_t & item = w.item(); - alugrid_assert ( item.first || item.second ); - IMPLElementType * elem = 0; - if( item.first ) - elem = static_cast<IMPLElementType *> (item.first); - else if( item.second ) - { - elem = static_cast<IMPLElementType *>( item.second->getGhost().first ); - alugrid_assert ( elem ); - } - if (elem->hasBeenRefined()) + alugrid_assert ( item.first || item.second ); + IMPLElementType * elem = 0; + if( item.first ) + elem = static_cast<IMPLElementType *> (item.first); + else if( item.second ) + { + elem = static_cast<IMPLElementType *>( item.second->getGhost().first ); + alugrid_assert ( elem ); + } + if (elem->hasBeenRefined()) + { + elem->resetRefinedTag(); + // on bisected grids its possible that not only leaf elements where added so + // we have to move up the hierarchy to make sure that the refined tag on parents are also removed + while (elem->up()) { + elem = static_cast<IMPLElementType *>(elem->up()); elem->resetRefinedTag(); - // on bisected grids its possible that not only leaf elements where added so - // we have to move up the hierarchy to make sure that the refined tag on parents are also removed - while (elem->up()) - { - elem = static_cast<IMPLElementType *>(elem->up()); - elem->resetRefinedTag(); - } } } } + } - // make that postAdapt has been called - lockPostAdapt_ = false; + // post process grid + template< ALU3dGridElementType elType, class Comm > + alu_inline + void ALU3dGrid< elType, Comm >::postAdapt () + { + if( lockPostAdapt_ ) + { + // call implementation of postAdapt + clearIsNewMarkers(); + + // make that postAdapt has been called + lockPostAdapt_ = false; + } } template< ALU3dGridElementType elType, class Comm > @@ -582,7 +592,7 @@ namespace Dune updateStatus(); // reset refinement markers - postAdapt(); + clearIsNewMarkers(); } diff --git a/dune/alugrid/3d/grid_inline.hh b/dune/alugrid/3d/grid_inline.hh index 1d837714fa91c32fce56af8b00eb1e7342e4303c..04cd2a87fb95d81909b615f32db8ed13b4ae71ae 100644 --- a/dune/alugrid/3d/grid_inline.hh +++ b/dune/alugrid/3d/grid_inline.hh @@ -54,7 +54,7 @@ namespace Dune dverb << "************************************************" << std::endl; checkMacroGrid (); - postAdapt(); + clearIsNewMarkers(); calcExtras(); } // end constructor @@ -362,17 +362,9 @@ namespace Dune EntityObject father( EntityImp( factory(), this->maxLevel() ) ); EntityObject son ( EntityImp( factory(), this->maxLevel() ) ); - int defaultChunk = newElementsChunk_; - int actChunk = refineEstimate_ * refineMarked_; - - // guess how many new elements we get - int newElements = std::max( actChunk , defaultChunk ); - // true if at least one element was marked for coarsening bool mightCoarse = preAdapt(); - // reserve memory - handle.preAdapt( newElements ); - + bool refined = false ; if(globalIdSet_) { @@ -408,9 +400,6 @@ namespace Dune // are cleand during refinement callback } - // check whether we have balance - handle.postAdapt(); - // here postAdapt is not called, because // reset of refinedTag is done in preCoarsening and postRefinement // methods of datahandle (see datahandle.hh) @@ -460,7 +449,7 @@ namespace Dune grid.globalIdSet_->updateIdSet(); // unset all leaf markers - grid.postAdapt(); + grid.clearIsNewMarkers(); } return changed; @@ -509,19 +498,12 @@ namespace Dune // compress data, wrapper for dof manager gs.compress(); - grid.postAdapt(); + grid.clearIsNewMarkers(); } return changed; } }; // ALU3dGridCommHelper -/* - template< ALU3dGridElementType elType, class Comm > - inline bool ALU3dGrid< elType, Comm >::loadBalance () - { - return ALU3dGridCommHelper< elType, Comm >::loadBalance( *this ); - } -*/ // load balance grid template< ALU3dGridElementType elType, class Comm > @@ -544,7 +526,7 @@ namespace Dune updateStatus(); // call post adapt - postAdapt(); + clearIsNewMarkers(); }