I am doing simulations of Navier-Stokes flow on an unstructured grid.
At every timestep I thus have a function u. I know how to export this as an array: u.vector().array() but this is not a very helpful array. In fact, what arrray is it?
What I would like is to somehow get from my mesh and u two arrays:
(1) An array of points on my grid [(x_1,y_1), (x_2, y_2)....]
(2) An array of velocities [(ux_1,uy_1), (ux_1,uy_1)....]
The element at index i in (2) would then be the velocity at the point on the mesh described by the coordinates in place i in (1).
How would I go about creating these arrays from fenics functions?
Thanks in advance.
Here's my attempt, but it is not correct:
arr = u.vector().array()
coor = mesh.coordinates()
vertex_to_dof_map = V.dofmap().vertex_to_dof_map(mesh)
values = list()
for i, dum in enumerate(coor):
values.append([arr[vertex_to_dof_map[2*i]],arr[vertex_to_dof_map[2*i+1]]])
values = np.array(values)