From 138095ad68519e9ead5cd5e9f830204784677d87 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20He=C3=9F?= <rene.hess@iwr.uni-heidelberg.de>
Date: Mon, 20 Aug 2018 15:00:32 +0200
Subject: [PATCH] Analyze grid in 3d example

---
 bin/analyzegrid/analyze_grid.cc        | 2 +-
 cmake/modules/DunePerftoolMacros.cmake | 2 +-
 python/dune/perftool/options.py        | 2 +-
 python/dune/perftool/sumfact/switch.py | 4 ++--
 test/sumfact/poisson/CMakeLists.txt    | 9 +++++----
 5 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/bin/analyzegrid/analyze_grid.cc b/bin/analyzegrid/analyze_grid.cc
index 61eddbf1..5ceed213 100644
--- a/bin/analyzegrid/analyze_grid.cc
+++ b/bin/analyzegrid/analyze_grid.cc
@@ -18,7 +18,7 @@ int main(int argc, char** argv){
   try
   {
     if (argc != 3){
-      std::cout << "Need ini file as command line argument." << std::endl;
+      std::cout << "Need ini file and output filename." << std::endl;
       return 1;
     }
 
diff --git a/cmake/modules/DunePerftoolMacros.cmake b/cmake/modules/DunePerftoolMacros.cmake
index 42446c12..d5557d41 100644
--- a/cmake/modules/DunePerftoolMacros.cmake
+++ b/cmake/modules/DunePerftoolMacros.cmake
@@ -120,7 +120,7 @@ function(add_generated_executable)
   set(ANALYZE_GRID_OPTION)
   if(GEN_ANALYZE_GRID)
     set(ANALYZE_GRID_FILE "${GEN_INIFILE}.csv")
-    set(ANALYZE_GRID_OPTION "--sumfact-grid-info=${ANALYZE_GRID_FILE}")
+    set(ANALYZE_GRID_OPTION "--grid-info=${ANALYZE_GRID_FILE}")
     add_custom_command(OUTPUT ${ANALYZE_GRID_FILE}
                        COMMAND ${CMAKE_BINARY_DIR}/bin/analyzegrid/analyze_grid ${GEN_INIFILE} ${ANALYZE_GRID_FILE}
                        COMMENT "Analyzing the grid for target ${GEN_TARGET}..."
diff --git a/python/dune/perftool/options.py b/python/dune/perftool/options.py
index b909e5b1..a28b2bc5 100644
--- a/python/dune/perftool/options.py
+++ b/python/dune/perftool/options.py
@@ -39,6 +39,7 @@ class PerftoolGlobalOptionsArray(ImmutableRecord):
     explicit_time_stepping = PerftoolOption(default=False, helpstr="use explicit time stepping")
     exact_solution_expression = PerftoolOption(helpstr="name of the exact solution expression in the ufl file")
     compare_l2errorsquared = PerftoolOption(helpstr="maximal allowed l2 error squared of difference between numerical solution and interpolation of exact solution (NOTE: requires --exact-solution-expression)")
+    grid_info = PerftoolOption(default=None, helpstr="Path to file with information about facedir and facemod variations. This can be used to limit the generation of skeleton kernels.")
     l2error_tree_path = PerftoolOption(default=None, helpstr="Tree pathes that should be considered for l2 error calculation. Default None means we take all of them into account.")
     ini_file = PerftoolOption(helpstr="An inifile to use. A generated driver will be hard-coded to it, a [formcompiler] section will be used as default values to form compiler arguments (use snake case)")
     opcounter = PerftoolOption(default=False, helpstr="Count operations. Note: In this case only operator applications are generated since solving and operator counting does not work. You probably want to set instrumentation level>0.")
@@ -80,7 +81,6 @@ class PerftoolFormOptionsArray(ImmutableRecord):
     fastdg = PerftoolOption(default=False, helpstr="Use FastDGGridOperator from PDELab.")
     sumfact = PerftoolOption(default=False, helpstr="Use sumfactorization")
     sumfact_regular_jacobians = PerftoolOption(default=False, helpstr="Generate non sum-factorized jacobians (only useful if sumfact is set)")
-    sumfact_grid_info = PerftoolOption(default=None, helpstr="Path to file with information about facedir and facemod variations. This can be used to limit the generation of skeleton kernels.")
     vectorization_quadloop = PerftoolOption(default=False, helpstr="whether to generate code with explicit vectorization")
     vectorization_strategy = PerftoolOption(default="none", helpstr="The identifier of the vectorization cost model. Possible values: none|explicit|model")
     vectorization_not_fully_vectorized_error = PerftoolOption(default=False, helpstr="throw an error if nonquadloop vectorization did not fully vectorize")
diff --git a/python/dune/perftool/sumfact/switch.py b/python/dune/perftool/sumfact/switch.py
index 5d9e971f..1528d2c9 100644
--- a/python/dune/perftool/sumfact/switch.py
+++ b/python/dune/perftool/sumfact/switch.py
@@ -57,8 +57,8 @@ def decide_if_kernel_is_necessary(facedir_s, facemod_s, facedir_n, facemod_n):
     # If we are not using YaspGrid, all variants need to be realized
     if not get_form_option("diagonal_transformation_matrix"):
         # Reduce the variability according to grid info file
-        if get_form_option("sumfact_grid_info") is not None:
-            filename = get_form_option("sumfact_grid_info")
+        if get_option("grid_info") is not None:
+            filename = get_option("grid_info")
             with open(filename) as csv_file:
                 csv_reader = csv.reader(csv_file, delimiter=" ")
                 for row in csv_reader:
diff --git a/test/sumfact/poisson/CMakeLists.txt b/test/sumfact/poisson/CMakeLists.txt
index 9dda49d7..260a5f53 100644
--- a/test/sumfact/poisson/CMakeLists.txt
+++ b/test/sumfact/poisson/CMakeLists.txt
@@ -55,10 +55,11 @@ dune_add_formcompiler_system_test(UFLFILE poisson_dg_2d.ufl
                                   INIFILE poisson_dg_2d_unstructured.mini
                                   ANALYZE_GRID
                                   )
-# dune_add_formcompiler_system_test(UFLFILE poisson_dg_3d.ufl
-#                                   BASENAME sumfact_poisson_dg_3d_unstructured
-#                                   INIFILE poisson_dg_3d_unstructured.mini
-#                                   )
+dune_add_formcompiler_system_test(UFLFILE poisson_dg_3d.ufl
+                                  BASENAME sumfact_poisson_dg_3d_unstructured
+                                  INIFILE poisson_dg_3d_unstructured.mini
+                                  ANALYZE_GRID
+                                  )
 
 
 #=============================================
-- 
GitLab