Meshing problem with CSG in 3D

Issue #11 new
Stefan Jakobsson created an issue

The following code meshes a union of a cylinder and a box.

import dolfin 
from mshr import *
R =1.0
H=0.5
fragments=51
cyl = Cylinder(dolfin.Point(0.0,0.0,H),dolfin.Point(0.0,0.0,0.0),R,R,fragments)
box = Box(dolfin.Point(-R,-R,0),dolfin.Point(R,0,H))
domain = cyl+box

# Creating a mesh generator object gives access to parameters of the
# meshing backend
generator = CSGCGALMeshGenerator3D(domain)
generator.parameters["edge_size"] = 0.025
generator.parameters["facet_angle"] = 25.0
generator.parameters["facet_size"] = 0.05

m = dolfin.Mesh()
generator.generate(m)

dolfin.plot(m, "3D mesh")

dolfin.interactive()

The dimensions are chosen so the geometries match. However, since fragments is not an even number the polygonial representations do not match. I tested this previously in dolfin and that resulted in a mesh with very small tets along one of the intersections between the cube and the cylinder and the same thing happens with mshr , see figure. With fragments=50 one gets a nice mesh.

Comments (3)

  1. Benjamin Dam Kehlet

    Confirmed! Sorry about the late reply.

    I have experienced the same. The problem is that due to round off errors (note that this occurs only on one side of the mesh) small parts of the cylinder "sticks out". They mesh generator will detect this as small features in the domain that should be preserved ("protected edge" is the term CGAL uses) during the generation of the mesh. The result is not only a mesh with ery small tets, but the performance of the mesh generator is also affected badly. It seems that the mesh generator dose not scale well with respect to the number of such protected edges. I discussed this briefly with the developer of CGAL's mesh generation package and he had some ideas. I'll take a look and see if we can detect this situation safely and remove it before we send the polyhedron to the mesh generator.

  2. Log in to comment