Assertion error, mesh is None

from dolfinx import *
from mpi4py import *

mesh = mesh.create_unit_interval(MPI.COMM_WORLD,8)
V = fem.FunctionSpace(mesh,"Lagrange",2)


print('done')

root@818ab534cb85:~/sandbox# cd /root/sandbox ; /usr/bin/env /bin/python3 /root/.vscode-server/extensions/ms-python.python-2023.12.0/pythonFiles/lib/python/debugpy/adapter/…/…/debugpy/launcher 46521 – /root/sandbox/sandbox.py
Traceback (most recent call last):
File “/root/sandbox/sandbox.py”, line 5, in
V = fem.FunctionSpace(mesh,“Lagrange”,2)
File “/usr/local/dolfinx-real/lib/python3.10/dist-packages/dolfinx/fem/function.py”, line 469, in init
assert mesh is None
AssertionError
root@818ab534cb85:~/sandbox#



Anyone can shed light on why this assertion error. Is that the way things are included on an rc1 docker image for cpp?

You should avoid wildcard import while using dolfinx as written here FEniCSx tutorial. So, the code becomes -

from dolfinx import mesh
from dolfinx.fem import FunctionSpace
from mpi4py import MPI

points = [0., 8.]
mesh = mesh.create_interval(MPI.COMM_WORLD,8,points)
V = FunctionSpace(mesh,("CG", 2))

You can use pyvista or paraview to visualize as the mesh as done in the same tutorial I mentioned above FEniCSx tutorial.

3 Likes