`TensorElement` is not recompiled when `symmetry` argument changes
Closed this issue · 1 comments
When working with ufl.TensorElement("Quadrature", ...)
, I noticed that the length of the resulting FunctionSpace
did not change when changing the symmetry
argument.
Consider the following failing test case that creates a 6x6 tensor element with and without symmetry and checks the block size of the resulting dofmap. The second assert will fail.
import dolfinx as df
import ufl
from mpi4py import MPI
mesh = df.mesh.create_unit_interval(MPI.COMM_WORLD, 1)
def get_block_size(symmetry):
element = ufl.TensorElement(
"Quadrature",
mesh.ufl_cell(),
degree=2,
shape=(6, 6),
quad_scheme="default",
symmetry=symmetry,
)
V = df.fem.FunctionSpace(mesh, element)
return V.dofmap.index_map_bs
assert get_block_size(symmetry=True) == 21
assert get_block_size(symmetry=None) == 36
If you change the order of the asserts and clear ~/.cache/fenics
, again the second assert will fail.
I briefly went through the ffcx code and noticed that the hash (AFAIU used to decide if a previously compiled element is reused or new compiled) is based on the repr
of the corresponding basix.ufl_wrapper.TensorElement
which does not include the symmetry information. So if this line is changed to (e.g.)
super().__init__(f"TensorElement({sub_element._repr}, {shape}, {symmetric}) ...
the test above runs fine.
If that solution is fine for you, I am happy to open a pull request with the fix.
If that solution is fine for you, I am happy to open a pull request with the fix.
This is exactly the solution I would do, so you can go ahead. Thanks!