Is it possible to add zero-thickness elements in an existing mesh using Python API?
Hello,
I am interested in adding zero-thickness elements in a mesh generated in Gmsh.
By "zero-thickness elements" I mean quadrilateral elements with originally overlapping nodes (reason for the "zero-thickness" term):
Usually, the solution adopted consists of reading the .msh file, interpreting its contents, and rewriting it with the new elements. An example of this approach was presented by Tyler Olsen in this post. He also implemented a Python script that does that and gently shared it.
The process consists in:
- Interpreting .msh file. It is mandatory that the crack and the surfaces on either side of it are separated into different Physical Groups;
- The nodes of the line defining the crack are duplicated, and the connectivities of the elements around it are changed. A similar process is done by the Crack plugin);
- Finally, the zero-thickness elements are generated using the duplicated nodes, and they are added to a new physical group.
As follows, there are three files. The .geo file creates the geometry. The left ones are the input and output files used/generated with Tyler Olsen's script.
- Geo file: simpleCrack.geo
- Input file: simpleCrack.msh
- Output file: cracked_simpleCrack.msh
Geometry and input mesh with the crack highlighted:
Final mesh with the quadrilateral zero-thickness elements:
My question is:
Can I replicate Tyler Olsen's work using the Python API?
I was trying (with no success) to duplicate the nodes and change the connectivities of the elements around the crack. I managed to create the new nodes with the function gmsh.model.mesh.addNodes. I imagine that create the new elements is not a problem too, because the function gmsh.model.mesh.addElements is available. However, I couldn't change the connectivities of the existing elements.
Okay, I know that the Crack plugin also duplicates the nodes and rearranges the connectivities, but I would like to control the creation of the new nodes better. Also, I would like to do that using Python API, because it is easier and faster than doing that with the Gmsh source code in C++.
Can anyone help me?
Kind regards,
Francisco Dias.