This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

How to fix degenerate CGAL meshes

+1 vote

I guess this is related to issue 224: Is there an easy way to get rid of degenerate cells in (generated) meshes? The following code illustrates the problem caused by a small perturbation of a single coordinate.

from dolfin import *
vertices = lambda eps: [[0.0, 0.5+eps], [0.5, 0.0], [1.0, 0.5], [0.5, 1.0]]
for i in range(2):
    mesh = Mesh(Polygon([Point(*p) for p in vertices(i*1e-15)]), 2)
    print "\t%i: MeshQuality" % (i+1), MeshQuality.radius_ratio_min_max(mesh), "num_cells", mesh.num_cells()
    plot(mesh, title="mesh %i" % (i+1))
interactive()
asked Feb 4, 2014 by meigel FEniCS User (1,520 points)

1 Answer

+1 vote

There is no easy way to fix poor meshes. The 'fix' is to not generate bad meshes in first place. Unfortunately CGAL does not mesh polygons very well.

answered Feb 5, 2014 by Garth N. Wells FEniCS Expert (35,930 points)

What I have experienced is (without extensive testing) that some cells degenerate in the way that one dimension collapses. If this was the only thing to happen, one could iterate all cells, remove the ones with vanishing measure, reorder vertices and use MeshEditor to create a new mesh. Do you reckon this would be worthwhile or are there other issues you have seen like degenerate but non-vanishing cells?

I would recommend using Gmsh to create polygonal meshes,

We consider an evolving polygonal interface in some 2d domain and have to remesh every other iteration with the constraint that the interface is represented by the mesh. Do you think gmsh is suited for this?

...