# How to export a .nas from Hypermesh and import to gmsh with label

**URL:** <https://fenicsproject.discourse.group/t/how-to-export-a-nas-from-hypermesh-and-import-to-gmsh-with-label/6102>\
**Category:** mesh\
**Created:** [June 29, 2021, 11:26am UTC](https://fenicsproject.discourse.group/t/how-to-export-a-nas-from-hypermesh-and-import-to-gmsh-with-label/6102 "2021-06-29T11:26:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![YYWayne](https://avatars.discourse-cdn.com/v4/letter/y/ad7895/32.png) [@YYWayne](https://fenicsproject.discourse.group/u/YYWayne)\
**Post date:** [June 29, 2021, 11:26am UTC](https://fenicsproject.discourse.group/t/how-to-export-a-nas-from-hypermesh-and-import-to-gmsh-with-label/6102/1 "2021-06-29T11:26:38Z")

</div>

I know this is not really a topic of fenics but with Hypermesh, but I wanna get some help if anyone has deal with similar issue.  
I’m trying to get a mesh from Hypermesh and solving the problem with fenics. However, when I export the mesh in nastran format and read it with gmsh (to transform to .msh format), there is no labels for my mesh, or say only label 0. But these meshes do from different components in Hypermesh.  
I can deal with same issue when I use COMSOL to generate mesh and here is the minimum code(though this issue doesn’t reach to fenics code yet)

import meshio

def create\_mesh(mesh, cell\_type, prune\_z=False):  
cells = mesh.get\_cells\_type(cell\_type) # return a n\*(dim+1) array of cell vertexes  
cell\_data = mesh.get\_cell\_data(“gmsh:geometrical”, cell\_type) # return a n\*1 array of cell labels  
out\_mesh = meshio.Mesh(points=mesh.points, cells={cell\_type: cells}, cell\_data={“name\_to\_read”: [cell\_data]})  
if prune\_z:  
out\_mesh.prune\_z\_0()  
return out\_mesh

msh = meshio.read(‘case1\_3d\_2delem.msh’)  
meshio.write(“mesh.xdmf”, meshio.Mesh(points=msh.points, cells={“tetra”: msh.cells\_dict[“tetra”]}))  
tria\_mesh = create\_mesh(msh, ‘triangle’, prune\_z=True)  
meshio.write(‘mf.xdmf’, tria\_mesh)  
tetra\_mesh = create\_mesh(msh, ‘tetra’, prune\_z=True)  
meshio.write(‘cf.xdmf’, tetra\_mesh)

The mesh in Hypermesh:

 ![image](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/6/64dcfdb313d8d620c345be82dffafd6e2c8ccbc9.jpeg)

But in GMSH mesh only have label 0

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [July 5, 2021, 4:01pm UTC](https://fenicsproject.discourse.group/t/how-to-export-a-nas-from-hypermesh-and-import-to-gmsh-with-label/6102/2 "2021-07-05T16:01:00Z")

</div>

So a few things you need to clarify here:

1. Is the problem that when you export the mesh to msh, it looses the cell data, or
2. Reading in the cell data with msh is not converted to the appropriate mf, cf file?

If 1. is the problem, I think you need to ask the [hypermesh community](https://community.altair.com/community).  
if 2. is the problem, I would suggest asking the developers of meshio, or add a minimal `msh` file that illustrates the issue to the issue (try making a simple geometry with less than 20 cells).

---

<div class="post-metadata">

**Author:** ![YYWayne](https://avatars.discourse-cdn.com/v4/letter/y/ad7895/32.png) [@YYWayne](https://fenicsproject.discourse.group/u/YYWayne)\
**Post date:** [July 16, 2021, 3:04am UTC](https://fenicsproject.discourse.group/t/how-to-export-a-nas-from-hypermesh-and-import-to-gmsh-with-label/6102/3 "2021-07-16T03:04:10Z")

</div>

Thanks for you reply!  
I have managed to solve this problem by adding ‘properties’ for meshes in Hypermesh, thus provide a label readable by meshio.
