How do I export the results of mixed formulation?

Hi.
How do I export the results of mixed formulation with fenics-dolfinx v0.8.0?
The essence of my code is :

``````mesh = dolfinx.mesh.create_rectangle(MPI_COMM_WORLD,
np.array([[0.0, 0.0], [width, height]]),
[nx, ny],

Q2 = basix.ufl.element("CG", mesh.basix_cell(), 2, shape=(mesh.geometry.dim,), dtype=dolfinx.default_real_type)
Q1 = basix.ufl.element("CG", mesh.basix_cell(), 1, dtype=dolfinx.default_real_type)
MixedSpace = dolfinx.fem.functionspace(mesh,basix.ufl.mixed_element([Q2,Q1]))
V, dofV = MixedSpace.sub(0).collapse()
Q, dofQ = MixedSpace.sub(1).collapse()

# X={U,P} : solution of the problem
X = dolfinx.fem.Function(MixedSpace)
solver.solve(X)
U = dolfinx.fem.Function(V)
U.x.array[:] = X.x.array[dofV]
P = dolfinx.fem.Function(Q)
P.x.array[:] = X.x.array[dofQ]

ofile = dolfinx.io.XDMFFile(mesh.comm,"result.xdmf","w")
ofile.write_mesh(mesh)
ofile.write_function(U)
ofile.write_function(P)
``````

and this code causes error like :

Degree of output Function must be same as mesh degree. Maybe the Function needs to be interpolated?

Thank you.

If you search for this error on the forum

You get the following posts where I explain what is going on

Hi @dokken .
I solved my problem because of you!