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

How to get the coordinates corresponding to specific vertices that are pointed by their index.

0 votes

I want to be sure that the order in which vertices are reported for each edge, is consistent with the order in which vertices are laid out when mesh.coordinates() is called. Also, is there a method to tabulate the coordinates of a specific vertex that I point to by its index?
E.g. (from https://fenicsproject.org/qa/9807/how-to-get-a-nodal-value-for-a-specific-node)

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

In the last line the index of the vertex gets printed. For each edge two vertices are printed (as expected). Suppose, that for an edge I get the vertex indices 0, and 1. Then my first question precisely is: Are the first two coordinates (i.e., the zeroth and the first) returned by mesh.coordinates(), actually the coordinates of the vertices indexed by the last line of code? The second question is: Can I modify the above code to obtain the coordinates of the "vertex" by its index?

Many thanks for your time and assistance.

asked Sep 1, 2016 by hbinzubair FEniCS Novice (250 points)
...