How is function related to mesh?

Hello !

I am new to fenics and something puzzles me when i was trying this:

from fenics import *
import matplotlib.pyplot as plt
mesh = UnitSquareMesh(8,8)
V = FunctionSpace(mesh, "P", 1)
u = Function(V)
u.vector()[0] = 10
print(mesh.coordinates()[0])
plot(u)
plt.show()

In my opinion, after modifying the u.vector()[0] , the value of u at point mesh.coordinates()[0] should be changed. However, the picture painted shows that the value of u at point (0.0, 1.0) was changed.

How strange! Who can explain it?

1 Like

Take a look at this Tutorial:

https://fenicsproject.org/pub/tutorial/sphinx1/._ftut1006.html#degrees-of-freedom-and-function-evaluation

Thank you very much !

Coordinates are reordered when constructing FunctionSpace V .

coordinates = V.tabulate_dof_coordinates()

instead of

coordinates = mesh.coordinates()

It might be right now !