I am just giving you the tools to do what you would like to do. The code in the «parts of domain» approach is a working example of a custom projection.
In your case, you are trying to project a derivative of a 3D field into 2D. There are several things you could consider:
-first project func3dz
into an appropriate 3D space (DG degree-1)
- then i think you should be able to interpolate into 2D.
You should Also inspect the behavior offunc3dz
after projection usingxdmf.write_checkpoint
and visualize it with paraview.