compute length of a specified edge

Asked by Xiaoxian Liu on 2013-01-25

Hi all,

Below is the code I tested:

### Beginning of code
from dolfin import *
mesh = UnitSquare(1,1) # Only 2 cells in total
mesh.init() # Compute all the connectivity
c1 = Cell(mesh, 1) # choose cell with index "1"

f0, f1, f2 = c1.entities(1) # Pull out the connectivity information of cell "1"

for f in [f0, f1, f2]:
    print "%d-th edge has length %g" % (f, c1.facet_area(f))

### End of code

And the error message reads,
*** Error: Unable to create mesh entity.
*** Reason: Mesh entity index 49 out of range [0, 5] for entity of dimension 1.
*** Where: This error was encountered inside MeshEntity.cpp.
*** -------------------------------------------------------------------------

However, for this simple example, the facet indices of the 3 facets are (f0=3, f1=1, f2=4). Is this a bug or I did something stupid?

Thank you!

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Jan Blechta
Solved:
2013-01-26
Last query:
2013-01-26
Last reply:
2013-01-25
Best Jan Blechta (blechta) said : #1

Problem is in c1.facet_area(f). Here f needs to be local (=w.r.t. cell) facet index (0,1,2 for triangle cell). But you call it with f=3,1,4 which is global entity index.

Xiaoxian Liu (liuxiaox) said : #2

Thanks Jan Blechta, that solved my question.