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

How can I get the information of edges on each cell ( triangle ) ?

0 votes

Using " mesh.cells() " can only get the information about cells and vertices, but I want to know the connections about cells and edges.
In another word, I want to know the global ID of the three edges on a given cell(triangle).
I tried Pydoc dolfin.Mesh ,but no answer.

Thanks !

asked Nov 19, 2013 by HS.Sheng FEniCS Novice (570 points)

1 Answer

+4 votes
 
Best answer

Hi, here are 2 ways how you can get the cell->edge connectivity

from dolfin import *

mesh = UnitSquareMesh(2, 2)

# 'long' version
for cell in cells(mesh):
  print "cell", cell.index(), "has edges :",
  for edge in edges(cell):
    print edge.index(),
  print

print 

# 'short' version
for cell in cells(mesh):
  print "cell", cell.index(), "has edges :", cell.entities(1) 
answered Nov 19, 2013 by MiroK FEniCS Expert (80,920 points)
selected Nov 19, 2013 by HS.Sheng

Thank you !: )

There's a chance that you rather want facets(cell) instead of edges(cell) (which makes no difference in 2D).

Thanks a lot ! :)

...