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

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:

But in GMSH mesh only have label 0

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.
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).

1 Like

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.

1 Like