From c6513ccf36b5bf1fe67e6ce9eb54dee293c194fd 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, 18 Dec 2018 11:02:05 +0100 Subject: [PATCH] [skip ci] Use correct matrix sequence in interface after splitting --- python/dune/codegen/sumfact/accumulation.py | 16 ++++++++++++++++ python/dune/codegen/sumfact/basis.py | 13 +++++++++++++ python/dune/codegen/sumfact/geometry.py | 13 +++++++++++++ python/dune/codegen/sumfact/vectorization.py | 7 ++++++- 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/python/dune/codegen/sumfact/accumulation.py b/python/dune/codegen/sumfact/accumulation.py index 4219ba26..b32541f6 100644 --- a/python/dune/codegen/sumfact/accumulation.py +++ b/python/dune/codegen/sumfact/accumulation.py @@ -102,6 +102,9 @@ class AccumulationOutput(SumfactKernelInterfaceBase, ImmutableRecord): trial_element_index=None, ): + # See comment regarding get_keyword_arguments why we assert that matrix_sequence is not None + assert matrix_sequence is not None + # Note: The function sumfact_quadrature_permutation_strategy does not # work anymore after the visiting process since get_facedir and # get_facemod are not well defined. But we need the @@ -131,6 +134,19 @@ class AccumulationOutput(SumfactKernelInterfaceBase, ImmutableRecord): def __repr__(self): return ImmutableRecord.__repr__(self) + def get_keyword_arguments(self): + """Get dictionary of keyword arguments needed to initialize this classIFIERS + + Extract keyword arguments from the ImmutableRecord and modify + accordingly. You need to set the correct matrix sequence before using + this dict to create an interface. + """ + dict = self.get_copy_kwargs() + del dict['_cost_permutation'] + del dict['_quadrature_permutation'] + dict['matrix_sequence'] = None + return dict + @property def quadrature_permutation(self): return self._quadrature_permutation diff --git a/python/dune/codegen/sumfact/basis.py b/python/dune/codegen/sumfact/basis.py index fb0b905f..067f31e7 100644 --- a/python/dune/codegen/sumfact/basis.py +++ b/python/dune/codegen/sumfact/basis.py @@ -94,6 +94,19 @@ class LFSSumfactKernelInput(SumfactKernelInterfaceBase, ImmutableRecord): def __str__(self): return repr(self) + def get_keyword_arguments(self): + """Get dictionary of keyword arguments needed to initialize this classIFIERS + + Extract keyword arguments from the ImmutableRecord and modify + accordingly. You need to set the correct matrix sequence before using + this dict to create an interface. + """ + dict = self.get_copy_kwargs() + del dict['_cost_permutation'] + del dict['_quadrature_permutation'] + dict['matrix_sequence'] = None + return dict + @property def quadrature_permutation(self): return self._quadrature_permutation diff --git a/python/dune/codegen/sumfact/geometry.py b/python/dune/codegen/sumfact/geometry.py index 7de23836..cd0d34b7 100644 --- a/python/dune/codegen/sumfact/geometry.py +++ b/python/dune/codegen/sumfact/geometry.py @@ -103,6 +103,19 @@ class GeoCornersInput(SumfactKernelInterfaceBase, ImmutableRecord): def __str__(self): return repr(self) + def get_keyword_arguments(self): + """Get dictionary of keyword arguments needed to initialize this classIFIERS + + Extract keyword arguments from the ImmutableRecord and modify + accordingly. You need to set the correct matrix sequence before using + this dict to create an interface. + """ + dict = self.get_copy_kwargs() + del dict['_cost_permutation'] + del dict['_quadrature_permutation'] + dict['matrix_sequence'] = None + return dict + @property def quadrature_permutation(self): return self._quadrature_permutation diff --git a/python/dune/codegen/sumfact/vectorization.py b/python/dune/codegen/sumfact/vectorization.py index 53c44257..8b191593 100644 --- a/python/dune/codegen/sumfact/vectorization.py +++ b/python/dune/codegen/sumfact/vectorization.py @@ -459,7 +459,12 @@ def get_vectorization_dict(sumfacts, vertical, horizontal, qp): seq = list(sf.matrix_sequence_quadrature_permuted) seq[slice_direction] = oldtab.copy(slice_size=vertical, slice_index=i) - kernels.append(sf.copy(matrix_sequence=tuple(seq))) + + # Create new sf kernel with new interface + kwargs = sf.interface.get_keyword_arguments() + kwargs.update({'matrix_sequence': tuple(seq)}) + newinterface = type(sf.interface)(**kwargs) + kernels.append(sf.copy(matrix_sequence=tuple(seq), interface=newinterface)) # Join the new kernels into a sum factorization node buffer = get_counted_variable("joined_buffer") -- GitLab