# Finding cell facet coordinates

**URL:** <https://fenicsproject.discourse.group/t/finding-cell-facet-coordinates/4073>\
**Category:** mesh\
**Created:** [September 9, 2020, 8:20pm UTC](https://fenicsproject.discourse.group/t/finding-cell-facet-coordinates/4073 "2020-09-09T20:20:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ss636](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@ss636](https://fenicsproject.discourse.group/u/ss636)\
**Post date:** [September 9, 2020, 8:20pm UTC](https://fenicsproject.discourse.group/t/finding-cell-facet-coordinates/4073/1 "2020-09-09T20:20:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![volkerk](https://avatars.discourse-cdn.com/v4/letter/v/9d8465/32.png) [@volkerk](https://fenicsproject.discourse.group/u/volkerk)\
**Post date:** [September 10, 2020, 8:00am UTC](https://fenicsproject.discourse.group/t/finding-cell-facet-coordinates/4073/2 "2020-09-10T08:00:41Z")

</div>

You may try something like:

```python
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.

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [September 10, 2020, 8:18am UTC](https://fenicsproject.discourse.group/t/finding-cell-facet-coordinates/4073/3 "2020-09-10T08:18:46Z")

</div>

> [@volkerk](#):
>
> Note that the dofs at the vertices are not included.

Note that these are easy to add with the following additions:

```auto
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)

```
