Closed BorisAndrews closed 2 years ago
Here's a reduced example of the problem:
from finat.point_set import PointSet
from gem import Index, select_expression
from tsfc.finatinterface import create_element
from ufl import FiniteElement, RestrictedElement, quadrilateral
ufl_element = RestrictedElement(FiniteElement("Q", quadrilateral, 2), restriction_domain="facet")
ps = PointSet([[0.5]])
finat_element = create_element(ufl_element)
evaluations = []
for eid in range(4):
(val,) = finat_element.basis_evaluation(0, ps, (1, eid)).values()
evaluations.append(val)
expr = select_expression(evaluations, Index())
The idea behind select_expression
is that it is meant to push the indexing inside by appropriately factorising a list of expressions. In this case the parts that end up failing are: [Product(...), Zero()]
which isn't a handled set of cases. I think that what is happening is that there is an assumption that each of the expressions in the list handed to select_expression
have the same structure (in the sense of pattern-matching). In this case however, the tabulation of some parts of the element result in literal Zero
s which destroys the structure-equivalence.
One can get around this by not eagerly producing symbolic zeros when building Literal
objects and constant folding thereafter. But I don't know if this has any negative consequences down the line.
That merge had bad consequences, so we've reverted it for now.
Certain forms arising from attempting to specify Lagrange multipliers on facets causes
_select_expression
inoptimise.py
to returnNotImplementedError: No rule for factorising expressions of this kind.
.Example code to return this error:
Work around found by @wence-: setting
{"mode" : "vanilla"}
in theform_compiler_parameters
of the specific problem, alongside addingreturn partial_indexed(ListTensor(expressions), (index,))
to_select_expression
before the error is raised, resolved the issue.