2

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:

enter image description here

However, I would like to add a crack to the mesh, something like:

enter image description here

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:

enter image description here

After applying the load, the crack opens since the element connectivity allows this:

enter image description here

Carlos
  • 586
  • 1
  • 9
  • 19
  • Interesting problem. You're trying to do a fracture mechanics analysis? Do you intend to calculate a J-integral to evaluate the possibility of crack propagation? I would say putting a discontinuity, with two physically distinct surfaces that cannot penetrate each other, is not the way you should go. You should do a stress analysis and use post-processing to evaluate the K value for the crack geometry. – duffymo Jan 27 '20 at 20:47
  • Yes, I want to do a fracture mechanics analysis, just linear-elastic. However, a crack/fracture must be defined. The simplest way is to define it through the element connectivity of the mesh. Ideally, this should be done in the meshing process. – Carlos Jan 27 '20 at 21:58
  • The two crack faces make contact and penetration factors - those are non-linear. I think mean just refining the elements along the crack path, but both sides are still joined in the mesh. That seems like a good idea. I would refine the mesh in the area of the crack tip and evaluation the stress intensity factor at integration points as a post processing step. – duffymo Jan 27 '20 at 22:01
  • @duffymo I just want a simple static traction test, so the faces of the crack do not contact each other. If the crack is not defined like you say, there won't be a concentration of stresses, and it won't be a fracture mechanics problem anymore. – Carlos Jan 27 '20 at 22:43
  • @duffymo I updated the question to better explain what I want to achieve. Notice that some comercial FEA software already use this technique of modeling the crack through the element connectivity, like Abaqus. – Carlos Jan 27 '20 at 22:50
  • I know Abaqus and its developers. I once had an offer to work there. If you can solve this with Anaqus, I’d say you’re in good hands. – duffymo Jan 27 '20 at 23:48
  • I understand fracture mechanics; forgive me, it's been a while. – duffymo Jan 28 '20 at 10:36

2 Answers2

1

You can achieve this by modeling a very narrow rectangle at that region. You can give dimensions like 1e-10 easily. I modelled also the crack tip to collapse the nodes in one point by modeling a very small circle. It works quite fine.

Also there is a plugin for this now. It automatically separates the nodes at the specified crack line/surface.

Ali
  • 11
  • 2
  • 1
    What plugin? Although it may seem pedantic, a crack should be modelled as a line in a 2D problem (or as a surface in a 3D problem). Fracture Mechanics is based on such principles (the crack is assumed to be a geometric discontinuity). Anyways, your approach is probably acceptable, but I believe a line would be better and easier to handle if any propagation model is explored. – Carlos Apr 12 '21 at 17:13
0

This can be achieved using the "embed" functionality. Minimal working example bellow (in Python).

import gmsh

gmsh.initialize()

gmsh.model.add("TestModel")

ms = 1 # mesh size at point

# square (plate) points
gmsh.model.geo.addPoint(0, 0, 0, ms, 1)
gmsh.model.geo.addPoint(8, 0, 0, ms, 2)
gmsh.model.geo.addPoint(8, 8, 0, ms, 3)
gmsh.model.geo.addPoint(0, 8, 0, ms, 4)

# square (plate) lines
gmsh.model.geo.addLine(1, 2, 1)
gmsh.model.geo.addLine(2, 3, 2)
gmsh.model.geo.addLine(3, 4, 3)
gmsh.model.geo.addLine(4, 1, 4)

# square (plate) curve loop
gmsh.model.geo.addCurveLoop([1, 2, 3, 4], 1)

# square (plate) surface
s = gmsh.model.geo.addPlaneSurface([1])

# "crack" geometry
a = gmsh.model.geo.addPoint(2, 2, 0, ms)
b = gmsh.model.geo.addPoint(6, 4, 0, ms/100)
l = gmsh.model.geo.addLine(a, b)

# synchronize
gmsh.model.geo.synchronize()

# embed "crack" on plate
gmsh.model.mesh.embed(1, [l], 2, s)

# generate mesh
gmsh.model.mesh.generate(2)

gmsh.fltk.run()

gmsh.finalize()

Output:

enter image description here

Carlos
  • 586
  • 1
  • 9
  • 19