Mesh refinement and plotting in 1D

Issue #59 resolved
Elmar Zander created an issue

When I create a mesh in 1D, refine it and interpolate something on it, the plot looks very messed up, as in the plot first the original nodes are connected and then the new nodes from the refinement. An MWE is given below:

from dolfin import * print dolfin.version

mesh = refine(UnitIntervalMesh(10))

V = FunctionSpace(mesh, "CG", 1) f = interpolate(Expression("sin(10*x[0])"), V)

plot(f)

The dolfin.version I use is 1.2.0+, i.e. the nightly or development builds (Ubuntu package: 1.2.0+git20130604~ppa1~precise1).

Comments (7)

  1. Prof Garth Wells

    Can confirm problem. Plotting is fine without refinement, but something is up with points near boundary once refined.

    from dolfin import * 
    mesh = UnitIntervalMesh(40)
    mesh = refine(mesh)
    V = FunctionSpace(mesh, "CG", 1) 
    f = interpolate(Expression("sin(10*x[0])"), V)
    plot(f, interactive=True)
    
  2. Chris Richardson

    I just had a look at this, it seems that VTK is not respecting the connectivity information (set in VTKPlottableMesh::build_grid_cells) in 1D.

    More specifically, the class vtkXYPlotActor does not seem to use the Cell information, but just assumes the points are in order.

  3. Chris Richardson

    I've made a branch "chris/fix-issue-59" which implements a hack to get around this feature. I'm not making any claims for it being the best solution to the problem.

  4. Prof Garth Wells

    Looks good. Bit harsh calling it a hack. Looks like a nice work-around to me.

    I've merged chris/fix-issue-59 into next.

  5. Log in to comment