addPhysicalGroup removes nodes
Hi,
I want to embed points in a 2D mesh. With the attached code this works fine
But when I tag these points with addPhysicalGroup, all other nodes and are removed in the mesh-file
Any hints for me?
import numpy as np
import sys
import gmsh
model = gmsh.model
factory = model.occ
gmsh.initialize(sys.argv)
gmsh.option.setNumber("General.Terminal", 1)
model.add("test")
# coordinates
p = [0]*10
x = [0]*len(p)
y = [0]*len(p)
x[1], y[1] = 0, 0
x[2], y[2] = 2, 0
x[3], y[3] = 2, 1
x[4], y[4] = 0, 1
x[5], y[5] = 1, 0.5
# points
p[1] = factory.addPoint(x[1], y[1], 0, 0.25 )
p[2] = factory.addPoint(x[2], y[2], 0, 0.25 )
p[3] = factory.addPoint(x[3], y[3], 0, 0.25 )
p[4] = factory.addPoint(x[4], y[4], 0, 0.25 )
# lines
l = [0]*5
l[1] = factory.addLine(p[1], p[2])
l[2] = factory.addLine(p[2], p[3])
l[3] = factory.addLine(p[3], p[4])
l[4] = factory.addLine(p[4], p[1])
ll1 = factory.addCurveLoop( l[1:4+1] )
s1 = factory.addPlaneSurface( [ll1] )
# points for embedding
x_embed = np.linspace(0.5, 1.5, 20)
y_embed = np.linspace(0.2, 0.8, 20)
p_embed = []
for k in range(len(x_embed)):
p_embed.append(factory.addPoint(x_embed[k], y_embed[k], 0, 0.05 ))
factory.synchronize()
model.mesh.embed(0, p_embed, 2, s1)
# addPhysicalGroup destroys the mesh !!
for bnd_ in p_embed:
tag = model.addPhysicalGroup(0, [bnd_])
gmsh.model.setPhysicalName(0, tag, 'point_' + str(bnd_))
gmsh.option.setNumber("Mesh.Algorithm", 1)
gmsh.option.setNumber("Mesh.MshFileVersion", 2.2)
model.mesh.generate(2)
gmsh.write("mesh.msh")
gmsh.finalize()