Dear FENICS community. I am trying to import meshes from gmsh using meshio to then study a problem with discontinuous elements in Dolfinx.
Provided that I have a 2D mesh file called mesh.xdmf
, I execute
with dolfinx.io.XDMFFile(MPI.COMM_WORLD, "mesh.xdmf", "r") as xdmf:
mesh = xdmf.read_mesh(name="Grid")
ct = xdmf.read_meshtags(mesh, name="Grid")
mesh.topology.create_connectivity(mesh.topology.dim - 1, mesh.topology.dim)
with dolfinx.io.XDMFFile(MPI.COMM_WORLD, "mt.xdmf", "r") as xdmf:
ft = xdmf.read_meshtags(mesh, name="Grid")
Following @dokken example in Define a boundary from DG elements, I ran the lines
def boundary(x):
return np.full(x.shape[1], True)
vertex_to_cell = mesh.topology.connectivity(0, mesh.topology.dim)
boundary_vertices = dolfinx.mesh.locate_entities(mesh, 0, boundary)
boundary_cells = []
for vertex in boundary_vertices:
boundary_cells.append(vertex_to_cell.links(vertex))
boundary_cells = np.hstack(boundary_cells)
But this error comes out
Traceback (most recent call last):....
boundary_cells.append(vertex_to_cell.links(vertex))
AttributeError: 'NoneType' object has no attribute 'links'
Since mesh.topology.connectivity(0, mesh.topology.dim)
returns None
. However, if I let the Python console open after the error and rerun line, sometimes it returns the vertex_to_cell dofs. I don’t now how this is happening.
On the other hand, the line
facet_to_cell = mesh.topology.connectivity(1, mesh.topology.dim)
returns the facet-to-cell dofs properly. Moreover, mesh.topology.connectivity(0, 1_or_2_here)
returns None
. The only one that seems to work is mesh.topology.connectivity(0, 0)
, i.e., vertex-to-vertex dofs