diff --git a/python/dune/perftool/blockstructured/__init__.py b/python/dune/perftool/blockstructured/__init__.py index 7c8ce39a8db130e47ae9c33f11376be48f7ea5f7..2fad02ffb42c57d462086736924356cfb74c27c8 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 7c2ef32b84c3bb3280e8021d30875608ed5e1e55..8c5fcfed28920e865b7b740cf7fb11c381a860a8 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 6079d75cee4ba5bb410f1a6e349b0d6b3872fa3e..c75373582850746a39173d43f391fc66c2000b10 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 e9c8c3f38cd0822c033bd01d690ffd3585961319..a118b318911086d71f27affada542cabeb0cae34 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 65e592907fe9c98f821e0d8e179d280740532ec6..832a3e7dc8a2a9e7b35015d40afed0f0ed5faf92 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 6793d45e48a10900e329f9ccc10289006543abcd..79dfb5dae291d82cf868377f0a09ace623f2a403 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 0bbb13f5a6949e20e6125fcb609e3073dbc3845e..5a5c74fa521bae4b08c38badc19d08fdd8bb4ea7 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