# Issues using generating mesh in magma-2d example

**URL:** <https://community.geodynamics.org/t/issues-using-generating-mesh-in-magma-2d-example/4640>\
**Category:** PyLith\
**Tags:** gmsh\
**Created:** [October 12, 2026, 5:21pm UTC](https://community.geodynamics.org/t/issues-using-generating-mesh-in-magma-2d-example/4640 "2026-10-12T17:21:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![g-brouwer](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/g-brouwer/32/3219_2.png) [@g-brouwer](https://community.geodynamics.org/u/g-brouwer)\
**Post date:** [October 12, 2026, 5:21pm UTC](https://community.geodynamics.org/t/issues-using-generating-mesh-in-magma-2d-example/4640/1 "2026-10-12T17:21:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![baagaard](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/baagaard/32/615_2.png) [@baagaard](https://community.geodynamics.org/u/baagaard)\
**Post date:** [October 13, 2026, 4:31pm UTC](https://community.geodynamics.org/t/issues-using-generating-mesh-in-magma-2d-example/4640/2 "2026-10-13T16:31:38Z")

</div>

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](https://community.geodynamics.org/uploads/short-url/yqwhsvVGj49LQpZZNmKw30ukZth.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](https://pylith.readthedocs.io/en/v5.0.2/intro/release-notes.html#version-5-0-2-2026-08-17) for changes that will affect your parameter files.

---

<div class="post-metadata">

**Author:** ![g-brouwer](https://yyz2.discourse-cdn.com/flex036/user_avatar/community.geodynamics.org/g-brouwer/32/3219_2.png) [@g-brouwer](https://community.geodynamics.org/u/g-brouwer)\
**Post date:** [October 13, 2026, 9:26pm UTC](https://community.geodynamics.org/t/issues-using-generating-mesh-in-magma-2d-example/4640/3 "2026-10-13T21:26:34Z")

</div>

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!
