This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Find adjacent cells of an edge/facet

+3 votes

I would like to get the (for an interior edge) two adjacent cells of a given facet. I found adjacent_cells() but it asks for an orientation of the form const std::vector facet_orientation* where I cannot find what this should be for an object.

from dolfin import *

mesh = UnitSquareMesh(4, 4)
for cell in cells(mesh):       
  for i, facet in enumerate(facets(cell)):
    print facet.index()
    print facet.adjacent_cells(??)
asked Oct 29, 2014 by hertzianer FEniCS Novice (190 points)

1 Answer

+4 votes
 
Best answer

You can use facet.entities(D):

from dolfin import *
mesh = UnitSquareMesh(4, 4)
D = mesh.topology().dim()
mesh.init(D-1,D) # Build connectivity between facets and cells
for f in facets(mesh):
    print f.index()
    print f.entities(D)
answered Oct 30, 2014 by Øyvind Evju FEniCS Expert (17,700 points)
selected Oct 30, 2014 by chris_richardson

Thanks, works perfectly

...