# Gmsh export to inp, missing nsets

**URL:** <https://calculix.discourse.group/t/gmsh-export-to-inp-missing-nsets/2641>\
**Category:** Uncategorized\
**Created:** [March 19, 2025, 10:59am UTC](https://calculix.discourse.group/t/gmsh-export-to-inp-missing-nsets/2641 "2025-03-19T10:59:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![shroud](https://avatars.discourse-cdn.com/v4/letter/s/58956e/32.png) [@shroud](https://calculix.discourse.group/u/shroud)\
**Post date:** [March 19, 2025, 10:59am UTC](https://calculix.discourse.group/t/gmsh-export-to-inp-missing-nsets/2641/1 "2025-03-19T10:59:33Z")

</div>

Hello,

I am trying to export a mesh created in the julia api. It works fine so far, but when creating node sets from physical surfaces, lines or simpy nodes, it does not work as it should.

My code: (Should work in python as well, by changing using with import.)

```auto
using Gmsh

gmsh.initialize()
gmsh.model.add("test")
gmsh.logger.start()

gmsh.model.occ.synchronize()
gmsh.model.occ.addBox(0, 0, 0, 20, 10, 1)

gmsh.model.occ.synchronize()

gmsh.option.setNumber("Mesh.CharacteristicLengthMax", 0.5)
gmsh.option.setNumber("Mesh.SaveGroupsOfElements", 1000)
gmsh.option.setNumber("Mesh.SaveGroupsOfNodes", -111)

gmsh.model.mesh.generate(3)

# Bottom face nodes
bot = gmsh.model.getEntitiesInBoundingBox(0, 0, 0, 20, 10, 0, 0)
gmsh.model.addPhysicalGroup(0, [p[2] for p in bot], 1, "bottom")

# Along a edge
lin = gmsh.model.getEntitiesInBoundingBox(0, 0, 0, 0, 10, 0, 0)
gmsh.model.addPhysicalGroup(0, [p[2] for p in lin], 2, "edge1")

# Volume
vol = gmsh.model.getEntities(3)
gmsh.model.addPhysicalGroup(3, [v[2] for v in vol], 3, "vol1")

gmsh.model.occ.synchronize()

gmsh.write("test.msh")
gmsh.write("test.inp")
gmsh.finalize

```

The issue is, that the physical groups to pick nodes from edges or surfaces do not export nodes from the mesh but the ones that are created by addBox as geometric points. A set nall for example then only contains the 8 corner nodes, nothing else.

Am I doing anything wrong or is this a known issue with gmsh?

---

<div class="post-metadata">

**Author:** ![JuanP74](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@JuanP74](https://calculix.discourse.group/u/JuanP74)\
**Post date:** [March 19, 2025, 1:34pm UTC](https://calculix.discourse.group/t/gmsh-export-to-inp-missing-nsets/2641/2 "2025-03-19T13:34:52Z")

</div>

Not sure to understand this sentence from the gmsh manual, this is a question for a gmsh forum, but:

`Mesh.SaveGroupsOfNodes`

Save groups of nodes for each physical group (for UNV, INP and Tochnog mesh formats) if value is positive; if negative, save groups of nodes for physical groups of dimension dim if the (dim+1)^th least significant digit of -Mesh.SaveGroupsOfNodes is 1 (for example: -100 will only save surfaces, while -1010 will save volumes and curves); for INP, save groups of nodes for all entities of dimension dim if the (dim+1)^th least significant digit of -Mesh.SaveGroupsOfNodes is 2  
Default value: `0`  
Saved in: `General.OptionsFileName`

---

<div class="post-metadata">

**Author:** ![shroud](https://avatars.discourse-cdn.com/v4/letter/s/58956e/32.png) [@shroud](https://calculix.discourse.group/u/shroud)\
**Post date:** [March 19, 2025, 1:58pm UTC](https://calculix.discourse.group/t/gmsh-export-to-inp-missing-nsets/2641/3 "2025-03-19T13:58:25Z")

</div>

I think the gmsh forum would be more suited as well, but I am still waiting that my account is approved. They only have a issue board on gitlab, as far as I know.

However, the combination gmsh/abaqus seems to be not so well documented, as abaqus users most likely will do everything in abaqus.

Besides other issues, I think a workaround would be the solution. If I get an answer in from the issue board I will update that here.  
Till then, a light wrapper for the gmesh model with a custom functionality to write my boundary conditions will do the trick I guess.

---

<div class="post-metadata">

**Author:** ![Nobody-86](https://avatars.discourse-cdn.com/v4/letter/n/e495f1/32.png) [@Nobody-86](https://calculix.discourse.group/u/Nobody-86)\
**Post date:** [March 22, 2025, 8:56pm UTC](https://calculix.discourse.group/t/gmsh-export-to-inp-missing-nsets/2641/4 "2025-03-22T20:56:14Z")

</div>

Hi,  
There is nothing wrong with the export, it works as expected. There are only two small errors in your script.

1. You select the end points to the two PhysicalGroups “bottom” and “edge1”, not the surface or line.

```auto
bot = gmsh.model.getEntitiesInBoundingBox(0, 0, 0, 20, 10, 0, 0)
lin = gmsh.model.getEntitiesInBoundingBox(0, 0, 0, 0, 10, 0, 0)

```

But it should be:

```auto
bot = gmsh.model.getEntitiesInBoundingBox(-1, -1, -1, 21, 11, 1, 2)
lin = gmsh.model.getEntitiesInBoundingBox(-1, -1, -1, 1, 11, 1, 1)

```

Note: The bounding box must be slightly larger so that the entities are secure in the box.

1. You explicitly assign points (dim=0) to the physicalGroups, not lines (dim=1) or areas (dim=2).

```auto
gmsh.model.addPhysicalGroup(0, [p[2] for p in bot], 1, "bottom")
gmsh.model.addPhysicalGroup(0, [p[2] for p in lin], 2, "edge1")

```

But it should be:

```auto
gmsh.model.addPhysicalGroup(1, [p[1] for p in bot], 1, "bottom")
gmsh.model.addPhysicalGroup(2, [p[1] for p in lin], 2, "edge1")

```

---

<div class="post-metadata">

**Author:** ![Yannick](https://avatars.discourse-cdn.com/v4/letter/y/b782af/32.png) [@Yannick](https://calculix.discourse.group/u/Yannick)\
**Post date:** [March 24, 2025, 8:48am UTC](https://calculix.discourse.group/t/gmsh-export-to-inp-missing-nsets/2641/5 "2025-03-24T08:48:13Z")

</div>

I had encountered the same issue. As JuanP74 said, the issue is how gmsh saves groups of nodes per default.

For my problem, the solution was to add following line in the .gmsh-options file:

Mesh.SaveGroupsOfNodes = 1;

---

<div class="post-metadata">

**Author:** ![shroud](https://avatars.discourse-cdn.com/v4/letter/s/58956e/32.png) [@shroud](https://calculix.discourse.group/u/shroud)\
**Post date:** [March 24, 2025, 9:15am UTC](https://calculix.discourse.group/t/gmsh-export-to-inp-missing-nsets/2641/6 "2025-03-24T09:15:43Z")

</div>

@Nobody-86  
Thanks. I figured that using a tolerance which is just applied to any bounding box just works fine.

However, after that the points will get selected as intendet but the .inp that is produced is not quite usable for me. There will be 1D and 2D elements written and it created node and element sets with the same names, which does not work for me.

I will use Gmsh now only for the Mesh generation and its optimization, and use some julia code to pick boundaries and write the inp file myself from this.
