From 31c7e790ba8d0d828ce2df2d2f0c91682919d727 Mon Sep 17 00:00:00 2001
From: Timo Koch <timo.koch@iws.uni-stuttgart.de>
Date: Tue, 26 Jan 2016 21:00:19 +0100
Subject: [PATCH] [bugfix][adaptivity] Remove isNew markers on ALL levels

When global refining not all isNew markers were removed.
This also caused a bug when mixing growth and adaptivity as the
isNew marker is also used for newly added elements through growth.
---
 dune/foamgrid/foamgrid/foamgrid.cc | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/dune/foamgrid/foamgrid/foamgrid.cc b/dune/foamgrid/foamgrid/foamgrid.cc
index 11068a4..e033c4e 100644
--- a/dune/foamgrid/foamgrid/foamgrid.cc
+++ b/dune/foamgrid/foamgrid/foamgrid.cc
@@ -319,13 +319,15 @@ void Dune::FoamGrid<dimgrid, dimworld>::postAdapt()
   willCoarsen=false;
 
   // Loop over all leaf entities and remove the isNew Marker.
-  for (const auto& element : elements(this->leafGridView()))
+  for (int level = maxLevel(); level >= 0; --level)
   {
-    FoamGridEntityImp<dimgrid, dimgrid, dimworld>& e = *const_cast<FoamGridEntityImp<dimgrid, dimgrid, dimworld>*>(this->getRealImplementation(element).target_);
-    e.isNew_=false;
-    assert(!e.willVanish_);
-    if (e.father_)
-      e.father_->markState_=FoamGridEntityImp<dimgrid, dimgrid, dimworld>::DO_NOTHING;
+    for(auto eIt = std::get<dimgrid>(entityImps_[level]).begin(); eIt != std::get<dimgrid>(entityImps_[level]).end(); ++eIt)
+    {
+      eIt->isNew_=false;
+      assert(!eIt->willVanish_);
+      if (eIt->father_)
+        eIt->father_->markState_=FoamGridEntityImp<dimgrid, dimgrid, dimworld>::DO_NOTHING;
+    }
   }
 }
 
-- 
GitLab