As it seems like all your computations are based on the mesh coordinates, you can use the dof_to_vertex_map
to insert values into a function from a CG 1 space, see; Mapping from mesh.coordinates() to u.vector() - #2 by dokken
1 Like