I just went through the Fenics book to get the nodal displacements and tried this code ....

u_nodal_values = U.vector()
u_array = u_nodal_values.array()
coor = mesh.coordinates()
center = (0.5,0.5,0.5)
print U(center)
if mesh.num_vertices()==len(u_array):
   for i in range(mesh.num_vertices()): 
       print ’U(%8g,%8g,%8g) = %g’% (coor[i][0], coor[i][1], u_array[i])

but i don't get the expected result.. can anyone suggest me the modification ??

  • 3
    $\begingroup$ Welcome to scicomp! It would help if you could tell us what the expected result was. To make helping you easier, you should also give a complete example, i.e., one we can copy and paste and compare the results. $\endgroup$ – Christian Clason May 20 '13 at 19:52

I think the problem is that you are relying on a specific DOF ordering, which was changed in release 1.1. However, the vertex to DOF map which you need to solve your problem can be obtained by the following code

map = V.dofmap().vertex_to_dof_map(mesh)
  • $\begingroup$ when I use your information in my code i get error as vertex_to_dof = V.dofmap().vertex_to_dof_map(mesh) AttributeError: 'GenericDofMap' object has no attribute 'vertex_to_dof_map'.... $\endgroup$ – nickrocks May 21 '13 at 9:03
  • $\begingroup$ Which version of DOLFIN are you using? I am on 1.2.0 and it works fine. But as far as I know this feature was also backported to 1.1.x. Perhaps you should update your FEniCS packages. $\endgroup$ – Christian Waluga May 21 '13 at 11:52
  • $\begingroup$ I upgraded my fenics and now it works perfectly thnks $\endgroup$ – nickrocks May 21 '13 at 12:17
  • $\begingroup$ In 2019.1.0 it is vertex_to_dof_map(V) $\endgroup$ – uranix Apr 18 at 18:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.