Format output of get_vertex_coordinates() method of the Cell DOLFIN class

Someone could help me to clarify the format output of the get_vertex_coordinates() method of the Cell DOLFIN class. It outputs something like this for a 3D mesh:

[-0.03472532392602301, -27.942183384549395, 133.66798902252106, 
2.7172014665493904, -24.023637506330253, 129.7313884770117, 
-0.11130044029116437, -26.370368099230735, 129.11942981422644, 
-1.0128139453107599, -23.528043761854555, 132.58770419122433]

Could this be read as:

[x of first vertex, y of first vertex, z of first vertex, 
x of second vertex, y of second vertex, z of second vertex, 
x of third vertex, y of third vertex, z of third vertex, 
x of fourth vertex, y of fourth vertex, z of fourth vertex]

???

Hi
If you are looking for the coordinates of the vertexes (ordered based on the vertex number), you can try this:

from dolfin import *
mesh = UnitCubeMesh(1, 1, 1)
W = FunctionSpace(mesh, 'Lagrange', 1)
gdim = mesh.geometry().dim()
coor = mesh.coordinates()
v2d = vertex_to_dof_map(W)
v2d2 = sorted(v2d)
for vertice in v2d2:
    print 'Coordinates of vertex no', vertice, ':', (coor[vertice])
1 Like

Hi Leo, Iā€™m trying to define subdomains for a problem with multiple materials. I was able to do this nicely in 2D by defining the subdomains with the constructive solid geometry functions of the mshr module of FEniCS and with the domain.set_subdomain() method. But it turns out that this is not implemented for 3D so I am going to do this manually by iterating over all cells and checking if the cell is inside a specific geometrical volume, for example:

My subdomain is:

marrow = Cylinder(df.Point(11.0, 13.0, 0.0), df.Point(11.0, 13.0, 150.0), r_marrow, r_marrow, 15)

then I define a markers MeshFunction:

markers = MeshFunction('size_t', mesh, 3)

finally I check if a given cell is inside my subdomain and I mark that cell

for cell in cells(mesh):
    # Find cell center
    coord_celda = cell.get_vertex_coordinates()  
    center_celda_x = (coord_celda[0] + coord_celda[3] + coord_celda[6] + coord_celda[9])/4
    center_celda_y = (coord_celda[1] + coord_celda[4] + coord_celda[7] + coord_celda[10])/4
    center_celda_z = (coord_celda[2] + coord_celda[5] + coord_celda[8] + coord_celda[11])/4

    # If cell is in marrow
    if ((centro_celda_x -  11)**2 + (centro_celda_y - 13)**2 <= r_marrow**2): 
        # It is marked as subdomain 1
        markers[cell.index] = 1