From c3fd84937f569a917cf172583d5c7949ac996cad Mon Sep 17 00:00:00 2001
From: Dominic Kempf <dominic.kempf@iwr.uni-heidelberg.de>
Date: Tue, 10 May 2016 18:13:53 +0200
Subject: [PATCH] Rip out horrible thing to determine bounds

---
 python/dune/perftool/loopy/transformer.py |  9 +++---
 python/dune/perftool/ufl/shape.py         | 37 -----------------------
 2 files changed, 4 insertions(+), 42 deletions(-)
 delete mode 100644 python/dune/perftool/ufl/shape.py

diff --git a/python/dune/perftool/loopy/transformer.py b/python/dune/perftool/loopy/transformer.py
index d5efa83b..63025911 100644
--- a/python/dune/perftool/loopy/transformer.py
+++ b/python/dune/perftool/loopy/transformer.py
@@ -184,18 +184,17 @@ class UFL2LoopyVisitor(ModifiedTerminalTracker, UFL2PymbolicMapper, GeometryMapp
 
     def index_sum(self, o):
         from loopy import Reduction
-        from dune.perftool.ufl.shape import determine_shape
 
         oldinames = self.inames
         self.inames = []
 
         red_inames = ()
         # Define an iname for each of the indices in the multiindex
-        for i in o.ufl_operands[1].indices():
-            red_inames = red_inames + (index_sum_iname(i),)
-            shape = determine_shape(o.ufl_operands[0], i)
+        for i, ind in enumerate(o.ufl_operands[1].indices()):
+            red_inames = red_inames + (index_sum_iname(ind),)
+            shape = o.ufl_operands[0].ufl_index_dimensions[i]
             from dune.perftool.pdelab import name_index
-            domain(name_index(i), shape)
+            domain(name_index(ind), shape)
 
         # Recurse to get the summation expression
         term = self.call(o.ufl_operands[0])
diff --git a/python/dune/perftool/ufl/shape.py b/python/dune/perftool/ufl/shape.py
deleted file mode 100644
index bc9e5bdb..00000000
--- a/python/dune/perftool/ufl/shape.py
+++ /dev/null
@@ -1,37 +0,0 @@
-""" An algorithm to determine the shape aka the loop domain for a given index """
-
-from ufl.algorithms import MultiFunction
-
-
-class ShapeDetermination(MultiFunction):
-    def __init__(self, index):
-        MultiFunction.__init__(self)
-        self.index = index
-
-    def expr(self, o):
-        ret = tuple(self(op) for op in o.ufl_operands)
-        asset = set(ret)
-        if len(asset) == 0:
-            return None
-        if len(asset) == 1:
-            # All determined shapes are equal. We just use the result.
-            return ret[0]
-        if len(asset) == 2:
-            try:
-                # Two shapes determined, one might be "None" so we use the other.
-                asset.remove(None)
-                return ret[0]
-            except KeyError:
-                pass
-        raise AssertionError("I had trouble determining the shape of an expression!")
-
-    def indexed(self, o):
-        try:
-            position = o.ufl_operands[1].indices().index(self.index)
-            return o.ufl_operands[0].ufl_shape[position]
-        except ValueError:
-            return self(o.ufl_operands[0])
-
-
-def determine_shape(expr, i):
-    return ShapeDetermination(i)(expr)
-- 
GitLab