From b22d57e6a8a3734fd811185e5ccecf8693d794e4 Mon Sep 17 00:00:00 2001 From: Marcel Koch <marcel.koch@uni-muenster.de> Date: Fri, 14 Jul 2017 17:18:41 +0200 Subject: [PATCH] Corrects boundary kernel for blockstructuring --- .../dune/perftool/blockstructured/__init__.py | 4 ++++ .../dune/perftool/blockstructured/geometry.py | 18 +++++++++++------- python/dune/perftool/blockstructured/spaces.py | 3 ++- python/dune/perftool/blockstructured/tools.py | 15 ++++++++------- python/dune/perftool/pdelab/__init__.py | 6 +++--- python/dune/perftool/pdelab/geometry.py | 5 +++++ python/dune/perftool/ufl/visitor.py | 2 +- 7 files changed, 34 insertions(+), 19 deletions(-) diff --git a/python/dune/perftool/blockstructured/__init__.py b/python/dune/perftool/blockstructured/__init__.py index 7c8ce39a..2fad02ff 100644 --- a/python/dune/perftool/blockstructured/__init__.py +++ b/python/dune/perftool/blockstructured/__init__.py @@ -8,6 +8,7 @@ from dune.perftool.blockstructured.spaces import lfs_inames from dune.perftool.blockstructured.quadrature import pymbolic_quadrature_position from dune.perftool.blockstructured.geometry import (pymbolic_jacobian_inverse_transposed, pymbolic_jacobian_determinant, + pymbolic_facet_jacobian_determinant, to_global) from dune.perftool.pdelab import PDELabInterface @@ -37,3 +38,6 @@ class BlockStructuredInterface(PDELabInterface): def pymbolic_jacobian_inverse_transposed(self, i, j, restriction): return pymbolic_jacobian_inverse_transposed(i,j,restriction) + + def pymbolic_facet_jacobian_determinant(self): + return pymbolic_facet_jacobian_determinant() diff --git a/python/dune/perftool/blockstructured/geometry.py b/python/dune/perftool/blockstructured/geometry.py index 7c2ef32b..8c5fcfed 100644 --- a/python/dune/perftool/blockstructured/geometry.py +++ b/python/dune/perftool/blockstructured/geometry.py @@ -3,21 +3,19 @@ from dune.perftool.generation import (backend, instruction) from dune.perftool.tools import get_pymbolic_basename from dune.perftool.options import get_option -from dune.perftool.pdelab.quadrature import quadrature_preamble from dune.perftool.pdelab.geometry import (name_jacobian_determinant, name_jacobian_inverse_transposed, - world_dimension, - name_geometry, - apply_to_global_transformation) + local_dimension, + apply_to_global_transformation, + name_facet_jacobian_determinant) from dune.perftool.blockstructured.tools import sub_element_inames -from loopy.match import Writes import pymbolic.primitives as prim @backend(interface="pymbolic_jacobian_determinant", name="blockstructured") def pymbolic_jacobian_determinant(): return prim.Quotient(prim.Variable(name_jacobian_determinant()), - prim.Power(get_option("number_of_blocks"),2)) + prim.Power(get_option("number_of_blocks"),local_dimension())) @backend(interface="pymbolic_jacobian_inverse_transposed", name="blockstructured") @@ -26,8 +24,14 @@ def pymbolic_jacobian_inverse_transposed(i,j,restriction): prim.Subscript(prim.Variable(name_jacobian_inverse_transposed(restriction)), (j, i)))) +@backend(interface="pymbolic_facet_jacobian_determinant", name="blockstructured") +def pymbolic_facet_jacobian_determinant(): + return prim.Quotient(prim.Variable(name_facet_jacobian_determinant()), + prim.Power(get_option("number_of_blocks"),local_dimension())) + + def define_point_in_macro(name, point_in_micro): - dim = world_dimension() + dim = local_dimension() temporary_variable(name, shape_impl=('fv',), shape=(dim,)) subelem_inames = sub_element_inames() diff --git a/python/dune/perftool/blockstructured/spaces.py b/python/dune/perftool/blockstructured/spaces.py index 6079d75c..c7537358 100644 --- a/python/dune/perftool/blockstructured/spaces.py +++ b/python/dune/perftool/blockstructured/spaces.py @@ -1,5 +1,6 @@ from dune.perftool.generation import (backend, domain) +from dune.perftool.pdelab.geometry import local_dimension @backend(interface="lfs_inames", name="blockstructured") @@ -12,6 +13,6 @@ def lfs_inames(element, restriction, count=None, context=''): context = str(count) name = "micro_{}_index".format(context) - domain(name, 4) + domain(name, pow(2,local_dimension())) return name, diff --git a/python/dune/perftool/blockstructured/tools.py b/python/dune/perftool/blockstructured/tools.py index e9c8c3f3..a118b318 100644 --- a/python/dune/perftool/blockstructured/tools.py +++ b/python/dune/perftool/blockstructured/tools.py @@ -1,6 +1,6 @@ from dune.perftool.generation import (iname, domain) -from dune.perftool.pdelab.geometry import world_dimension +from dune.perftool.pdelab.geometry import local_dimension from dune.perftool.generation.counter import get_counted_variable from dune.perftool.options import get_option import pymbolic.primitives as prim @@ -9,7 +9,7 @@ import pymbolic.primitives as prim @iname def sub_element_inames(): name = "subel" - dim = world_dimension() + dim = local_dimension() inames = tuple() for i in range(dim): name_counted = get_counted_variable(name) @@ -26,11 +26,12 @@ def micro_index_to_macro_index(index): k = get_option("number_of_blocks") - modified_index = prim.Product(((k+1), prim.Variable(subelem_inames[1]))) - modified_index = prim.Sum((modified_index, prim.Variable(subelem_inames[0]), index)) - index_div_2 = prim.FloorDiv(index, 2) - index_div_2 = prim.Product((index_div_2, k-1)) - modified_index = prim.Sum((modified_index, index_div_2)) + modified_index = prim.Sum((prim.Variable(subelem_inames[0]), index)) + if local_dimension()>1: + modified_index = prim.Sum((modified_index, prim.Product(((k+1), prim.Variable(subelem_inames[1]))))) + index_div_2 = prim.FloorDiv(index, 2) + index_div_2 = prim.Product((index_div_2, k-1)) + modified_index = prim.Sum((modified_index, index_div_2)) return modified_index diff --git a/python/dune/perftool/pdelab/__init__.py b/python/dune/perftool/pdelab/__init__.py index 65e59290..832a3e7d 100644 --- a/python/dune/perftool/pdelab/__init__.py +++ b/python/dune/perftool/pdelab/__init__.py @@ -16,7 +16,7 @@ from dune.perftool.pdelab.basis import (pymbolic_basis, from dune.perftool.pdelab.geometry import (component_iname, name_cell_volume, name_facet_area, - name_facet_jacobian_determinant, + pymbolic_facet_jacobian_determinant, pymbolic_jacobian_determinant, pymbolic_jacobian_inverse_transposed, name_unit_inner_normal, @@ -109,8 +109,8 @@ class PDELabInterface(object): def pymbolic_spatial_coordinate(self): return to_global(pymbolic_quadrature_position()) - def name_facet_jacobian_determinant(self): - return name_facet_jacobian_determinant() + def pymbolic_facet_jacobian_determinant(self): + return pymbolic_facet_jacobian_determinant() def pymbolic_jacobian_determinant(self): return pymbolic_jacobian_determinant() diff --git a/python/dune/perftool/pdelab/geometry.py b/python/dune/perftool/pdelab/geometry.py index 6793d45e..79dfb5da 100644 --- a/python/dune/perftool/pdelab/geometry.py +++ b/python/dune/perftool/pdelab/geometry.py @@ -396,12 +396,17 @@ def name_jacobian_determinant(): def pymbolic_jacobian_determinant(): return prim.Variable(name_jacobian_determinant()) + def name_facet_jacobian_determinant(): name = 'fdetjac' get_backend(interface="detjac", selector=option_switch("constant_transformation_matrix"))(name) return name +def pymbolic_facet_jacobian_determinant(): + return prim.Variable(name_facet_jacobian_determinant()) + + def apply_to_global_transformation(name, local): temporary_variable(name, shape=(world_dimension(),), shape_impl=("fv",)) geo = name_geometry() diff --git a/python/dune/perftool/ufl/visitor.py b/python/dune/perftool/ufl/visitor.py index 0bbb13f5..5a5c74fa 100644 --- a/python/dune/perftool/ufl/visitor.py +++ b/python/dune/perftool/ufl/visitor.py @@ -389,7 +389,7 @@ class UFL2LoopyVisitor(ModifiedTerminalTracker): raise NotImplementedError("How did you get Jacobian into your form? We only support JacobianInverse right now. Report!") def facet_jacobian_determinant(self, o): - return Variable(self.interface.name_facet_jacobian_determinant()) + return self.interface.pymbolic_facet_jacobian_determinant() def cell_volume(self, o): restriction = self.restriction -- GitLab