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