This is an illustration of the problem described in this forum post. I've included code to generate the image in Matplotlib to make it easy to include in the notebook here, but I get the same issue with the NetGen GUI:
import netgen.gui
Draw(mesh)
from ngsolve import __version__
__version__
'6.2.2009'
from ngsolve import *
from netgen.geom2d import *
import matplotlib.pyplot as plt
from matplotlib import cm
geo = CSG2d()
c0 = Circle(center=(0,0),radius=1, bc='a')
c1 = Circle(center=(1,0),radius=1, bc='b')
domain = c0 + c1 # Produces just a single circle (no union)
# domain = c0 * c1 # Same as above (no intersection)
# domain = c0 - c1 # Produces no plt
geo.Add(domain)
mesh = Mesh(geo.GenerateMesh())
# Generate image with Matplotlib
cells = [[v.nr for v in t.vertices] for t in mesh.Elements()]
xs = [v.point[0] for v in mesh.vertices]
ys = [v.point[1] for v in mesh.vertices]
all_edges = [(e.vertices[0].nr, e.vertices[1].nr) for e in mesh.edges]
for e in all_edges:
plt.plot([xs[e[0]],xs[e[1]]], [ys[e[0]],ys[e[1]]], 'k-', linewidth=0.2)
boundaries = set(mesh.GetBoundaries())
for i,boundary in enumerate(boundaries):
b = mesh.Boundaries(boundary)
boundary_edges = [[v.nr for v in e.vertices] for e in b.Elements()]
for e in boundary_edges:
plt.plot([xs[e[0]], xs[e[1]]], [ys[e[0]],ys[e[1]]], linewidth=4, color=cm.Dark2(i%8))
ax = plt.gca()
ax.set_aspect(1)
# Same results with the GUI
import netgen.gui
Draw(mesh)
geo = CSG2d()
c = Circle(center=(0,0),radius=1, bc='c')
r = Rectangle((0,0),(1,1), bc='r')
# domain = c * r # Produces just a single circle
# domain = c + r # Produces no plot
domain = c - r # Looks like a symmetric difference
geo.Add(domain)
mesh = Mesh(geo.GenerateMesh())
cells = [[v.nr for v in t.vertices] for t in mesh.Elements()]
xs = [v.point[0] for v in mesh.vertices]
ys = [v.point[1] for v in mesh.vertices]
all_edges = [(e.vertices[0].nr, e.vertices[1].nr) for e in mesh.edges]
for e in all_edges:
plt.plot([xs[e[0]],xs[e[1]]], [ys[e[0]],ys[e[1]]], 'k-', linewidth=0.2)
boundaries = set(mesh.GetBoundaries())
for i,boundary in enumerate(boundaries):
b = mesh.Boundaries(boundary)
boundary_edges = [[v.nr for v in e.vertices] for e in b.Elements()]
for e in boundary_edges:
plt.plot([xs[e[0]], xs[e[1]]], [ys[e[0]],ys[e[1]]], linewidth=4, color=cm.Dark2(i%8))
ax = plt.gca()
ax.set_aspect(1)