From 6b37b34ecac0bcf1eddd91daa62a79da89f81b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20He=C3=9F?= <rene.hess@iwr.uni-heidelberg.de> Date: Wed, 29 Mar 2017 09:07:27 +0200 Subject: [PATCH] Small cleanup --- python/dune/perftool/pdelab/__init__.py | 4 ++-- python/dune/perftool/pdelab/geometry.py | 6 +----- python/dune/perftool/pdelab/tensors.py | 8 ++++---- python/dune/perftool/ufl/extract_accumulation_terms.py | 2 +- python/dune/perftool/ufl/transformations/axiparallel.py | 2 +- python/dune/perftool/ufl/visitor.py | 6 +++--- 6 files changed, 12 insertions(+), 16 deletions(-) diff --git a/python/dune/perftool/pdelab/__init__.py b/python/dune/perftool/pdelab/__init__.py index 3d3f3f99..4afe9a97 100644 --- a/python/dune/perftool/pdelab/__init__.py +++ b/python/dune/perftool/pdelab/__init__.py @@ -92,8 +92,8 @@ class PDELabInterface(object): def pymbolic_list_tensor(self, o, visitor): return pymbolic_list_tensor(o, visitor) - def pymbolic_identity(self, o, visitor): - return pymbolic_identity(o, visitor) + def pymbolic_identity(self, o): + return pymbolic_identity(o) # # Geometry related generator functions diff --git a/python/dune/perftool/pdelab/geometry.py b/python/dune/perftool/pdelab/geometry.py index bb50344c..9da0f1ee 100644 --- a/python/dune/perftool/pdelab/geometry.py +++ b/python/dune/perftool/pdelab/geometry.py @@ -320,11 +320,7 @@ def define_constant_jacobian_inveser_transposed(name, restriction): globalarg(name, dtype=np.float64, shape=(dim, dim), managed=False) - if get_option('turn_off_diagonal_jacobian'): - jit_type = 'Dune::FieldMatrix<double,{},{}>'.format(dim,dim) - else: - jit_type = 'auto' - + jit_type = type_jacobian_inverse_transposed(restriction) return '{} {} = {}.jacobianInverseTransposed({});'.format(jit_type, name, geo, diff --git a/python/dune/perftool/pdelab/tensors.py b/python/dune/perftool/pdelab/tensors.py index 6c7e4fc5..aa154bdb 100644 --- a/python/dune/perftool/pdelab/tensors.py +++ b/python/dune/perftool/pdelab/tensors.py @@ -44,7 +44,7 @@ def identity_iname(name, bound): return name -def define_identity(name, expr, visitor): +def define_identity(name, expr): i = identity_iname("i", expr.ufl_shape[0]) j = identity_iname("j", expr.ufl_shape[1]) instruction(assignee=prim.Subscript(prim.Variable(name), (prim.Variable(i), prim.Variable(j))), @@ -54,12 +54,12 @@ def define_identity(name, expr, visitor): @kernel_cached -def pymbolic_identity(expr, visitor): - name = get_counted_variable("identity") +def pymbolic_identity(expr): + name = "identity_{}_{}".format(expr.ufl_shape[0],expr.ufl_shape[1]) temporary_variable(name, shape=expr.ufl_shape, shape_impl=('fm',), dtype=np.float64, ) - define_identity(name, expr, visitor) + define_identity(name, expr) return prim.Variable(name) diff --git a/python/dune/perftool/ufl/extract_accumulation_terms.py b/python/dune/perftool/ufl/extract_accumulation_terms.py index d1615aca..4dbebbb8 100644 --- a/python/dune/perftool/ufl/extract_accumulation_terms.py +++ b/python/dune/perftool/ufl/extract_accumulation_terms.py @@ -136,7 +136,7 @@ def split_into_accumulation_terms(expr): # - Replacing (\nabla v)_{k,l} by I_{k,l} after step 4. if len(set(indexed_test_arg.index._indices)) < len(indexed_test_arg.index._indices): if len(indexed_test_arg.index._indices)>2: - raise NotImplementedError("Test argument with more than three indices and double occurence ist not implemted.") + raise NotImplementedError("Test argument with more than three indices and double occurence ist not implemented.") mod_index_map = {indexed_test_arg.index: MultiIndex((newi[0], newi[1]))} mod_indexed_test_arg = replace_expression(indexed_test_arg.expr, replacemap = mod_index_map) diff --git a/python/dune/perftool/ufl/transformations/axiparallel.py b/python/dune/perftool/ufl/transformations/axiparallel.py index cd187da2..6d7e53e4 100644 --- a/python/dune/perftool/ufl/transformations/axiparallel.py +++ b/python/dune/perftool/ufl/transformations/axiparallel.py @@ -43,7 +43,7 @@ class LocalDiagonalJITReplacer(MultiFunction): return MultiIndex(tuple(self.local_replacemap.get(i, i) for i in o)) def indexed(self, o): - if self.local_replacemap!={}: + if self.local_replacemap: if isinstance(o.ufl_operands[1], MultiIndex): return self.reuse_if_untouched(o, *tuple(self.call(op) for op in o.ufl_operands)) else: diff --git a/python/dune/perftool/ufl/visitor.py b/python/dune/perftool/ufl/visitor.py index a5cf1a9d..711f92bf 100644 --- a/python/dune/perftool/ufl/visitor.py +++ b/python/dune/perftool/ufl/visitor.py @@ -229,14 +229,14 @@ class UFL2LoopyVisitor(ModifiedTerminalTracker): def list_tensor(self, o): return self.interface.pymbolic_list_tensor(o, self) + def identity(self, o): + return self.interface.pymbolic_identity(o) + # # Handlers for arithmetic operators and functions # Those handlers would be valid in any code going from UFL to pymbolic # - def identity(self, o): - return self.interface.pymbolic_identity(o, self) - def product(self, o): return Product(tuple(self.call(op) for op in o.ufl_operands)) -- GitLab