diff --git a/python/dune/codegen/blockstructured/basis.py b/python/dune/codegen/blockstructured/basis.py index 9a0c67afff4fdac59eb86a0b6e4f332c6a9aa79f..efbc1bc9b3b206d0503686679d6a15547d5004a9 100644 --- a/python/dune/codegen/blockstructured/basis.py +++ b/python/dune/codegen/blockstructured/basis.py @@ -38,21 +38,24 @@ class BlockStructuredBasisMixin(GenericBasisMixin): assert not isinstance(element, MixedElement) name = "phi_{}".format(FEM_name_mangling(element)) name = restricted_name(name, restriction) - self.init_basis_cache(element) + self.init_basis_cache(element, restriction) self.evaluate_basis(element, name, restriction) inames = self.lfs_inames(element, restriction, number, context=context) return prim.Subscript(prim.Variable(name), (tensor_index_to_sequential_index(inames, element.degree() + 1), 0)) @preamble(kernel='operator') - def init_basis_cache(self, element): - cache = name_localbasis_cache(element) - localbasis = name_localbasis(element) - qp_name = get_pymbolic_basename(self.quadrature_position_in_micro()) - return ["for (int i=0; i < {}.size(); ++i)".format(qp_name), - "{", - " {}.evaluateFunction({}[i], {});".format(cache, qp_name, localbasis), - "}"] + def init_basis_cache(self, element, restriction): + if not restriction: + cache = name_localbasis_cache(element) + localbasis = name_localbasis(element) + qp_name = get_pymbolic_basename(self.quadrature_position_in_micro()) + return ["for (int i=0; i < {}.size(); ++i)".format(qp_name), + "{", + " {}.evaluateFunction({}[i], {});".format(cache, qp_name, localbasis), + "}"] + else: + return [] @kernel_cached def evaluate_basis(self, element, name, restriction): @@ -71,21 +74,24 @@ class BlockStructuredBasisMixin(GenericBasisMixin): assert not isinstance(element, MixedElement) name = "js_{}".format(FEM_name_mangling(element)) name = restricted_name(name, restriction) - self.init_gradient_cache(element) + self.init_gradient_cache(element, restriction) self.evaluate_reference_gradient(element, name, restriction) inames = self.lfs_inames(element, restriction, number, context=context) return prim.Subscript(prim.Variable(name), (tensor_index_to_sequential_index(inames, element.degree() + 1), 0)) @preamble(kernel='operator') - def init_gradient_cache(self, element): - cache = name_localbasis_cache(element) - localbasis = name_localbasis(element) - qp_name = get_pymbolic_basename(self.quadrature_position_in_micro()) - return ["for (int i=0; i < {}.size(); ++i)".format(qp_name), - "{", - " {}.evaluateJacobian({}[i], {});".format(cache, qp_name, localbasis), - "}"] + def init_gradient_cache(self, element, restriction): + if not restriction: + cache = name_localbasis_cache(element) + localbasis = name_localbasis(element) + qp_name = get_pymbolic_basename(self.quadrature_position_in_micro()) + return ["for (int i=0; i < {}.size(); ++i)".format(qp_name), + "{", + " {}.evaluateJacobian({}[i], {});".format(cache, qp_name, localbasis), + "}"] + else: + return [] @kernel_cached def evaluate_reference_gradient(self, element, name, restriction): diff --git a/python/dune/codegen/pdelab/localoperator.py b/python/dune/codegen/pdelab/localoperator.py index 94d62d1cd4df704c06f1f668756be018697fe02f..6db956e498c1de5d7e25cb47fb40771314119299 100644 --- a/python/dune/codegen/pdelab/localoperator.py +++ b/python/dune/codegen/pdelab/localoperator.py @@ -284,7 +284,7 @@ def determine_accumulation_space(info, number): return AccumulationSpace(lfs=lfs, index=lfsi, restriction=info.restriction, - element=element + element=subel )