Please note that to do this you must consider multiple things.
If u
is not a CG-1
space, there is no map from the mesh-vertices to the degrees of freedom, you then need to go go through the following steps:
- Use
vertex_to_dof_map
to move your input data array into a CG-1 space. - Interpolate/project the data in the CG-1 space into the suitable space (for instance CG-2).
- Compute
grad(u)
.
You basically need an inverse process of what is described in: VectorFunctionSpace solution corresponding to mesh - #2 by dokken
(which links to for instance Bitbucket)