From 3dca73318742fa67affdb627daf57906546c9ed3 Mon Sep 17 00:00:00 2001
From: Tobias Leibner <tobias.leibner@googlemail.com>
Date: Thu, 10 Jul 2014 09:11:25 +0200
Subject: [PATCH] [spaces.continuouslagrange.pdelab and
 playground.spaces.discontinuouslagrange.pdelab] move CommunicationChooser to
 its own header

---
 .../spaces/discontinuouslagrange/pdelab.hh    | 61 +-------------
 dune/gdt/spaces/continuouslagrange/pdelab.hh  | 54 +-----------
 dune/gdt/spaces/parallel.hh                   | 83 +++++++++++++++++++
 3 files changed, 86 insertions(+), 112 deletions(-)
 create mode 100644 dune/gdt/spaces/parallel.hh

diff --git a/dune/gdt/playground/spaces/discontinuouslagrange/pdelab.hh b/dune/gdt/playground/spaces/discontinuouslagrange/pdelab.hh
index c2a0e8ffe..f3279405a 100644
--- a/dune/gdt/playground/spaces/discontinuouslagrange/pdelab.hh
+++ b/dune/gdt/playground/spaces/discontinuouslagrange/pdelab.hh
@@ -6,39 +6,28 @@
 #ifndef DUNE_GDT_SPACES_DISCONTINUOUSLAGRANGE_PDELAB_HH
 #define DUNE_GDT_SPACES_DISCONTINUOUSLAGRANGE_PDELAB_HH
 
-#include "config.h"
-
 #include <memory>
 
 #include <dune/common/typetraits.hh>
 
 #include <dune/stuff/common/disable_warnings.hh>
 #include <dune/common/fvector.hh>
-#include <dune/common/parallel/communicator.hh>
-#include <dune/stuff/common/parallel/helper.hh>
 #include <dune/stuff/common/reenable_warnings.hh>
 
 #include <dune/geometry/genericgeometry/topologytypes.hh>
 
-#include <dune/grid/common/capabilities.hh>
-
-#if HAVE_DUNE_ISTL
-#include <dune/stuff/common/disable_warnings.hh>
-#include <dune/istl/owneroverlapcopy.hh>
-#include <dune/stuff/common/reenable_warnings.hh>
-#endif
-
 #if HAVE_DUNE_PDELAB
 #include <dune/stuff/common/disable_warnings.hh>
 #include <dune/pdelab/finiteelementmap/qkdg.hh>
 #include <dune/pdelab/gridfunctionspace/gridfunctionspace.hh>
 #include <dune/pdelab/constraints/conforming.hh>
-#include <dune/pdelab/backend/istl/parallelhelper.hh>
 #include <dune/stuff/common/reenable_warnings.hh>
 #endif // HAVE_DUNE_PDELAB
 
 #include <dune/stuff/la/container/istl.hh>
 
+#include <dune/gdt/spaces/parallel.hh>
+
 #include "../../../mapper/pdelab.hh"
 #include "../../../basefunctionset/pdelab.hh"
 
