From ff4b03f223bebc912c646b514ca88845f4296431 Mon Sep 17 00:00:00 2001
From: Marcel Koch <marcel.koch@uni-muenster.de>
Date: Thu, 24 Aug 2017 10:13:49 +0200
Subject: [PATCH] Removes pdelab patch, adds instead blockstructured FEM
 locally

---
 .../blockstructured/blockstructuredqkfem.hh   | 61 +++++++++++++++++++
 ...Adds-Qk-for-k-2-for-structured-grids.patch | 53 ----------------
 python/dune/perftool/pdelab/driver.py         |  3 +
 3 files changed, 64 insertions(+), 53 deletions(-)
 create mode 100644 dune/perftool/blockstructured/blockstructuredqkfem.hh
 delete mode 100644 patches/dune-pdelab/0001-Adds-Qk-for-k-2-for-structured-grids.patch

diff --git a/dune/perftool/blockstructured/blockstructuredqkfem.hh b/dune/perftool/blockstructured/blockstructuredqkfem.hh
new file mode 100644
index 00000000..fd27ef36
--- /dev/null
+++ b/dune/perftool/blockstructured/blockstructuredqkfem.hh
@@ -0,0 +1,61 @@
+#ifndef DUNE_PERFTOOL_BLOCKSTRUCTUREDQKFEM_HH
+#define DUNE_PERFTOOL_BLOCKSTRUCTUREDQKFEM_HH
+
+
+#include <cstddef>
+
+#include <dune/common/power.hh>
+#include <dune/localfunctions/lagrange/qk.hh>
+#include <dune/pdelab/finiteelementmap/finiteelementmap.hh>
+
+namespace Dune {
+  namespace PDELab {
+
+    //! wrap up element from local functions
+    //! \ingroup FiniteElementMap
+    template<typename GV, typename D, typename R, std::size_t k>
+    class BlockstructuredQkLocalFiniteElementMap
+        : public SimpleLocalFiniteElementMap< Dune::QkLocalFiniteElement<D,R,GV::dimension,k> >
+    {
+
+    public:
+
+      BlockstructuredQkLocalFiniteElementMap(const GV& gv)
+      {}
+
+      bool fixedSize() const
+      {
+        return true;
+      }
+
+      bool hasDOFs(int codim) const
+      {
+        switch(k)
+        {
+          case 1:
+            return codim == GV::dimension;
+          default:
+            return 1;
+        }
+      }
+
+      std::size_t size(GeometryType gt) const
+      {
+        std::size_t acc = 1;
+        for(std::size_t i = 0; i < gt.dim(); ++i)
+          acc *= k-1;
+        return acc;
+      }
+
+      std::size_t maxLocalSize() const
+      {
+        return Dune::StaticPower<k+1,GV::dimension>::power;
+      }
+
+    };
+
+  }
+}
+
+
+#endif //DUNE_PERFTOOL_BLOCKSTRUCTUREDQKFEM_HH
diff --git a/patches/dune-pdelab/0001-Adds-Qk-for-k-2-for-structured-grids.patch b/patches/dune-pdelab/0001-Adds-Qk-for-k-2-for-structured-grids.patch
deleted file mode 100644
index b5e482af..00000000
--- a/patches/dune-pdelab/0001-Adds-Qk-for-k-2-for-structured-grids.patch
+++ /dev/null
@@ -1,53 +0,0 @@
-From cf3cc167d4940d7c4960bc5646816b6cf6a17326 Mon Sep 17 00:00:00 2001
-From: Marcel Koch <marcel.koch@uni-muenster.de>
-Date: Mon, 31 Jul 2017 15:45:53 +0200
-Subject: [PATCH] Adds Qk for k>2 for structured grids
-
----
- dune/pdelab/finiteelementmap/qkfem.hh | 24 +++++-------------------
- 1 file changed, 5 insertions(+), 19 deletions(-)
-
-diff --git a/dune/pdelab/finiteelementmap/qkfem.hh b/dune/pdelab/finiteelementmap/qkfem.hh
-index b4e8d67..435545e 100644
---- a/dune/pdelab/finiteelementmap/qkfem.hh
-+++ b/dune/pdelab/finiteelementmap/qkfem.hh
-@@ -35,31 +35,17 @@ namespace Dune {
-           {
-           case 1:
-             return codim == GV::dimension;
--          case 2:
--            if (GV::dimension != 2 && GV::dimension != 3)
--              DUNE_THROW(NotImplemented,"QkLocalFiniteElementMap with k = 2 is only implemented for d = 2,3");
--            return 1;
-           default:
--            DUNE_THROW(NotImplemented,"QkLocalFiniteElementMap is only implemented for k <= 2");
-+            return 1;
-           }
-       }
- 
-       std::size_t size(GeometryType gt) const
-       {
--        switch (k)
--          {
--          case 1:
--            return gt.isVertex() ? 1 : 0;
--          case 2:
--            {
--              if (GV::dimension != 2 && GV::dimension != 3)
--                DUNE_THROW(NotImplemented,"QkLocalFiniteElementMap with k = 2 is only implemented for d = 2,3");
--              // Q1 simply attaches a single DOF to each subentity
--              return 1;
--            }
--          default:
--            DUNE_THROW(NotImplemented,"QkLocalFiniteElementMap is only implemented for k <= 2");
--          }
-+        std::size_t acc = 1;
-+        for(std::size_t i = 0; i < gt.dim(); ++i)
-+          acc *= k-1;
-+        return acc;
-       }
- 
-       std::size_t maxLocalSize() const
--- 
-2.7.4
-
diff --git a/python/dune/perftool/pdelab/driver.py b/python/dune/perftool/pdelab/driver.py
index 3aba1351..8fb6dc15 100644
--- a/python/dune/perftool/pdelab/driver.py
+++ b/python/dune/perftool/pdelab/driver.py
@@ -309,6 +309,9 @@ def typedef_fem(expr, name):
     df = type_domainfield()
     r = type_range()
     dim = name_dimension()
+    if get_option("blockstructured"):
+        include_file("dune/perftool/blockstructured/blockstructuredqkfem.hh", filetag="driver")
+        return "using {} = Dune::PDELab::BlockstructuredQkLocalFiniteElementMap<{}, {}, {}, {}>;".format(name, gv, df, r, expr._degree)
     if isPk(expr):
         include_file("dune/pdelab/finiteelementmap/pkfem.hh", filetag="driver")
         return "using {} = Dune::PDELab::PkLocalFiniteElementMap<{}, {}, {}, {}>;".format(name, gv, df, r, expr._degree)
-- 
GitLab