My line of code:
tensor_el = element(family="DG", cell=the_mesh.mesh.ufl_cell(), degree=0, shape=(2, 2))
yields the error:
tensor_el = element(family="DG", cell=the_mesh.mesh.ufl_cell(), degree=0, shape=(2, 2))
File ".conda/envs/fenicsx-env/lib/python3.13/site-packages/basix/ufl.py", line 2038, in element
family = _basix.finite_element.string_to_family(family, cell.name)
^^^^^^^^^
AttributeError: 'Cell' object has no attribute 'name'
Apparently “element” expects either a str or _basix.CellType object. In my case I am giving it the object returned by the first argument of
mesh, cell_markers, facet_markers = gmshio.read_from_msh(mesh_file, MPI.COMM_WORLD, gdim=2)
which is a “Mesh” object, coming from dolfinx’s mesh.py. I see that this Mesh object has an attribute called “name”.
Not sure how to fix my problem.
Edit:
tensor_el = element(family="DG", cell=the_mesh.mesh.topology.cell_name(), degree=0, shape=(2, 2))
T = functionspace(the_mesh.mesh, tensor_el)
yields:
Traceback (most recent call last):
File "/home/user/Documents/fenicsx/v0dot9.py", line 2, in <module>
from dolfinx import log
File "/home/user/.conda/envs/fenicsx-env/lib/python3.13/site-packages/dolfinx/__init__.py", line 32, in <module>
from dolfinx import fem, geometry, graph, io, jit, la, log, mesh, nls, plot, utils
File "/home/user/.conda/envs/fenicsx-env/lib/python3.13/site-packages/dolfinx/fem/__init__.py", line 18, in <module>
from dolfinx.fem.assemble import (
...<7 lines>...
)
File "/home/user/.conda/envs/fenicsx-env/lib/python3.13/site-packages/dolfinx/fem/assemble.py", line 23, in <module>
from dolfinx.fem.forms import Form
File "/home/user/.conda/envs/fenicsx-env/lib/python3.13/site-packages/dolfinx/fem/forms.py", line 23, in <module>
from dolfinx.fem.function import FunctionSpace
ImportError: cannot import name 'FunctionSpace' from 'dolfinx.fem.function' (/home/user/.conda/envs/fenicsx-env/lib/python3.13/site-packages/dolfinx/fem/function.py)
Uh? It looks like forms.py tries to import FunctionSpace, which does not exist anymore (has been supplanted by functionspace). Is this a FEniCSx bug? How do people use it, then? I certainly am not the first one to fall over this situation, right?