In the same link as above, postprocessing is pretty easy when we are also integrating, but in my case, there is no integration, just a simple conditional function.
I assume u is the solution to your Finite element problem? If so, you can create a custom projection with the following variational forms:
u, v = TrialFunction(V), TestFunction(V)
a=inner(u,v)*dx
L=inner(uh**2,v)*dx(domain=mesh, subdomain_data=mf, subdomain_id=1) + inner(2*uh, v)* dx(domain=mesh, subdomain_data=mf, subdomain_id=0)
u_post =Function(V)
solve(a==L, u_post)
Where uh is the solution to your original problem. Note that you might want to use a DG-space for the projection, as u**2!=2u could happen at the interface between the domains.
To visualize DG functions, use XDMFFile.write_checkpoint and open it in paraview.