About the UFL Version Incompatibility

Hello, I installed Fenicsx on my new computer. I observed that my codes (the version uploaded at the end of 2023), which previously worked successfully with the (0.7.2 Dolfinx) and (2023.2.0 UFL) versions, were incompatible with the version I installed today ((0.8.0 Dolfinx and 2024.1.0 UFL) . There is a serious incompatibility, especially in UFL commands. For example, I’ve been there before

gdim= 2
shape = “triangle”
degree = 1

Define the cell and domain

I am currently encountering an error while running the cell = ufl.Cell(shape, geometric_dimension=gdim) code. -------------------------------------------------- -------------------------
TypeError Traceback (most recent call last)
Cell In[3], line 7
4 degrees = 1
6 # Define the cell and domain
----> 7 cell = ufl.Cell(shape, geometric_dimension=gdim)
8 domain = ufl.Mesh(ufl.VectorElement(“Lagrange”, cell, degree))
9#Create the mesh

TypeError: Cell.init() got an unexpected keyword argument ‘geometric_dimension’ Or, in the code domain = ufl.Mesh(ufl.VectorElement(“Lagrange”, cell, degree)) ---------- -------------------------------------------------- ---------------
AttributeError Traceback (most recent call last)
Cell In[59], line 8
6 # Define the cell and domain
7 cell = ufl.Cell(shape)
----> 8 domain = ufl.Mesh(ufl.VectorElement(“Lagrange”, cell, degree))
9#Create the mesh
10 mesh = dolfinx.mesh.create_mesh(MPI.COMM_WORLD, refined_cell_to_node, pos, domain)

I encounter AttributeError: module ‘ufl’ has no attribute ‘VectorElement’ errors, but I can also run other codes that do not contain ufl commands in the same way successfully. Is the reason for this change a version difference or a problem with the installation, etc. I wanted to ask if it was the case, to be honest, I searched it but I couldn’t figure it out. Also, for example, if you are available, can you share with me the version of this code suitable for new versions? I thought about it a lot, but I didn’t fully understand it. Thanks a lot.

Define geometric and topological dimensions

gdim = 2
shape = “triangle”
degree = 1

Define the cell and domain

cell = ufl.Cell(shape)
domain = ufl.Mesh(ufl.VectorElement(“Lagrange”, cell, degree))
#Create the mesh
mesh = dolfinx.mesh.create_mesh(MPI.COMM_WORLD, refined_cell_to_node, pos, domain)
tdim = mesh.topology.dim
fdim = tdim - 1
mesh.topology.create_connectivity(fdim, tdim)

Check if PyVista backend is available

print(pyvista.global_theme.jupyter_backend)
pyvista.start_xvfb() # Start virtual framebuffer if necessary

Create and plot the mesh using PyVista

topology, cell_types, geometry = plot.vtk_mesh(mesh, gdim)
grid = pyvista.UnstructuredGrid(topology, cell_types, geometry)
plotter = pyvista.Plotter()
plotter.add_mesh(grid, show_edges=True)
plotter.view_xy()

Show the plot in an interactive window or save to a file

if not pyvista.OFF_SCREEN:
plotter.show()
else:
figure = plotter.screenshot(“adjacent_triangles_mesh.png”)

Also, is there an easy way for me to back to 0.7.2 Dolfinx and 2023.2.0 UFL versions? I installed the software on Windows 11 using Docker Desktop.

Best regards,

You may want to search in the forum before posting. There is a message on literally the same thing just 3 posts under yours Alternative to vectorfunctionSpace - #2 by nate

Furthermore, your codes aren’t properly formatted, and thus it’s very hard to follow what you wrote.