# Finding cell facet coordinates

When looping over a cell’s FaceIterator (i.e. FaceIterator(cell)), how can one access the coordinates of the face and its dofs ids?

For e.g. there exists; cell->get_vertex_coordinates();

but nothing similar for faces…

face->get_vertex_coordinates()
or
face->get_dof_ids() // should return cell dofs that are non-zero on this face

Any suggestions?

thanks,
-ss

You may try something like:

from dolfin import *

mesh = UnitSquareMesh(2,2)
W = FunctionSpace(mesh, 'CG', 2)

for cell in cells(mesh):
print(cell.index())
for facet in facets(cell):
vertex_coords = []
for vertex in vertices(facet):
vertex_coords.append(list(vertex.point().array()))
facet_dofs = W.dofmap().entity_dofs(mesh, mesh.topology().dim()-1, [facet.index()])

print('\t', vertex_coords, facet_dofs)

Note that the dofs at the vertices are not included.

1 Like

from dolfin import *

mesh = UnitSquareMesh(2,2)
W = FunctionSpace(mesh, 'CG', 2)

for cell in cells(mesh):
print(cell.index())
for facet in facets(cell):
vertex_coords = []
vertex_indices = []
for vertex in vertices(facet):
vertex_coords.append(list(vertex.point().array()))
vertex_indices.append(vertex.index())
facet_dofs = W.dofmap().entity_dofs(mesh, mesh.topology().dim()-1, [facet.index()])
vertex_dofs = W.dofmap().entity_dofs(mesh, 0, vertex_indices)
print('\t', vertex_coords, facet_dofs, vertex_dofs)