Issues using generating mesh in magma-2d example

I am learning to use PyLith. I attempt to run the 2D magma reservoir using poroelasticity example. However, generate_gmsh.py does not work. I have not altered the file at all- it is exactly as it was in the original download. Please advise on how to remedy this error.

When I generate the mesh I get this error:

./generate_gmsh.py --write
Info : [ 0%] Union Info : [ 10%] Union Info : [ 20%] Union Info : [ 30%] Union Info : [ 40%] Union Info : [ 50%] Union Info : [ 70%] Union Info : [ 80%] Union Info : [ 90%] Union Info : Cannot bind existing OpenCASCADE surface 3 to second tag 4
Info : Could not preserve tag of 2D object 4 (->3)
Info : [ 0%] Fragments Info : [ 10%] Fragments Info : [ 20%] Fragments Info : [ 30%] Fragments Info : [ 40%] Fragments Info : [ 50%] Fragments Info : [ 60%] Fragments Info : [ 70%] Fragments - Performing intersection of shapes Info : [ 80%] Fragments - Making faces Info : [ 90%] Fragments Info : [ 0%] Fragments Info : [ 10%] Fragments Info : [ 20%] Fragments Info : [ 30%] Fragments Info : [ 40%] Fragments Info : [ 50%] Fragments Info : [ 60%] Fragments Info : [ 70%] Fragments Info : [ 80%] Fragments - Making faces Info : [ 90%] Fragments Traceback (most recent call last):
File “/Users/gbrouwer/pylith/pylith-4.2.1-macOS-12.0-arm64/src/pylith-4.2.1/examples/magma-2d/./generate_gmsh.py”, line 174, in
App().main()
File “/Users/gbrouwer/pylith/pylith-4.2.1-macOS-12.0-arm64/lib/python3.12/site-packages/pylith/meshio/gmsh_utils.py”, line 106, in main
self.create_geometry()
File “/Users/gbrouwer/pylith/pylith-4.2.1-macOS-12.0-arm64/src/pylith-4.2.1/examples/magma-2d/./generate_gmsh.py”, line 87, in create_geometry
self.c_yneg_right = domain_curves[0][6]
~~~~~~~~~~~~~~~~^^^
IndexError: index 6 is out of bounds for axis 0 with size 5

I am using v4.2.1 and Mac OS. I installed it with the binary package.

Thank you for notifying us about this error. There appear to be changes to OpenCascade that are causing the script to no longer work, and we didn’t test the script with the latest version.

The attached generate_gmsh.py should resolve the issue. You will need to uncompress the file using gunzip.
generate_gmsh.py.gz (2.3 KB)

Note: We strongly recommend that you update to PyLith v5.0.2. You will still need this fix. Refer to the release notes for changes that will affect your parameter files.

Thanks for getting back to me so quickly. The file you shared worked.

I also updated to Pylith v5.0.2. Thanks for the tip!