I am following the tutorial on mesh generation presented at Sorbonne this year.
When trying to plot the mesh defined in the beginning of the page,
import dolfinx
import numpy as np
import ufl
from mpi4py import MPI
import pyvista
nodes = np.array([[1., 0.], [2., 0.], [3., 2.], [1, 3]])
connectivity = np.array([[0, 1, 2], [0, 2, 3]])
c_el = ufl.Mesh(ufl.VectorElement("Lagrange", ufl.triangle, 1))
domain = dolfinx.mesh.create_mesh(MPI.COMM_SELF, connectivity, nodes, c_el)
def plot_mesh(mesh: dolfinx.mesh.Mesh):
plotter = pyvista.Plotter()
# ugrid = pyvista.UnstructuredGrid(*dolfinx.plot.create_vtk_mesh(mesh))
ugrid = pyvista.UnstructuredGrid(*dolfinx.plot.vtk_mesh(mesh))
if mesh.geometry.cmap.degree > 1:
plotter.add_mesh(ugrid, style="points", color="b", point_size=10)
ugrid = ugrid.tessellate()
show_edges = False
else:
show_edges = True
plotter.add_mesh(ugrid, show_edges=show_edges)
plotter.show_axes()
plotter.view_xy()
plotter.show()
plot_mesh(domain)
i get this error:
if mesh.geometry.cmap.degree > 1:
^^^^^^^^^^^^^^^^^^
AttributeError: 'dolfinx.cpp.mesh.Geometry_float64' object has no attribute 'cmap'. Did you mean: 'cmaps'?
My fenicsx version is: 0.7.0 based on GIT commit: 2244eee852d6aa070a2bbbd76215ef78d84911e1 and i run it in a conda environment on linux.
I checked, and the current version of the dolfinx.mesh.Geometry
class does really not have this ‘cmap’ attribute. How can i make this code run?
Another remark: the definition of ugrid
in the code was broken. I replaced “create_vtk_mesh” with “vtk_mesh”.