From d94aab54aa849e8c88c90bc2a3ce68b87479fd7c Mon Sep 17 00:00:00 2001
From: Dominic Kempf <dominic.kempf@iwr.uni-heidelberg.de>
Date: Thu, 24 Aug 2017 14:31:00 +0200
Subject: [PATCH] Allow conditionals choosing between tensors

The indexing information needs to be stored and reset
for visiting of the second branch.
---
 python/dune/perftool/ufl/visitor.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/python/dune/perftool/ufl/visitor.py b/python/dune/perftool/ufl/visitor.py
index 8773efff..2ac22c3e 100644
--- a/python/dune/perftool/ufl/visitor.py
+++ b/python/dune/perftool/ufl/visitor.py
@@ -325,7 +325,15 @@ class UFL2LoopyVisitor(ModifiedTerminalTracker):
     #
 
     def conditional(self, o):
-        return prim.If(*tuple(self.call(op) for op in o.ufl_operands))
+        condition = self.call(o.ufl_operands[0])
+        indices = self.indices
+
+        op1 = self.call(o.ufl_operands[1])
+        # Restore indexing information for the second branch
+        self.indices = indices
+        op2 = self.call(o.ufl_operands[2])
+
+        return prim.If(condition, op1, op2)
 
     def eq(self, o):
         return prim.Comparison(self.call(o.ufl_operands[0]),
-- 
GitLab