Bug in crack plugin (duplicating wrong nodes)
Hey everyone! I believe I found a small bug when using the Crack
plugin. I'm creating a crack with two lines, but when changing the orientation of the second line, the plugin is not duplicating the right nodes. I was checking the source code, and my assumption is that there is a problem when finding the elements on the positive side of the crack, but I could not identify what is the problem. I apologize if the issue in question is misuse.
The below case is working fine:
However, if I change the orientation of the second line, it doesn't work as expected:
This is an illustration of processing the above mesh in my finite element code:
To check this weird behavior you can use the below script (you can change the crack_pt3
point to reproduce the tests I did).
import gmsh
import sys
gmsh.initialize(sys.argv)
gmsh.model.add("testing_crack")
p0 = gmsh.model.occ.addPoint(0, 0, 0, 0.1, 1)
p1 = gmsh.model.occ.addPoint(1, 0, 0, 0.1, 2)
p2 = gmsh.model.occ.addPoint(1, 1, 0, 0.1, 3)
p3 = gmsh.model.occ.addPoint(0, 1, 0, 0.1, 4)
l0 = gmsh.model.occ.addLine(1, 2, 1)
l1 = gmsh.model.occ.addLine(2, 3, 2)
l2 = gmsh.model.occ.addLine(3, 4, 3)
l3 = gmsh.model.occ.addLine(4, 1, 4)
ll0 = gmsh.model.occ.addCurveLoop([1, 2, 3, 4], 1)
s0 = gmsh.model.occ.addPlaneSurface([1], 1)
crack_pt1 = gmsh.model.occ.addPoint(0.25, 0.25, 0, 0.1)
crack_pt2 = gmsh.model.occ.addPoint(0.5, 0.5, 0, 0.1)
# crack_pt3 = gmsh.model.occ.addPoint(0.75, 0.25, 0, 0.1)
crack_pt3 = gmsh.model.occ.addPoint(0.25, 0.75, 0, 0.1)
crack_line1 = gmsh.model.occ.addLine(crack_pt1, crack_pt2)
crack_line2 = gmsh.model.occ.addLine(crack_pt2, crack_pt3)
ov, ovv = gmsh.model.occ.fragment([(2, 1)], [(1, crack_line1), (1, crack_line2)])
gmsh.model.occ.synchronize()
new_crack_lines = [item[1] for sublist in ovv[1:] for item in sublist]
gmsh.model.mesh.generate(2)
gmsh.model.mesh.setOrder(3)
gmsh.model.addPhysicalGroup(1, new_crack_lines, 101, "crack")
gmsh.plugin.setNumber("Crack", "Dimension", 1)
gmsh.plugin.setNumber("Crack", "PhysicalGroup", 101)
gmsh.plugin.setNumber("Crack", "DebugView", 1)
gmsh.plugin.run("Crack")
gmsh.option.setNumber("Mesh.SaveAll", 1)
gmsh.write("crack.msh")
if '-nopopup' not in sys.argv:
gmsh.fltk.run()
gmsh.finalize()
Please let me know if I'm doing something wrong.