What is the difference between compute_incident_entities and entities_to_geometry?

When I run the following code:

boundary_vertices = dolfinx.mesh.compute_incident_entities(mesh.topology, boundary_facets, mesh.topology.dim-1, 0)
print(boundary_vertices)
vertex_to_geometry = dolfinx.cpp.mesh.entities_to_geometry(mesh._cpp_object, 0, boundary_vertices, False) 
print(vertex_to_geometry)

the results are as follows:

[16 23 26 28 29]
[[16]
 [23]
 [26]
 [28]
 [29]]

with these numbers representing vertex indices. I’ve looked at the source code of the functions, but I’m still not clear on the difference between these two functions. Could someone help explain?


entities to geometry computes the geometry (node indices) of an entity of any dimension (vertex, Edge, facet, cell). The nodes are listed per entity.

Compute incident entities takes in a list of entities, and returns a single list of all entities of dimension d1 connected to these.

In the case of a linear geometry, all nodes = vertices, and the connectivities might be the same for your call (not always guaranteed).

1 Like

Thank you, this explanation is very clear.