From 93fc9070a2d7ac05ffdb2277167aa6bb7632dbce Mon Sep 17 00:00:00 2001
From: Marcel Koch <marcel.koch@uni-muenster.de>
Date: Wed, 24 Oct 2018 17:16:37 +0200
Subject: [PATCH] adds to_global for unstructured 2d grids

---
 .../dune/perftool/blockstructured/geometry.py | 32 +++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/python/dune/perftool/blockstructured/geometry.py b/python/dune/perftool/blockstructured/geometry.py
index 31f5ac01..ce77c3d0 100644
--- a/python/dune/perftool/blockstructured/geometry.py
+++ b/python/dune/perftool/blockstructured/geometry.py
@@ -312,6 +312,35 @@ def name_point_in_macro(point_in_micro):
     return name
 
 
+def apply_default_to_global_transformation(name, local):
+    dim = world_dimension()
+    temporary_variable(name, shape=(dim,), managed=True)
+    corners = name_element_corners()
+
+    if isinstance(local, str):
+        local = prim.Variable(local)
+
+    d_var = prim.Variable(component_iname('to_global'))
+
+    coeffs = bilinear_transformation_coefficients()
+
+    # global[d] = T(local)[d]
+    if dim == 2:
+        a_var, b_var, c_var = [prim.Variable(coeff) for coeff in coeffs]
+        expr = (prim.Subscript(a_var, (d_var)) * prim.Subscript(local, (0,)) * prim.Subscript(local, (1,)) +
+                prim.Subscript(b_var, (d_var,)) * prim.Subscript(local, (0,)) +
+                prim.Subscript(c_var, (d_var,)) * prim.Subscript(local, (1,)) +
+                prim.Subscript(prim.Variable(corners), (0, d_var)))
+
+    assignee = prim.Subscript(prim.Variable(name), (d_var,))
+
+    instruction(assignee=assignee, expression=expr,
+                within_inames=frozenset(sub_element_inames() + get_backend(interface="quad_inames")() + (d_var.name,)),
+                within_inames_is_final=True,
+                depends_on=frozenset({Writes(local.name), Writes(corners)})
+                )
+
+
 def apply_constant_to_global_transformation(name, local):
     dim = world_dimension()
     temporary_variable(name, shape=(dim,), managed=True)
@@ -344,6 +373,5 @@ def to_global(local):
     if get_form_option("constant_transformation_matrix"):
         apply_constant_to_global_transformation(name, prim.Variable(macro))
     else:
-        from dune.perftool.pdelab.geometry import apply_to_global_transformation
-        apply_to_global_transformation(name, prim.Variable(macro))
+        apply_default_to_global_transformation(name, prim.Variable(macro))
     return prim.Variable(name)
-- 
GitLab