From faa8d7a37b7a09ff9da079fa324f60e22cfc1290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20He=C3=9F?= <rene.hess@iwr.uni-heidelberg.de> Date: Fri, 26 Aug 2016 10:15:26 +0200 Subject: [PATCH] Set diagonal transformatino for Yasp grids --- python/dune/perftool/options.py | 29 +++++++++++++++++++-------- python/dune/perftool/pdelab/basis.py | 6 +++--- python/dune/perftool/pdelab/driver.py | 4 ++++ 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/python/dune/perftool/options.py b/python/dune/perftool/options.py index 3af9307c..7041c587 100644 --- a/python/dune/perftool/options.py +++ b/python/dune/perftool/options.py @@ -61,18 +61,31 @@ _option_dict = {} _arguments_read = False +def init_option_dict(): + """Add form compile arguments to options dict""" + global _arguments_read + if not _arguments_read: + _option_dict.update(get_form_compiler_arguments()) + _arguments_read = True + + def set_option(key, value): + """Add the key value pair to the options. + + If the key is already in the options dictionary its value will be + overwritten. Form compiler arguments will always be set before + any other options. + + """ + # Make sure form compile arguments were read + init_option_dict() + _option_dict.update({key: value}) def get_option(key, default=None): - # If we have not yet read form compiler arguments we do that - # now. Note: If there are already entries in _option_dict with the - # same key as a form compiler argument the values will be - # overwritten here. - global _arguments_read - if not _arguments_read: - _option_dict.update(get_form_compiler_arguments()) - _arguments_read = True + """Return the value corresponding to key from option dictionary""" + # Make sure form compile arguments were read + init_option_dict() return _option_dict.get(key, default) diff --git a/python/dune/perftool/pdelab/basis.py b/python/dune/perftool/pdelab/basis.py index 71321cd7..7a1665f1 100644 --- a/python/dune/perftool/pdelab/basis.py +++ b/python/dune/perftool/pdelab/basis.py @@ -294,7 +294,7 @@ def evaluate_basis_gradient(leaf_element, name, restriction): # Evaluate product of jacobianInvereseTransposed and gradient on reference element with loopy dimindex_0 = dimension_iname(context='gradient_transformation', count=0) from dune.perftool.options import get_option - if not get_option('diagonal-transformation-matrix'): + if get_option('diagonal_transformation_matrix'): # dimindex_1 = dimension_iname(context='gradient_transformation', count=1) reduction_expr = Product(( Subscript(Variable(jac), (Variable(dimindex_0), Variable(dimindex_0))), @@ -303,9 +303,9 @@ def evaluate_basis_gradient(leaf_element, name, restriction): assignee = Subscript(Variable(name), (Variable(index), Variable(dimindex_0))) # Create exrpession instruction - forced_iname_deps = frozenset({quadrature_iname()}).union(frozenset({index})) + forced_iname_deps = frozenset({quadrature_iname()}).union(frozenset({index})).union(frozenset({dimindex_0})) instruction( - expression=Reduction("sum", dimindex_0, reduction_expr, allow_simultaneous=True), + expression=reduction_expr, assignee=assignee, forced_iname_deps=forced_iname_deps, forced_iname_deps_is_final=True) diff --git a/python/dune/perftool/pdelab/driver.py b/python/dune/perftool/pdelab/driver.py index 11c66909..bfa739b4 100644 --- a/python/dune/perftool/pdelab/driver.py +++ b/python/dune/perftool/pdelab/driver.py @@ -178,6 +178,10 @@ def name_dimension(): def typedef_grid(name): dim = name_dimension() if any(_driver_data['form'].ufl_cell().cellname() in x for x in ["vertex", "interval", "quadrilateral", "hexahedron"]): + # For Yasp Grids the jacobi of the transformation is diagonal + from dune.perftool.options import set_option + set_option('diagonal_transformation_matrix', True) + gridt = "Dune::YaspGrid<{}>".format(dim) include_file("dune/grid/yaspgrid.hh", filetag="driver") else: -- GitLab