From b9c0c16f86bedf5033ed2a367ad7ad4483f611c8 Mon Sep 17 00:00:00 2001
From: Oliver Sander <sander@igpm.rwth-aachen.de>
Date: Fri, 16 May 2014 15:39:46 +0000
Subject: [PATCH] Start an entity-based interface for GlobalIndex

And use it in one place in VectorCommunicator

[[Imported from SVN: r9748]]
---
 dune/gfe/parallel/globalindex.hh        | 9 +++++++++
 dune/gfe/parallel/vectorcommunicator.hh | 5 +++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/dune/gfe/parallel/globalindex.hh b/dune/gfe/parallel/globalindex.hh
index 4999ad95..7978dc97 100644
--- a/dune/gfe/parallel/globalindex.hh
+++ b/dune/gfe/parallel/globalindex.hh
@@ -293,6 +293,15 @@ public:
     return globalLocalMap_.find(globalIndex)->second;
   }
 
+  int globalIndex(const typename GridView::template Codim<CODIM>::Entity& entity) const
+  {
+    return localGlobalMap_.find(gridview_.indexSet().index(entity))->second;
+  }
+
+  int localIndex(const typename GridView::template Codim<CODIM>::Entity& entity) const {
+    return gridview_.indexSet().index(entity);
+  }
+
   inline unsigned int nGlobalEntity() const
   {
     return(nGlobalEntity_);
diff --git a/dune/gfe/parallel/vectorcommunicator.hh b/dune/gfe/parallel/vectorcommunicator.hh
index e9144c11..f3d460c3 100644
--- a/dune/gfe/parallel/vectorcommunicator.hh
+++ b/dune/gfe/parallel/vectorcommunicator.hh
@@ -26,8 +26,9 @@ private:
     std::vector<TransferVectorTuple> localVectorEntries;
 
     // Translate vector entries
-    for (size_t k = 0; k < localVector.size(); ++k)
-      localVectorEntries.push_back(TransferVectorTuple(guIndex.globalIndex(k), localVector[k]));
+    const auto& gridView = guIndex.getGridView();
+    for (auto it = gridView.template begin<2>(); it != gridView.template end<2>(); ++ it)
+        localVectorEntries.push_back(TransferVectorTuple(guIndex.globalIndex(*it), localVector[guIndex.localIndex(*it)]));
 
     // Get number of vector entries on each process
     localVectorEntriesSizes = MPIFunctions::shareSizes(guIndex.getGridView(), localVectorEntries.size());
-- 
GitLab