From 911e94fa1ed25b33d9548d930a8324e4b7a1faf4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20He=C3=9F?= <rene.hess@iwr.uni-heidelberg.de>
Date: Wed, 12 Sep 2018 15:37:04 +0200
Subject: [PATCH] Sum factorized fast-DG for gmsh files

---
 python/dune/perftool/sumfact/realization.py   | 12 +++++--
 test/sumfact/poisson/CMakeLists.txt           | 14 +++++---
 .../poisson/poisson_fastdg_3d_gmsh.mini       | 34 +++++++++++++++++++
 3 files changed, 54 insertions(+), 6 deletions(-)
 create mode 100644 test/sumfact/poisson/poisson_fastdg_3d_gmsh.mini

diff --git a/python/dune/perftool/sumfact/realization.py b/python/dune/perftool/sumfact/realization.py
index 0acb2128..a4487d7a 100644
--- a/python/dune/perftool/sumfact/realization.py
+++ b/python/dune/perftool/sumfact/realization.py
@@ -194,9 +194,13 @@ def realize_sumfact_kernel_function(sf):
         #   (vectorized + FastDGGridOperator)
         input_inames = (k_expr,) + tuple(prim.Variable(j) for j in out_inames[1:])
         if l == 0 and sf.stage == 1 and sf.interface.direct_is_possible:
-            # See comment below
-            input_inames = permute_backward(input_inames, perm)
+            # One permutation for cost reduction, see comment below
             inp_shape = permute_backward(inp_shape, perm)
+            input_inames = permute_backward(input_inames, perm)
+
+            # And one more for permuted quadrature points, see comment below
+            inp_shape = permute_backward(inp_shape, sf.quadrature_permutation)
+            input_inames = permute_backward(input_inames, sf.quadrature_permutation)
 
             input_summand = sf.interface.realize_direct(inp_shape, input_inames)
         else:
@@ -208,6 +212,10 @@ def realize_sumfact_kernel_function(sf):
                 inp_shape = permute_backward(inp_shape, perm)
                 input_inames = permute_backward(input_inames, perm)
                 if sf.stage == 1:
+                    # In the unstructured case the sf.matrix_sequence could
+                    # already be permuted according to
+                    # sf.quadrature_permutation. We also need to reverse this
+                    # permutation to get the input from 0 to d-1.
                     inp_shape = permute_backward(inp_shape, sf.quadrature_permutation)
                     input_inames = permute_backward(input_inames, sf.quadrature_permutation)
 
diff --git a/test/sumfact/poisson/CMakeLists.txt b/test/sumfact/poisson/CMakeLists.txt
index ee95c2e2..da9166a6 100644
--- a/test/sumfact/poisson/CMakeLists.txt
+++ b/test/sumfact/poisson/CMakeLists.txt
@@ -61,11 +61,17 @@ if(consistent-edge-orientation_FOUND)
                                     INIFILE poisson_dg_3d_unstructured.mini
                                     ANALYZE_GRID
                                     )
+
   dune_add_formcompiler_system_test(UFLFILE poisson_dg_3d.ufl
-                                  BASENAME sumfact_poisson_dg_3d_gmsh
-                                  INIFILE poisson_dg_3d_gmsh.mini
-                                  ANALYZE_GRID
-                                  )
+                                    BASENAME sumfact_poisson_dg_3d_gmsh
+                                    INIFILE poisson_dg_3d_gmsh.mini
+                                    ANALYZE_GRID
+                                    )
+  dune_add_formcompiler_system_test(UFLFILE poisson_dg_3d.ufl
+                                    BASENAME sumfact_poisson_fastdg_3d_gmsh
+                                    INIFILE poisson_fastdg_3d_gmsh.mini
+                                    ANALYZE_GRID
+                                    )
   dune_symlink_to_source_files(FILES cube_hexa_2.msh cube_hexa_2_consistent.msh)
   dune_symlink_to_source_files(FILES cube_hexa.msh cube_hexa_consistent.msh)
 endif()
diff --git a/test/sumfact/poisson/poisson_fastdg_3d_gmsh.mini b/test/sumfact/poisson/poisson_fastdg_3d_gmsh.mini
new file mode 100644
index 00000000..380cef48
--- /dev/null
+++ b/test/sumfact/poisson/poisson_fastdg_3d_gmsh.mini
@@ -0,0 +1,34 @@
+__name = sumfact_poisson_fastdg_3d_gmsh_{__exec_suffix}
+__exec_suffix = {deg_suffix}_{quadvec_suffix}_{gradvec_suffix}
+
+quadvec_suffix = quadvec, nonquadvec | expand quad
+gradvec_suffix = gradvec, nongradvec | expand grad
+deg_suffix = deg{formcompiler.ufl_variants.degree}
+
+{deg_suffix} == deg1 | exclude
+{quadvec_suffix} == quadvec | exclude
+{gradvec_suffix} == gradvec | exclude
+
+# gmshFile = cube_hexa_2.msh
+# gmshFile = cube_hexa_2_consistent.msh
+# gmshFile = cube_hexa.msh
+gmshFile = cube_hexa_consistent.msh
+
+[wrapper.vtkcompare]
+name = {__name}
+extension = vtu
+
+[formcompiler]
+compare_l2errorsquared = 1e-4, 5e-6 | expand deg
+grid_unstructured = 1
+
+[formcompiler.r]
+numerical_jacobian = 0
+sumfact = 1
+fastdg = 1
+sumfact_regular_jacobians = 1
+vectorization_quadloop = 1, 0 | expand quad
+vectorization_strategy = explicit, none | expand grad
+
+[formcompiler.ufl_variants]
+degree = 1, 2 | expand deg
-- 
GitLab