On Feb 2, 2011, at 10:17 AM, Julien Derr wrote:
> fipy looks absolutely amazing. but so far, I didn't understand how to extract > the coordinates of a face. > do you know how it could be done ? The coordinates of the face centers (which is usually all you care about for working within FiPy) are obtained with X, = mesh.getFaceCenters() X, Y, = mesh.getFaceCenters() X, Y, Z = mesh.getFaceCenters() depending on the dimensionality of the mesh. If you want the coordinates of the vertices that define the face (for visualization in another tool, for instance), that's a bit harder to get at[*]. The coordinates of face #5 would be: coords = mesh.getVertexCoords()[..., mesh.faceVertexIDs[..., 5]] Of course, what's face #5? More useful, is something like: coords = mesh.getVertexCoords()[..., mesh.faceVertexIDs[..., mesh.getFacesLeft().getValue()]] coords will be an array of shape (D, V, F), where D is the dimensionality, V is the number of vertices for each face (possibly masked for mixed elements), and F is the number of faces you asked about. E.g, coords[:, 0, ...] will be the set of coordinates of the first vertex of each face, coords[:, 1, ...] will be the set of coordinates of the second vertex, and so on. coords[0, ...] will the be the X coordinates of all the vertices in a (V, F) array. coords[..., 5] will be coordinates of the vertices of the 5th face you asked about in a (D, V) array. Clear as mud? [*] It's even harder to get at because of some inconsistencies (and outright bugs) in our definitions. faceVertexIDs isn't defined for a Grid1D at all and for a Grid3D.faceVertexIDs is a tuple for some reason, so you need to use mesh.faceVertexIDs[1]. I don't know what other issues there are.
