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

Code in some demos has minor error

0 votes

Many of the Ch1 examples have code to print values:

coor = mesh.coordinates()
for i in range(len(u_array)):
print 'u(%8g,%8g) = %g \t exact=%g' \
% (coor[i][0], coor[i][1], u_array[i], u_e_array[i] )}

When I run it, I find that the order of the coor array is different from the order of the u_array, so the coordinates don't match up with the right values. I got around this by interpolating x and y to the same space that u is in (interpolation should be exact) and then printing the interpolated coordinates along with u and u_e.

Is there a better way?

asked Apr 1, 2014 by mike125 FEniCS Novice (670 points)

1 Answer

+3 votes

Hi, there is indeed a difference in order of mesh coordinates and order of u_array. The keyword that you are looking for is dofmap. See here for a similar question and the answer.

answered Apr 2, 2014 by MiroK FEniCS Expert (80,920 points)
...