From fb64c1688b21295f333d5c15d35ae7371e02a5d8 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, 6 Jun 2017 13:26:43 +0200
Subject: [PATCH] Rename dimension_index to component_index

---
 python/dune/perftool/pdelab/__init__.py       |  6 ++--
 python/dune/perftool/pdelab/basis.py          |  6 ++--
 python/dune/perftool/pdelab/geometry.py       |  6 ++--
 python/dune/perftool/pdelab/localoperator.py  | 12 +++----
 python/dune/perftool/sumfact/accumulation.py  | 32 +++++++++----------
 python/dune/perftool/sumfact/quadrature.py    |  3 +-
 .../{dimensionindex.py => componentindex.py}  | 16 +++++-----
 python/dune/perftool/ufl/visitor.py           | 18 +++++------
 8 files changed, 49 insertions(+), 50 deletions(-)
 rename python/dune/perftool/ufl/{dimensionindex.py => componentindex.py} (65%)

diff --git a/python/dune/perftool/pdelab/__init__.py b/python/dune/perftool/pdelab/__init__.py
index 10d2b951..33571d68 100644
--- a/python/dune/perftool/pdelab/__init__.py
+++ b/python/dune/perftool/pdelab/__init__.py
@@ -10,7 +10,7 @@ from dune.perftool.pdelab.argument import (pymbolic_apply_function,
 from dune.perftool.pdelab.basis import (pymbolic_basis,
                                         pymbolic_reference_gradient,
                                         )
-from dune.perftool.pdelab.geometry import (dimension_iname,
+from dune.perftool.pdelab.geometry import (component_iname,
                                            name_cell_volume,
                                            name_facet_area,
                                            name_facet_jacobian_determinant,
@@ -44,8 +44,8 @@ class PDELabInterface(object):
     # They should be placed elsewhere and be used directly in the visitor.
     #
 
-    def dimension_iname(self, context=None, count=None):
-        return dimension_iname(context=context, count=count)
+    def component_iname(self, context=None, count=None):
+        return component_iname(context=context, count=count)
 
     def name_index(self, ind):
         return name_index(ind)
diff --git a/python/dune/perftool/pdelab/basis.py b/python/dune/perftool/pdelab/basis.py
index 25438f7e..f79f4df9 100644
--- a/python/dune/perftool/pdelab/basis.py
+++ b/python/dune/perftool/pdelab/basis.py
@@ -18,7 +18,7 @@ from dune.perftool.pdelab.spaces import (lfs_child,
                                          name_lfs_bound,
                                          type_gfs,
                                          )
-from dune.perftool.pdelab.geometry import (dimension_iname,
+from dune.perftool.pdelab.geometry import (component_iname,
                                            world_dimension,
                                            name_jacobian_inverse_transposed,
                                            to_cell_coordinates,
@@ -139,7 +139,7 @@ def evaluate_coefficient(element, name, container, restriction, tree_path):
 
     shape = sub_element.value_shape()
     shape_impl = ('arr', ) * rank
-    idims = tuple(dimension_iname(count=i) for i in range(rank))
+    idims = tuple(component_iname(count=i) for i in range(rank))
     leaf_element = sub_element
     from ufl import VectorElement, TensorElement
     if isinstance(sub_element, (VectorElement, TensorElement)):
@@ -176,7 +176,7 @@ def evaluate_coefficient_gradient(element, name, container, restriction, tree_pa
     shape = sub_element.value_shape() + (element.cell().geometric_dimension(),)
     shape_impl = ('arr',) * rank
 
-    idims = tuple(dimension_iname(count=i) for i in range(rank))
+    idims = tuple(component_iname(count=i) for i in range(rank))
     leaf_element = sub_element
     from ufl import VectorElement, TensorElement
     if isinstance(sub_element, (VectorElement, TensorElement)):
diff --git a/python/dune/perftool/pdelab/geometry.py b/python/dune/perftool/pdelab/geometry.py
index 58122feb..65f40a10 100644
--- a/python/dune/perftool/pdelab/geometry.py
+++ b/python/dune/perftool/pdelab/geometry.py
@@ -54,7 +54,7 @@ def name_localcenter():
 
 
 @iname
-def _dimension_iname(context, count):
+def _component_iname(context, count):
     if context:
         context = '_' + context
     name = 'idim{}{}'.format(context, str(count))
@@ -64,8 +64,8 @@ def _dimension_iname(context, count):
     return name
 
 
-def dimension_iname(context='', count=0):
-    return _dimension_iname(context, count)
+def component_iname(context='', count=0):
+    return _component_iname(context, count)
 
 
 def name_element_geometry_wrapper():
diff --git a/python/dune/perftool/pdelab/localoperator.py b/python/dune/perftool/pdelab/localoperator.py
index b821173d..1e213f00 100644
--- a/python/dune/perftool/pdelab/localoperator.py
+++ b/python/dune/perftool/pdelab/localoperator.py
@@ -236,9 +236,9 @@ def determine_accumulation_space(expr, number, measure, idims=None):
     valuearg(lfs, dtype=NumpyType("str"))
 
     if len(subel.value_shape()) != 0:
-        from dune.perftool.pdelab.geometry import dimension_iname
+        from dune.perftool.pdelab.geometry import component_iname
         if idims is None:
-            idims = tuple(dimension_iname(context='arg', count=i) for i in range(len(subel.value_shape())))
+            idims = tuple(component_iname(context='arg', count=i) for i in range(len(subel.value_shape())))
         lfs = lfs_child(lfs, idims, shape=subel.value_shape(), symmetry=subel.symmetry())
         subel = subel.sub_elements()[0]
 
@@ -392,12 +392,12 @@ def visit_integrals(integrals):
 
         # Iterate over the terms and generate a kernel
         for accterm in accterms:
-            # Get dimension indices
+            # Get component indices
             indexmap = {}
-            from dune.perftool.ufl.dimensionindex import dimension_index_mapping
+            from dune.perftool.ufl.componentindex import component_index_mapping
             if accterm.argument.expr is not None:
-                indexmap.update(dimension_index_mapping(accterm.indexed_test_arg()))
-            indexmap.update(dimension_index_mapping(accterm.term))
+                indexmap.update(component_index_mapping(accterm.indexed_test_arg()))
+            indexmap.update(component_index_mapping(accterm.term))
 
             # Get a transformer instance for this kernel
             if get_option('sumfact'):
diff --git a/python/dune/perftool/sumfact/accumulation.py b/python/dune/perftool/sumfact/accumulation.py
index 2e3996f6..c10cbd19 100644
--- a/python/dune/perftool/sumfact/accumulation.py
+++ b/python/dune/perftool/sumfact/accumulation.py
@@ -75,35 +75,35 @@ class AlreadyAssembledInput(SumfactKernelInputBase):
         return hash(self.index)
 
 
-def _dimension_gradient_indices(argument):
-    """Return dimension and gradient index of test function argument
+def _component_gradient_indices(argument):
+    """Return component and gradient index of test function argument
 
-    Dimension index corresponds to the dimensio for vector valued
-    functions (eg v in Stokes). The gradient index is the direction of
-    the derivative (eg in \Delat u in poisson or \grad u in Stoks).
+    The component_index is the component of vector valued functions
+    (eg v in Stokes). The gradient index is the direction of the
+    derivative (eg in \Delat u in poisson or \grad u in Stoks).
     """
     grad_index = None
-    dimension_index = None
+    component_index = None
 
     # If this is a gradient the last index is the grad_index
     if argument.reference_grad:
         grad_index = argument.expr.ufl_operands[1][-1]._value
 
-    # If this argument has indices there could be a dimension_index
+    # If this argument has indices there could be a component_index
     if isinstance(argument.expr, uc.Indexed):
         # More than two indices not supported
         if len(argument.expr.ufl_operands[1]) > 2:
             assert False
-        # For two indices the first is the dimension index
+        # For two indices the first is the component_index
         if len(argument.expr.ufl_operands[1]) == 2:
             assert grad_index is not None
-            dimension_index = argument.expr.ufl_operands[1].indices()[0]._value
-        # For there is no gradient index we should have only one index, the dimension index
+            component_index = argument.expr.ufl_operands[1].indices()[0]._value
+        # For there is no gradient index we should have only one index, the component_index
         if not argument.reference_grad:
             assert len(argument.expr.ufl_operands[1]) == 1
-            dimension_index = argument.expr.ufl_operands[1].indices()[0]._value
+            component_index = argument.expr.ufl_operands[1].indices()[0]._value
 
-    return dimension_index, grad_index
+    return component_index, grad_index
 
 
 @backend(interface="accum_insn", name="sumfact")
@@ -111,9 +111,9 @@ def generate_accumulation_instruction(visitor, accterm, measure, subdomain_id):
     # When doing sum factorization we want to split the test function
     assert(accterm.argument.expr is not None)
 
-    # Get dimension and gradient index
-    dimension_index, grad_index = _dimension_gradient_indices(accterm.argument)
-    accum_index = (dimension_index,)
+    # Get component and gradient index
+    component_index, grad_index = _component_gradient_indices(accterm.argument)
+    accum_index = (component_index,)
 
     # Do the tree traversal to get a pymbolic expression representing this expression
     pymbolic_expr = visitor(accterm.term)
@@ -158,7 +158,7 @@ def generate_accumulation_instruction(visitor, accterm, measure, subdomain_id):
                            accumvar=accum,
                            within_inames=jacobian_inames,
                            input=AlreadyAssembledInput(index=accum_index),
-                           coeff_func_index=dimension_index,
+                           coeff_func_index=component_index,
                            )
 
         from dune.perftool.sumfact.vectorization import attach_vectorization_info
diff --git a/python/dune/perftool/sumfact/quadrature.py b/python/dune/perftool/sumfact/quadrature.py
index b86f7751..36bac3e2 100644
--- a/python/dune/perftool/sumfact/quadrature.py
+++ b/python/dune/perftool/sumfact/quadrature.py
@@ -14,8 +14,7 @@ from dune.perftool.sumfact.tabulation import (quadrature_points_per_direction,
                                               name_oned_quadrature_weights,
                                               )
 from dune.perftool.pdelab.argument import name_accumulation_variable
-from dune.perftool.pdelab.geometry import (dimension_iname,
-                                           local_dimension,
+from dune.perftool.pdelab.geometry import (local_dimension,
                                            )
 from dune.perftool.options import get_option
 
diff --git a/python/dune/perftool/ufl/dimensionindex.py b/python/dune/perftool/ufl/componentindex.py
similarity index 65%
rename from python/dune/perftool/ufl/dimensionindex.py
rename to python/dune/perftool/ufl/componentindex.py
index 6aebaf42..4c4ebea6 100644
--- a/python/dune/perftool/ufl/dimensionindex.py
+++ b/python/dune/perftool/ufl/componentindex.py
@@ -1,18 +1,18 @@
-""" Extract all the aliases of dimension indices """
+""" Extract all the aliases of component indices """
 
 from ufl.algorithms import MultiFunction
 
 
-class _DimensionIndexMapping(MultiFunction):
+class _ComponentIndexMapping(MultiFunction):
     call = MultiFunction.__call__
 
     def __call__(self, o):
         self.shape = 0
-        self.dimension_index_dict = {}
+        self.component_index_dict = {}
         self.tree_path = None
         self.call(o)
 
-        return self.dimension_index_dict
+        return self.component_index_dict
 
     def expr(self, o):
         for op in o.ufl_operands:
@@ -32,10 +32,10 @@ class _DimensionIndexMapping(MultiFunction):
     def indexed(self, o):
         self.call(o.ufl_operands[0])
         for i in range(self.shape):
-            from dune.perftool.pdelab.geometry import dimension_iname
-            self.dimension_index_dict[o.ufl_operands[1][i]] = dimension_iname(context='arg', count=i)
+            from dune.perftool.pdelab.geometry import component_iname
+            self.component_index_dict[o.ufl_operands[1][i]] = component_iname(context='arg', count=i)
         self.shape = 0
 
 
-def dimension_index_mapping(expr):
-    return _DimensionIndexMapping()(expr)
+def component_index_mapping(expr):
+    return _ComponentIndexMapping()(expr)
diff --git a/python/dune/perftool/ufl/visitor.py b/python/dune/perftool/ufl/visitor.py
index e12d7704..e1769ae2 100644
--- a/python/dune/perftool/ufl/visitor.py
+++ b/python/dune/perftool/ufl/visitor.py
@@ -35,11 +35,11 @@ import pymbolic.primitives as prim
 
 
 class UFL2LoopyVisitor(ModifiedTerminalTracker):
-    def __init__(self, interface, measure, dimension_indices):
+    def __init__(self, interface, measure, component_indices):
         self.interface = interface
         self.interface.visitor = self
         self.measure = measure
-        self.dimension_indices = dimension_indices
+        self.component_indices = component_indices
 
         # Call base class constructors
         super(UFL2LoopyVisitor, self).__init__()
@@ -78,8 +78,8 @@ class UFL2LoopyVisitor(ModifiedTerminalTracker):
             shape = len(element.value_shape())
             self.indices = self.indices[shape:]
             for i in range(len(element.value_shape())):
-                if self.interface.dimension_iname(context='arg', count=i) not in self.inames:
-                    self.inames = self.inames + (self.interface.dimension_iname(context='arg', count=i),)
+                if self.interface.component_iname(context='arg', count=i) not in self.inames:
+                    self.inames = self.inames + (self.interface.component_iname(context='arg', count=i),)
 
             # For the purpose of basis evaluation, we need to take the leaf element
             leaf_element = element.sub_elements()[0]
@@ -185,7 +185,7 @@ class UFL2LoopyVisitor(ModifiedTerminalTracker):
         else:
             # Recurse to get the summation expression
             term = self.call(o.ufl_operands[0])
-            redinames = tuple(i for i in redinames if i not in self.dimension_indices)
+            redinames = tuple(i for i in redinames if i not in self.component_indices)
             if len(redinames) > 0:
                 ret = Reduction("sum", tuple(self.interface.name_index(ind) for ind in redinames), term)
             else:
@@ -197,10 +197,10 @@ class UFL2LoopyVisitor(ModifiedTerminalTracker):
         if isinstance(index, FixedIndex):
             return index._value
         else:
-            if index in self.dimension_indices:
-                if self.dimension_indices[index] not in self.inames:
-                    self.inames = self.inames + (self.dimension_indices[index],)
-                return Variable(self.dimension_indices[index])
+            if index in self.component_indices:
+                if self.component_indices[index] not in self.inames:
+                    self.inames = self.inames + (self.component_indices[index],)
+                return Variable(self.component_indices[index])
             else:
                 return Variable(self.interface.name_index(index))
 
-- 
GitLab