From 9791f45d6a70c923e9c0ecfb7043cd31481e0c18 Mon Sep 17 00:00:00 2001
From: "Praetorius, Simon" <simon.praetorius@tu-dresden.de>
Date: Fri, 31 Jan 2020 17:35:51 +0100
Subject: [PATCH] workaround for communicators in blocked bases, use
 SequentialCommunication if not flat MultiIndex

---
 src/amdis/functions/ParallelGlobalBasis.hpp | 11 +++++++----
 src/amdis/typetree/MultiIndex.hpp           | 15 +++++++++++++++
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/src/amdis/functions/ParallelGlobalBasis.hpp b/src/amdis/functions/ParallelGlobalBasis.hpp
index 8e219428..82677c71 100644
--- a/src/amdis/functions/ParallelGlobalBasis.hpp
+++ b/src/amdis/functions/ParallelGlobalBasis.hpp
@@ -23,12 +23,13 @@
 
 #include <dune/typetree/treepath.hh>
 
-#include <amdis/common/Concepts.hpp>
-#include <amdis/common/TypeTraits.hpp>
-#include <amdis/linearalgebra/Traits.hpp>
 #include <amdis/AdaptiveGrid.hpp>
 #include <amdis/Observer.hpp>
 #include <amdis/Output.hpp>
+#include <amdis/common/Concepts.hpp>
+#include <amdis/common/TypeTraits.hpp>
+#include <amdis/linearalgebra/Traits.hpp>
+#include <amdis/typetree/MultiIndex.hpp>
 
 #if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7)
 #include <dune/functions/functionspacebases/defaultlocalindexset.hh>
@@ -65,7 +66,9 @@ namespace AMDiS
     using LocalView = Dune::Functions::DefaultLocalView<Self>;
 
     /// Type of the communicator
-    using Comm = typename BackendTraits<Self>::Comm;
+    using Comm = std::conditional_t<Traits::IsFlatIndex<typename Super::MultiIndex>::value,
+      typename BackendTraits<Self>::Comm,
+      SequentialCommunication>;
 
     struct DummyImpl {};
     using ADH = Dune::AdaptDataHandle<Grid, DummyImpl>;
diff --git a/src/amdis/typetree/MultiIndex.hpp b/src/amdis/typetree/MultiIndex.hpp
index fb997f13..3ef8048f 100644
--- a/src/amdis/typetree/MultiIndex.hpp
+++ b/src/amdis/typetree/MultiIndex.hpp
@@ -5,6 +5,21 @@
 
 namespace AMDiS
 {
+  namespace Traits
+  {
+    template <class T>
+    struct IsFlatIndex
+        : std::is_integral<T> {};
+
+    template <class I>
+    struct IsFlatIndex<Dune::Functions::FlatMultiIndex<I> >
+        : std::true_type {};
+
+    template <class I>
+    struct IsFlatIndex<Dune::ReservedVector<I, 1> >
+        : std::true_type {};
+  }
+
   inline std::size_t flatMultiIndex(std::size_t idx)
   {
     return idx;
-- 
GitLab