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

Find the edges associated with each vertex

+1 vote

On a triangular mesh, I have a set of quantities defined on each vertex (i), but also need to define a quantity on the edges to all neighbour vertices of i (a quantity on ij for all neighbours j).

The following works for accessing the vertices associated with each edge:

for edge in edges(mesh):
    print "edge", edge.index()
    for vertex in vertices(edge):
        print "vertex", vertex.index()

How can I do the reverse, and get the edges associated with each vertex? If I try reversing the labels above, I get that 'edges(vertex)' is invalid syntax.

asked Dec 12, 2013 by David Holloway FEniCS Novice (170 points)
edited Dec 12, 2013 by johanhake

1 Answer

+4 votes
 
Best answer

This works perfectly fine:

for vert in vertices(mesh):
        print "\nvert", vert.index()
        for edge in edges(vert):
                print "   edge", edge.index()
answered Dec 12, 2013 by johanhake FEniCS Expert (22,480 points)
selected Dec 13, 2013 by johanhake

Thank you! That works.

...