Smoothing interface without mesh refinement

Hello,

Please first see the following test plots


4 figures are generate with element types: CG-1, CG-2, CG-3, DG-0. I needed to achieve a smooth interface between the red and blue area without mesh refinement, nor to mesh around the circle(this scenario is just a simple test case). What are some possible ways to do that? Any idea is appreciated!

from dolfin import *
from mshr import *
domain = Rectangle(dl.Point(0., 0.), dl.Point(1., 1.))
resolution=125
mesh = generate_mesh(domain, resolution)
R = .25
m = 1.
n = 0.
u = Expression('(pow(x[0]-0.6,2) + pow(x[1]-0.6,2) > pow(R,2)) ? m : n',degree=1,R=R,m=m,n=n)

for i in range(1,4):
    Vi = FunctionSpace(mesh, 'CG', i)
    ui = interpolate(u, Vi)
    plot(ui)

V0 = FunctionSpace(mesh, "DG", 0)
u0 = interpolate(u, V0)
plot(u0)

If you want something smooth without refining the mesh, I would strongly suggest using a combination of ufl.conditional and SpatialCoordinate, with a high order quadrature rule, is SpatialCoordinates are evalutated at quadrature points, and does not belong to a specific function space.

Please note that using the plot command for visualization will interpolate any higher order Lagrange space into a first order space, so a lot of information is lost. To visualize such spaces use XDMFFile.write_checkpoint