Hi all,
I have been trying to import numeric data from text file into FEniCS, but somehow the plot() function does not work correctly. Here is what used to set the values:
V = FunctionSpace(mesh, "CG", 1)
u = Function(V)
u.vector().set_local(h_data)
plot(u, interactive=True)
The graph I got is this one:
which should show a smooth slope. Yet it does not seem so.
I tried printing out the values at the vertices:
u_array = u.vector().array()
coor = mesh.coordinates()
if mesh.num_vertices() == len(u_array):
for i in range(mesh.num_vertices()):
print 'u(%8g,%8g) = %g' % (coor[i][0], coor[i][1], u_array[i])
this is the result:
u( 0, 0) = 1.5
u(0.333333, 0) = 1.5
u(0.666667, 0) = 1.5
u( 1, 0) = 1.5
u( 0,0.333333) = 2.5
u(0.333333,0.333333) = 2.5
u(0.666667,0.333333) = 2.5
u( 1,0.333333) = 2.5
u( 0,0.666667) = 3.5
u(0.333333,0.666667) = 3.5
u(0.666667,0.666667) = 3.5
u( 1,0.666667) = 3.5
u( 0, 1) = 4.5
u(0.333333, 1) = 4.5
u(0.666667, 1) = 4.5
u( 1, 1) = 4.5
which should, again, show a slope. Any thoughts on what I have done wrong?
Many thanks,