I’m trying to evaluate the solution of a PDE I solved on all the cells of the mesh, to construct an array that contains coordinates and value of the function: [ x, y, z, u(x,y,z) ]
So I have solved the PDE, but I’m quite confused on how should I retrive the cell indexes and coordinate value to call eval on the solution:
...
u, p= Function(V), Function(Q)
x = PETSc.Vec().createNest([_cpp.la.petsc.create_vector_wrap(u.x), _cpp.la.petsc.create_vector_wrap(p.x)])
ksp.solve(b, x)
u_values=u.eval( ?, ?? )
I know ? is an object of shape (num_points,3), namely the coordinates, and ?? are the cell indexes of the points I want to evaluate, but I cannot find a simple way of retrive all the centers of the cells and the corresponding cells indexes from the mesh I used in the solution of the PDE. I’m using dolfinx 0.6.0
If you want to compute this at every cell midpoint, you could also simply interpolate your solution into a DG-0 space, and extract the values directly from the underlying dof-array