AttributeError: module 'dolfinx.mesh' has no attribute 'CellType'

While i was trying to run the demo_poisson.py on the DOLFINx 0.3.1.0 documentation, i encountered the following error:

File “/mnt/d/Users/Desktop/demo_poisson.py”, line 25, in
cell_type=mesh.CellType.triangle)
AttributeError: module ‘dolfinx.mesh’ has no attribute ‘CellType’

Code, where the error to be found:

import numpy as np

import ufl

from dolfinx import fem, io, mesh, plot

from ufl import ds, dx, grad, inner

from mpi4py import MPI

from petsc4py.PETSc import ScalarType


#Create Mesh and FunctionSpace V :

msh = mesh.create_mesh(comm=MPI.COMM_WORLD,

                            points=((0.0, 0.0), (1.0, 1.0)), n=(32, 32),

                            cell_type=mesh.CellType.triangle)

V = fem.FunctionSpace(msh, ("Lagrange", 1))

my question is: after looking in the reference documentation (2022) of Dolfinx, i find the same declaration methode for the mesh class function (Attribute) CellType. Is there another way (update or so.) to to define CellType in Python?

PS: I’m using pip and not docker. (Debian/Ubuntu packages)Preformatted text

As far as Im aware the debian packages using the 0.3.0 release (Debian -- Details of package python3-dolfinx in sid) where you have to import celltype as from dolfinx.cpp.mesh import CellType.
See for instance the demos from the 0.3.0 release: dolfinx/python/demo at v0.3.0 · FEniCS/dolfinx · GitHub

1 Like