Skip to content

BUG: FactorisationError in spectral mode when interpolating an Argument from a VectorFunctionSpace of a physically mapped element #5690

Open
firedrakeproject/fiat
#317

Description

@marazzaf

Describe the bug
Symbolic interpolate(v, T) where v is a TestFunction or TrialFunction on a VectorFunctionSpace of a physically mapped element (Hermite, Reduced-Hermite, Morley, Argyris, Bell) fails to compile in the default "spectral" mode with gem.refactorise.FactorisationError. The same form compiles and assembles with form_compiler_parameters={"mode": "vanilla"}.

The failure does not depend on the target space (vector/tensor CG1, DG1, N1curl, Bernardi-Raugel and Rotated-Bernardi-Raugel all fail) or on whether a gradient is taken first. It does not occur for scalar spaces of the same elements, for vector spaces of non-mapped elements (e.g. vector CG2), or for forms that use the vector-valued Argument directly without interpolate (e.g. inner(grad(u), grad(v))*dx).

The node rejected by _collect_monomials (gem/refactorise.py:206) is an Indexed(ListTensor([...]), (Index(...),)) whose entries contain Delta(Index, 0) factors, i.e. an argument-dependent ListTensor indexed by a free index, which the argument factorisation cannot split.

This came up while testing #5688 (with firedrakeproject/fiat#316 and FEniCS/ufl#571) on a discrete Kirchhoff triangle formulation: w in VectorFunctionSpace(mesh, "Reduced-Hermite", 3, dim=3), discrete gradient interpolate(grad(w), VectorFunctionSpace(mesh, "Rotated-Bernardi-Raugel", 1, dim=3)). #5688 fixes the coordinate-mapping assertion for the vector Rotated-Bernardi-Raugel target, after which every residual and Jacobian term containing a test or trial function hits this error. It is not a regression from #5688: the minimal example below also fails on the commits #5688 is based on (firedrake 350cd70, fiat 91b20b48, ufl f4183ef2).

Steps to Reproduce

from firedrake import *

mesh = UnitSquareMesh(2, 2)
V = VectorFunctionSpace(mesh, "Hermite", 3)  # also Morley, Argyris, Bell, Reduced-Hermite
T = VectorFunctionSpace(mesh, "CG", 1)       # any target space fails the same way
v = TestFunction(V)

L = inner(interpolate(v, T), Constant((1, 0))) * dx

assemble(L, form_compiler_parameters={"mode": "vanilla"})
print("vanilla: OK")

assemble(L)  # default "spectral" mode
print("spectral: OK")

Run with python bug3_vector_zany_argument_interpolate.py.

Expected behavior
The form assembles in spectral mode, as it does in vanilla mode and as the scalar-valued equivalent does.

Error message

vanilla: OK
Traceback (most recent call last):
  File "bug3_vector_zany_argument_interpolate.py", line 13, in <module>
    assemble(L)  # default "spectral" mode
  ...
  File ".../tsfc/kernel_interface/common.py", line 319, in compile_gem
    assignments.extend(mode.flatten(var_reps.items(), ctx['index_cache']))
  File ".../tsfc/spectral.py", line 96, in flatten
    monomial_sums = collect_monomials(expressions, classifier)
  File ".../gem/refactorise.py", line 344, in collect_monomials
    return list(map(mapper, expressions))
  File ".../gem/refactorise.py", line 208, in _collect_monomials
    sums.append(MonomialSum.sum(*map(self, summands)))
  File ".../gem/refactorise.py", line 206, in _collect_monomials
    raise FactorisationError(expr)
gem.refactorise.FactorisationError: Indexed(ListTensor([Product(Delta(Index(58), 0, None), Literal(array(0.33333333), ...

The full message is a very long GEM expression; complete log attached (bug3_vector_zany_argument_interpolate.log).

Environment:

Additional Info
Workaround: form_compiler_parameters={"mode": "vanilla"} in assemble/solve. Related: #5686, #5687, #5688.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions