From 29d149cb76fd164e5482ffbdb6fcbc6049f8cc1c Mon Sep 17 00:00:00 2001
From: Oliver Sander <sander@igpm.rwth-aachen.de>
Date: Mon, 26 May 2014 05:22:32 +0000
Subject: [PATCH] Avoid loops over entities of any codimension

For a general grid, such loops are only possible for codimensions 0
and the grid dimension.

[[Imported from SVN: r9766]]
---
 dune/gfe/parallel/uniqueentitypartition.hh | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/dune/gfe/parallel/uniqueentitypartition.hh b/dune/gfe/parallel/uniqueentitypartition.hh
index 232c18d8..a7216e36 100644
--- a/dune/gfe/parallel/uniqueentitypartition.hh
+++ b/dune/gfe/parallel/uniqueentitypartition.hh
@@ -129,11 +129,14 @@ public:
 	typedef typename GridView::IndexSet IndexSet;
 
 	// assign own rank to entities that I might have
-	for(Iterator it = gridview_.template begin<CODIM>();it!=gridview_.template end<CODIM>(); ++it)
-          assignment_[gridview_.indexSet().template index(*it)]
-            = ( (it->partitionType()==Dune::InteriorEntity) || (it->partitionType()==Dune::BorderEntity) )
-            ? rank_  // set to own rank
-            : - 1;   // it is a ghost entity, I will not possibly own it.
+        for(auto it = gridview_.template begin<0>();it!=gridview_.template end<0>(); ++it)
+          for (int i=0; i<it->template count<CODIM>(); i++)
+          {
+            assignment_[gridview_.indexSet().template subIndex(*it,i,CODIM)]
+              = ( (it->template subEntity<CODIM>(i)->partitionType()==Dune::InteriorEntity) || (it->template subEntity<CODIM>(i)->partitionType()==Dune::BorderEntity) )
+              ? rank_  // set to own rank
+              : - 1;   // it is a ghost entity, I will not possibly own it.
+          }
 
         /** exchange entity index through communication */
 	MinimumExchange<IndexSet,std::vector<int> > dh(gridview_.indexSet(),assignment_);
@@ -141,11 +144,8 @@ public:
 	gridview_.communicate(dh,Dune::All_All_Interface,Dune::ForwardCommunication);
 
 	/* convert vector of minimum ranks to assignment vector */
-	for(Iterator it = gridview_.template begin<CODIM>();it!=gridview_.template end<CODIM>(); ++it)
-        {
-          size_t idx = gridview_.indexSet().template index(*it);
-          assignment_[idx] = (assignment_[idx] == rank_) ? 1 : 0;
-        }
+        for (size_t i=0; i<assignment_.size(); i++)
+          assignment_[i] = (assignment_[i] == rank_) ? 1 : 0;
   }
 
   /** answer question if entity belongs to me, to this process */
-- 
GitLab