From 8931a86bca6a1515e1f824327d6c779251abfff9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20He=C3=9F?= <rene.hess@iwr.uni-heidelberg.de>
Date: Tue, 19 Jun 2018 15:09:15 +0200
Subject: [PATCH] Make it possible to pass mutliple option statements to
 option_switch

Probably not the solution we want to have in the long run but right
now it is not possible to have a backend switch for
default/blockstructured/sumfact. This way the old code should behave
the same way as before and it is possible to switch between those
three things.
---
 python/dune/perftool/options.py         | 21 +++++++++++++--------
 python/dune/perftool/pdelab/geometry.py |  2 +-
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/python/dune/perftool/options.py b/python/dune/perftool/options.py
index a30ec5f7..96617371 100644
--- a/python/dune/perftool/options.py
+++ b/python/dune/perftool/options.py
@@ -235,14 +235,19 @@ def get_form_option(key, form=None):
 
 def option_switch(opt):
     def _switch():
+        if isinstance(opt, tuple):
+            opts = opt
+        else:
+            assert isinstance(opt, str)
+            opts = (opt,)
         try:
-            if get_option(opt):
-                return opt
-            else:
-                return "default"
+            for o in opts:
+                if get_option(o):
+                    return o
+            return "default"
         except AttributeError:
-            if get_form_option(opt):
-                return opt
-            else:
-                return "default"
+            for o in opts:
+                if get_form_option(o):
+                    return o
+            return "default"
     return _switch
diff --git a/python/dune/perftool/pdelab/geometry.py b/python/dune/perftool/pdelab/geometry.py
index d308917a..80ab0387 100644
--- a/python/dune/perftool/pdelab/geometry.py
+++ b/python/dune/perftool/pdelab/geometry.py
@@ -338,7 +338,7 @@ def define_jacobian_inverse_transposed(name, restriction):
     dim = world_dimension()
     temporary_variable(name, decl_method=define_jacobian_inverse_transposed_temporary(restriction), shape=(dim, dim))
     geo = name_cell_geometry(restriction)
-    pos = get_backend("qp_in_cell", selector=option_switch("blockstructured"))(restriction)
+    pos = get_backend("qp_in_cell", selector=option_switch(("blockstructured", "sumfact")))(restriction)
     return quadrature_preamble("{} = {}.jacobianInverseTransposed({});".format(name,
                                                                                geo,
                                                                                str(pos),
-- 
GitLab