@@ -52,52 +41,6 @@ namespace DiscontinuousLagrange {
 #if HAVE_DUNE_PDELAB
 
 
-template <class ViewImp,
-          bool is_parallel = DS::UseParallelCommunication<typename ViewImp::Grid::CollectiveCommunication>::value>
-struct CommunicationChooser
-{
-  typedef DS::SequentialCommunication Type;
-
-  static std::shared_ptr<Type> create(const ViewImp& /*gridView*/)
-  {
-    return std::make_shared<Type>();
-  }
-
-  template <class SpaceBackend>
-  static bool prepare(const SpaceBackend& /*space_backend*/, Type& /*communicator*/)
-  {
-    return false;
-  }
-}; // struct CommunicationChooser
-
-
-#if HAVE_MPI
-
-
-template <class ViewImp>
-struct CommunicationChooser<ViewImp, true>
-{
-  typedef OwnerOverlapCopyCommunication<bigunsignedint<96>, int> Type;
-
-  static std::shared_ptr<Type> create(const ViewImp& gridView)
-  {
-    return std::make_shared<Type>(gridView.comm());
-  }
-
-  template <class Space>
-  static bool prepare(const Space& space, Type& communicator)
-  {
-    Stuff::LA::IstlRowMajorSparseMatrix<typename Space::RangeFieldType> matrix;
-    PDELab::istl::ParallelHelper<typename Space::BackendType>(space.backend(), 0)
-        .createIndexSetAndProjectForAMG(matrix.backend(), communicator);
-    return true;
-  }
-}; // struct CommunicationChooser< ..., true >
-
-
-#endif // HAVE_MPI
-
-
 // forward, to be used in the traits and to allow for specialization
 template <class GridViewImp, int polynomialOrder, class RangeFieldImp, int rangeDim, int rangeDimCols = 1>
 class PdelabBased
diff --git a/dune/gdt/spaces/continuouslagrange/pdelab.hh b/dune/gdt/spaces/continuouslagrange/pdelab.hh
index eeab07c51..cbbdb8c34 100644
--- a/dune/gdt/spaces/continuouslagrange/pdelab.hh
+++ b/dune/gdt/spaces/continuouslagrange/pdelab.hh
@@ -11,19 +11,14 @@
 
 #include <dune/geometry/genericgeometry/topologytypes.hh>
 
-#include <dune/grid/common/capabilities.hh>
-
 #include <dune/common/typetraits.hh>
 
 #include <dune/stuff/common/disable_warnings.hh>
 #include <dune/common/fvector.hh>
-#include <dune/common/parallel/communicator.hh>
-#include <dune/stuff/common/parallel/helper.hh>
 #include <dune/stuff/common/reenable_warnings.hh>
 
 #if HAVE_DUNE_ISTL
 #include <dune/stuff/common/disable_warnings.hh>
-#include <dune/istl/owneroverlapcopy.hh>
 #include <dune/istl/paamg/pinfo.hh>
 #include <dune/stuff/common/reenable_warnings.hh>
 #include <dune/stuff/la/solver/istl_amg.hh>
@@ -35,11 +30,10 @@
 #include <dune/pdelab/finiteelementmap/qkfem.hh>
 #include <dune/pdelab/gridfunctionspace/gridfunctionspace.hh>
 #include <dune/pdelab/constraints/conforming.hh>
-#include <dune/pdelab/backend/istl/parallelhelper.hh>
 #include <dune/stuff/common/reenable_warnings.hh>
 #endif // HAVE_DUNE_PDELAB
 
-#include <dune/stuff/la/container/istl.hh>
+#include <dune/gdt/spaces/parallel.hh>
 
 #include "../../mapper/pdelab.hh"
 #include "../../basefunctionset/pdelab.hh"
@@ -55,52 +49,6 @@ namespace ContinuousLagrange {
 #if HAVE_DUNE_PDELAB
 
 
-template <class ViewImp,
-          bool is_parallel = DS::UseParallelCommunication<typename ViewImp::Grid::CollectiveCommunication>::value>
-struct CommunicationChooser
-{
-  typedef DS::SequentialCommunication Type;
-
-  static std::shared_ptr<Type> create(const ViewImp& /*gridView*/)
-  {
-    return std::make_shared<Type>();
-  }
-
-  template <class SpaceBackend>
-  static bool prepare(const SpaceBackend& /*space_backend*/, Type& /*communicator*/)
-  {
-    return false;
-  }
-}; // struct CommunicationChooser
-
-
-#if HAVE_MPI
-
-
-template <class ViewImp>
-struct CommunicationChooser<ViewImp, true>
-{
-  typedef OwnerOverlapCopyCommunication<bigunsignedint<96>, int> Type;
-
-  static std::shared_ptr<Type> create(const ViewImp& gridView)
-  {
-    return std::make_shared<Type>(gridView.comm());
-  }
-
-  template <class Space>
-  static bool prepare(const Space& space, Type& communicator)
-  {
-    Stuff::LA::IstlRowMajorSparseMatrix<typename Space::RangeFieldType> matrix;
-    PDELab::istl::ParallelHelper<typename Space::BackendType>(space.backend(), 0)
-        .createIndexSetAndProjectForAMG(matrix.backend(), communicator);
-    return true;
-  }
-}; // struct CommunicationChooser< ..., true >
-
-
-#endif // HAVE_MPI
-
-
 // forward, to be used in the traits and to allow for specialization
 template <class GridViewImp, int polynomialOrder, class RangeFieldImp, int rangeDim, int rangeDimCols = 1>
 class PdelabBased
diff --git a/dune/gdt/spaces/parallel.hh b/dune/gdt/spaces/parallel.hh
new file mode 100644
index 000000000..d8fb348ed
--- /dev/null
+++ b/dune/gdt/spaces/parallel.hh
@@ -0,0 +1,83 @@
+// This file is part of the dune-gdt project:
+//   http://users.dune-project.org/projects/dune-gdt
+// Copyright holders: Felix Schindler
+// License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
+
+#ifndef DUNE_GDT_SPACES_PARALLEL_HH
+#define DUNE_GDT_SPACES_PARALLEL_HH
+
+#include <dune/stuff/common/disable_warnings.hh>
+#include <dune/common/parallel/communicator.hh>
+#include <dune/stuff/common/reenable_warnings.hh>
+
+#if HAVE_DUNE_ISTL
+#include <dune/stuff/common/disable_warnings.hh>
+#include <dune/istl/owneroverlapcopy.hh>
+#include <dune/stuff/common/reenable_warnings.hh>
+#endif
+
+#if HAVE_DUNE_PDELAB
+#include <dune/stuff/common/disable_warnings.hh>
+#include <dune/pdelab/backend/istl/parallelhelper.hh>
+#include <dune/stuff/common/reenable_warnings.hh>
+#endif
+
+#include <dune/stuff/la/container/istl.hh>
+#include <dune/stuff/common/parallel/helper.hh>
+
+namespace Dune {
+
+namespace GDT {
+namespace Spaces {
+
+template <class ViewImp,
+          bool is_parallel =
+              Dune::Stuff::UseParallelCommunication<typename ViewImp::Grid::CollectiveCommunication>::value>
+struct CommunicationChooser
+{
+  typedef Dune::Stuff::SequentialCommunication Type;
+
+  static std::shared_ptr<Type> create(const ViewImp& /*gridView*/)
+  {
+    return std::make_shared<Type>();
+  }
+
+  template <class SpaceBackend>
+  static bool prepare(const SpaceBackend& /*space_backend*/, Type& /*communicator*/)
+  {
+    return false;
+  }
+}; // struct CommunicationChooser
+
+
+#if HAVE_MPI
+
+
+template <class ViewImp>
+struct CommunicationChooser<ViewImp, true>
+{
+  typedef OwnerOverlapCopyCommunication<bigunsignedint<96>, int> Type;
+
+  static std::shared_ptr<Type> create(const ViewImp& gridView)
+  {
+    return std::make_shared<Type>(gridView.comm());
+  }
+
+  template <class Space>
+  static bool prepare(const Space& space, Type& communicator)
+  {
+    Stuff::LA::IstlRowMajorSparseMatrix<typename Space::RangeFieldType> matrix;
+    PDELab::istl::ParallelHelper<typename Space::BackendType>(space.backend(), 0)
+        .createIndexSetAndProjectForAMG(matrix.backend(), communicator);
+    return true;
+  }
+}; // struct CommunicationChooser< ..., true >
+
+
+#endif // HAVE_MPI
+
+} // namespace Spaces
+} // namespace GDT
+} // namespace Dune
+
+#endif // DUNE_GDT_SPACES_PARALLEL_HH
-- 
GitLab