# Struggling with Gmsh.jl

**URL:** <https://discourse.julialang.org/t/struggling-with-gmsh-jl/117335>\
**Category:** General Usage\
**Tags:** question, package\
**Created:** [July 22, 2024, 11:09am UTC](https://discourse.julialang.org/t/struggling-with-gmsh-jl/117335 "2024-07-22T11:09:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![panos.asproulis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/panos.asproulis/32/23368_2.png) [@panos.asproulis](https://discourse.julialang.org/u/panos.asproulis)\
**Post date:** [July 22, 2024, 11:09am UTC](https://discourse.julialang.org/t/struggling-with-gmsh-jl/117335/1 "2024-07-22T11:09:00Z")

</div>

I am struggling to use the Gmsh.jl API in order to extract some information from a 3D mesh I loaded to my application. There are two simple things I am trying to do.

1. From the mesh I want to find all the mesh faces as a vector of the identification number of the faces and for each face I want to know the connectivity information i.e. a vector with the ids of the vertices forming each face, including the boundary vertices.

2. I want to do the same thing for the cells: I want a vector with the identification numbers of all the mesh cells and for each cell I want a vector with the identification numbers of each face forming the cell, including the boundary faces.

I looked at the tutorials for the Gmsh Julia API but they are mostly describing ways to construct meshes, not extracting data from imported ones. I managed to read the vertices with their unique identification numbers and coordinates but the connectivity information is something I am unable to find how to access.

Can anyone please help me with this?

---

<div class="post-metadata">

**Author:** ![j-fu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j-fu/32/11373_2.png) [@j-fu](https://discourse.julialang.org/u/j-fu)\
**Post date:** [July 22, 2024, 12:48pm UTC](https://discourse.julialang.org/t/struggling-with-gmsh-jl/117335/2 "2024-07-22T12:48:35Z")

</div>

We may have this functionality in ExtendableGrids.jl. It has a Gmsh extension, and we create various kinds of incidence matrices from gmsh output.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [July 22, 2024, 3:53pm UTC](https://discourse.julialang.org/t/struggling-with-gmsh-jl/117335/3 "2024-07-22T15:53:19Z")

</div>

@panos.asproulis please share a sample gmsh file and we can provide concrete examples on how to achieve what you need.

---

<div class="post-metadata">

**Author:** ![panos.asproulis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/panos.asproulis/32/23368_2.png) [@panos.asproulis](https://discourse.julialang.org/u/panos.asproulis)\
**Post date:** [July 25, 2024, 12:51pm UTC](https://discourse.julialang.org/t/struggling-with-gmsh-jl/117335/4 "2024-07-25T12:51:30Z")

</div>

Thank you for that. Using this as a reference I managed to extract the vertices which form a face (face connectivity information). I am now trying to find the faces which form a cell but according to the Gmsh API I can only find how to obtain the vertices forming a cell. Any hints?

---

<div class="post-metadata">

**Author:** ![j-fu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j-fu/32/11373_2.png) [@j-fu](https://discourse.julialang.org/u/j-fu)\
**Post date:** [July 25, 2024, 3:28pm UTC](https://discourse.julialang.org/t/struggling-with-gmsh-jl/117335/5 "2024-07-25T15:28:39Z")

</div>

ExtendableGrids can calculate these as matrices after converting the gmsh info to an ExtendableGrid.  
With examples/gmsh.jl:

```julia
julia> g=gmsh_t5();
ulia> g[FaceNodes]
3×28843 Matrix{Int32}:
1423 1423 255 1423 256 255 … 967 1914 1914 967 1271 1271
256 255 256 1539 1412 1412 2386 886 967 929 1274 1274
255 1539 1539 256 255 1539 1914 967 929 886 2852 1295

julia> g[CellFaces]
4×13801 Matrix{Int32}:
1 5 8 11 14 17 20 23 25 28 … 28837 28840 28840 28842 28842
2 3 9 6 4 7 21 22 26 12 16232 19348 28841 28658 28843
3 6 10 12 15 18 15 19 27 27 28517 26964 17764 19088 28601
4 7 2 13 16 19 22 24 10 29 28839 28838 28839 27068 28662

```

If this is what you need…
