SpatialCoordinate of submesh

Is this difference in coordinates in dofs and geometry intended?

import gmsh
from dolfinx.io import gmshio
from mpi4py import MPI

gmsh.initialize()
r1=gmsh.model.occ.addRectangle(0, 0, 0, 1, 1)
r2=gmsh.model.occ.addRectangle(1, 0, 0, 1, 1)
r3=gmsh.model.occ.addRectangle(2, 0, 0, 1, 1)
gmsh.model.occ.synchronize()
v,v0=gmsh.model.occ.fragment([(2,r1),(2,r2),(2,r3)],[],removeObject=True)
gmsh.model.occ.synchronize()

for i,ee in enumerate(v):
    gmsh.model.addPhysicalGroup(2, [ee[1]],i+1)

facets=gmsh.model.getBoundary(v)
left=[]
right=[]
for f in facets:
    p1,p2=gmsh.model.getBoundary([f])
    if (gmsh.model.getValue(*p1,[])[0]==0) & (gmsh.model.getValue(*p2,[])[0]==0):
        left.append(f[1])
    if (gmsh.model.getValue(*p1,[])[0]==3) & (gmsh.model.getValue(*p2,[])[0]==3):
        right.append(f[1])
gmsh.model.addPhysicalGroup(1, left,2)    
gmsh.model.addPhysicalGroup(1, right,3)    

gmsh.option.setNumber("Mesh.MeshSizeMin", 5)
gmsh.option.setNumber("Mesh.MeshSizeMax", 30)


gmsh.model.mesh.generate(2)

comm=MPI.COMM_WORLD
domain,st,ft=gmshio.model_to_mesh(gmsh.model,comm,0)
gmsh.finalize()




import numpy as np
import dolfinx
import ufl
cells0,cells1=[np.concatenate([st.find(mi) for mi in grp]) for grp in [[1,2],[3]]]
mesh0,ent_mesh0_main,_,_=dolfinx.mesh.create_submesh(domain,domain.topology.dim,cells0)
V0=dolfinx.fem.functionspace(mesh0,("CG", 1))
f=dolfinx.fem.Function(V0)
x=ufl.SpatialCoordinate(mesh0)
def xx(x):
    return(x[0])
def yy(x):
    return(x[1])
with np.printoptions(precision=2,linewidth=200,suppress=1e-4,floatmode='fixed',sign=' '):
    print(mesh0.geometry.x[:,0])
    print(mesh0.geometry.x[:,1])
    print()
    f.interpolate(xx)
    print(f.x.array)
    f.interpolate(yy)
    print(f.x.array) 

[ 2.00 2.00 1.50 1.00 1.00 0.50 0.00 0.00]
[ 0.00 1.00 0.50 0.00 1.00 0.50 0.00 1.00]

[ 2.00 1.50 2.00 1.00 1.00 0.50 0.00 -0.00]
[ 1.00 0.50 0.00 0.00 1.00 0.50 0.00 1.00]

1st, 2nd and 3rd coordinate has been rotated.

How do I plot a function on submesh using pyvista?

topology, cell_types, geometry = plot.vtk_mesh(mesh0, tdim)
grid = pyvista.UnstructuredGrid(topology, cell_types, geometry)

does not work correctly

Thanks

Sorry, maybe I should read the docs first

topology, cell_types, geometry = plot.vtk_mesh(V0)
grid = pyvista.UnstructuredGrid(topology, cell_types, geometry)

does it correctly.

I have some examples here which may help also.