how to delete embedded elements after making the mesh
Dear community,
I have a mesh composed of several volumes. I have also two lines in the mesh with tag numbers 1 and 2. I want to use these two lines for refinement but later I must delete them. I know the function gmsh.model.removeEntities()
does exist but it only works for unembedded elements. I am using GMSH 4.9.0
. My script is in the following:
import gmsh
import sys
gmsh.initialize()
x_min, x_max = 0, 1000
y_min, y_max = 0, 500
z_min, z_max = -500, 0
ht_x, ht_y, ht_z, cl_x = 250, 250, -200, 750
gmsh.model.occ.addPoint(ht_x, ht_y, -200)
gmsh.model.occ.addPoint(ht_x, ht_y, -400)
gmsh.model.occ.addPoint(cl_x, ht_y, -200)
gmsh.model.occ.addPoint(cl_x, ht_y, -400)
gmsh.model.occ.addLine (1, 2)
gmsh.model.occ.addLine (3, 4)
gmsh.model.occ.addRectangle(x_min, y_min, -100, x_max, y_max, 1)
bh_r = 1
gmsh.model.occ.addBox(x_min, y_min, z_max, x_max, y_max, z_min, 1)
gmsh.model.occ.addBox(ht_x-bh_r, ht_y-bh_r, -200, bh_r*2, bh_r*2, -200, 2)
gmsh.model.occ.addBox(cl_x-bh_r, ht_y-bh_r, -200, bh_r*2, bh_r*2, -200, 3)
gmsh.model.occ.synchronize()
surfs = gmsh.model.occ.getEntities(2)
lines = gmsh.model.occ.getEntities(1)
points = gmsh.model.occ.getEntities(0)
gmsh.model.occ.fragment(points + lines + [(2, 1)] + [(3, 2), (3, 3)], [(3, 1)])
gmsh.model.occ.synchronize()
gmsh.model.mesh.field.add("Distance", 1)
gmsh.model.mesh.field.setNumbers(1, "SurfacesList", [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18])
gmsh.model.mesh.field.setNumber(1, "Sampling", 100)
gmsh.model.mesh.field.add("Threshold", 2)
gmsh.model.mesh.field.setNumber(2, "InField", 1)
gmsh.model.mesh.field.setNumber(2, "SizeMin", bh_r)
gmsh.model.mesh.field.setNumber(2, "SizeMax", 100)
gmsh.model.mesh.field.setNumber(2, "DistMin", bh_r*2)
gmsh.model.mesh.field.setNumber(2, "DistMax", 150)
gmsh.model.mesh.field.add("Distance", 3)
gmsh.model.mesh.field.setNumbers(3, "CurvesList", [1, 2])
gmsh.model.mesh.field.setNumber(3, "Sampling", 50)
gmsh.model.mesh.field.add("Threshold", 4)
gmsh.model.mesh.field.setNumber(4, "InField", 3)
gmsh.model.mesh.field.setNumber(4, "SizeMin", bh_r/2)
gmsh.model.mesh.field.setNumber(4, "SizeMax", 100)
gmsh.model.mesh.field.setNumber(4, "DistMin", bh_r)
gmsh.model.mesh.field.setNumber(4, "DistMax", 150)
gmsh.model.mesh.field.add("Min", 5)
gmsh.model.mesh.field.setNumbers(5, "FieldsList", [2, 4])
gmsh.model.mesh.field.setAsBackgroundMesh(5)
gmsh.option.setNumber("Mesh.MeshSizeMax", 150)
gmsh.option.setNumber("Mesh.MeshSizeExtendFromBoundary", 0)
gmsh.option.setNumber("Mesh.Algorithm3D", 10)
gmsh.model.mesh.generate(3)
gmsh.write(r"exports/rect_bh_line" + ".msh")
gmsh.fltk.run()
gmsh.finalize()