From 1b8b0b0e078e6cfc5cf0bcc996741724d275da16 Mon Sep 17 00:00:00 2001
From: Dominic Kempf <dominic.kempf@iwr.uni-heidelberg.de>
Date: Wed, 26 Oct 2016 13:05:28 +0200
Subject: [PATCH] Generate pymbolic for trial functions instead of just a name

In sum factorization we will have different temporary shape and access.
---
 python/dune/perftool/pdelab/__init__.py | 24 ++++++++++++------------
 python/dune/perftool/pdelab/argument.py | 21 ++++++++++-----------
 python/dune/perftool/ufl/visitor.py     |  8 ++++----
 3 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/python/dune/perftool/pdelab/__init__.py b/python/dune/perftool/pdelab/__init__.py
index f994193a..76aaff91 100644
--- a/python/dune/perftool/pdelab/__init__.py
+++ b/python/dune/perftool/pdelab/__init__.py
@@ -2,10 +2,10 @@
 
 # Trigger some imports that are needed to have all backend implementations visible
 # to the selection mechanisms
-from dune.perftool.pdelab.argument import (name_apply_function,
-                                           name_apply_function_gradient,
-                                           name_trialfunction,
-                                           name_trialfunction_gradient,
+from dune.perftool.pdelab.argument import (pymbolic_apply_function,
+                                           pymbolic_apply_function_gradient,
+                                           pymbolic_trialfunction,
+                                           pymbolic_trialfunction_gradient,
                                            )
 from dune.perftool.pdelab.basis import (name_basis,
                                         name_reference_gradient,
@@ -57,17 +57,17 @@ class PDELabInterface(object):
     def name_reference_gradient(self, element, restriction):
         return name_reference_gradient(element, restriction)
 
-    def name_trialfunction_gradient(self, element, restriction, component):
-        return name_trialfunction_gradient(element, restriction, component)
+    def pymbolic_trialfunction_gradient(self, element, restriction, component):
+        return pymbolic_trialfunction_gradient(element, restriction, component)
 
-    def name_apply_function_gradient(self, element, restriction, component):
-        return name_apply_function_gradient(element, restriction, component)
+    def pymbolic_apply_function_gradient(self, element, restriction, component):
+        return pymbolic_apply_function_gradient(element, restriction, component)
 
-    def name_trialfunction(self, element, restriction, component):
-        return name_trialfunction(element, restriction, component)
+    def pymbolic_trialfunction(self, element, restriction, component):
+        return pymbolic_trialfunction(element, restriction, component)
 
-    def name_apply_function(self, element, restriction, component):
-        return name_apply_function(element, restriction, component)
+    def pymbolic_apply_function(self, element, restriction, component):
+        return pymbolic_apply_function(element, restriction, component)
 
     #
     # Parameter function related generator functions
diff --git a/python/dune/perftool/pdelab/argument.py b/python/dune/perftool/pdelab/argument.py
index b727f373..afcb0e95 100644
--- a/python/dune/perftool/pdelab/argument.py
+++ b/python/dune/perftool/pdelab/argument.py
@@ -9,7 +9,6 @@ from dune.perftool.options import get_option
 from dune.perftool.generation import (cached,
                                       domain,
                                       function_mangler,
-                                      get_backend,
                                       iname,
                                       globalarg,
                                       valuearg,
@@ -91,36 +90,36 @@ def accumulation_mangler(target, func, dtypes):
                                   )
 
 
-def name_trialfunction_gradient(element, restriction, component):
+def pymbolic_trialfunction_gradient(element, restriction, component):
     rawname = "gradu" + "_".join(str(c) for c in component)
     name = restricted_name(rawname, restriction)
     container = name_coefficientcontainer(restriction)
     evaluate_coefficient_gradient(element, name, container, restriction, component)
-    return name
+    return Variable(name)
 
 
-def name_trialfunction(element, restriction, component):
+def pymbolic_trialfunction(element, restriction, component):
     rawname = "u" + "_".join(str(c) for c in component)
     name = restricted_name(rawname, restriction)
     container = name_coefficientcontainer(restriction)
-    get_backend("eval_coefficient")(element, name, container, restriction, component)
-    return name
+    evaluate_coefficient(element, name, container, restriction, component)
+    return Variable(name)
 
 
-def name_apply_function_gradient(element, restriction, component):
+def pymbolic_apply_function_gradient(element, restriction, component):
     rawname = "gradz_func" + "_".join(str(c) for c in component)
     name = restricted_name(rawname, restriction)
     container = name_applycontainer(restriction)
     evaluate_coefficient_gradient(element, name, container, restriction, component)
-    return name
+    return Variable(name)
 
 
-def name_apply_function(element, restriction, component):
+def pymbolic_apply_function(element, restriction, component):
     rawname = "z_func" + "_".join(str(c) for c in component)
     name = restricted_name(rawname, restriction)
     container = name_applycontainer(restriction)
-    get_backend("eval_coefficient")(element, name, container, restriction, component)
-    return name
+    evaluate_coefficient(element, name, container, restriction, component)
+    return Variable(name)
 
 
 def name_coefficientcontainer(restriction):
diff --git a/python/dune/perftool/ufl/visitor.py b/python/dune/perftool/ufl/visitor.py
index 898a7b46..d87c5dcf 100644
--- a/python/dune/perftool/ufl/visitor.py
+++ b/python/dune/perftool/ufl/visitor.py
@@ -110,14 +110,14 @@ class UFL2LoopyVisitor(ModifiedTerminalTracker):
 
             if self.reference_grad:
                 if o.count() == 0:
-                    return Variable(self.interface.name_trialfunction_gradient(o.ufl_element(), restriction, self.component))
+                    return self.interface.pymbolic_trialfunction_gradient(o.ufl_element(), restriction, self.component)
                 else:
-                    return Variable(self.interface.name_apply_function_gradient(o.ufl_element(), restriction, self.component))
+                    return self.interface.pymbolic_apply_function_gradient(o.ufl_element(), restriction, self.component)
             else:
                 if o.count() == 0:
-                    return Variable(self.interface.name_trialfunction(o.ufl_element(), restriction, self.component))
+                    return self.interface.pymbolic_trialfunction(o.ufl_element(), restriction, self.component)
                 else:
-                    return Variable(self.interface.name_apply_function(o.ufl_element(), restriction, self.component))
+                    return self.interface.pymbolic_apply_function(o.ufl_element(), restriction, self.component)
 
         # Check if this is a parameter function
         else:
-- 
GitLab