I am trying to generate a finite element mesh using PyGmsh, using the following code:
import pygmsh
geom = pygmsh.opencascade.Geometry(
characteristic_length_min=0.1,
characteristic_length_max=0.1,
)
rectangle = geom.add_rectangle([-1.0, -1.0, 0.0], 2.0, 2.0)
disk1 = geom.add_disk([-1.2, 0.0, 0.0], 0.5)
disk2 = geom.add_disk([+1.2, 0.0, 0.0], 0.5)
disk3 = geom.add_disk([0.0, -0.9, 0.0], 0.5)
disk4 = geom.add_disk([0.0, +0.9, 0.0], 0.5)
union = geom.boolean_union([rectangle, disk1, disk2])
diff = geom.boolean_difference([union], [disk3, disk4])
mesh = pygmsh.generate_mesh(geom, dim=2)
I can generate the following mesh:
However, I would like to add a crack to the mesh, something like:
The crack here is just an example, it would need to be defined before the meshing process.
I've tried creating 2 points (geom.add_point()
) and a line (geom.add_line()
), and then do a
geom.boolean_difference()
between the final geometry and the line/crack, but this just does not work.
Any help would be greatly appreciated.
EDIT
The purpose of this type of mesh generation is to simulate a physical crack in a body. In the meshing process, the crack can be modeled by the elemental connectivity of the mesh (i.e. the elements must have different nodes to create a crack face). Example, before applying any load, the crack is closed:
After applying the load, the crack opens since the element connectivity allows this: