How to extract values in a surface of 3D mesh to another 2D mesh?

What I am suggesting is to use a restricted measure, i.e.

ds = Measure("ds", domain=mesh1, subdomain_data=meshfunction_2D, subdomain_id=surface_id)

see for instance: Poisson equation with multiple subdomains — DOLFIN documentation for more info regarding subdomains.
Then you can simply do a restricted projection.

u, v = TrialFunction(V1), TestFunction(V1)
a = inner(u, v)*ds
A = assemble(a)
l = inner(u2, v)*ds
b = assemble(b)
A.ident_zeros()
u_2D = Function(V1)
solve(A, u_2D.vector(), b)
2 Likes