Hi everyone
I have an issue with the markers when generating GMSH from text files using Meshio. Precisely, I have mesh information stored in text files like ‘node1.txt’ storing nodes coordinates, ‘elements1.txt’ storing mesh connectivity and makers. The code below will used for generating GMSH mesh.
Files: node1.txt, elements1.txt
import meshio
import numpy as np
# read data
list_nodes = np.loadtxt('nodes1.txt', delimiter=" ")
list_elements = np.loadtxt('elements1.txt', dtype="i", delimiter=" ")
# define points
points = list_nodes
# define cells
cells = [ ("triangle", list_elements[:, 0:3]-1) ]
# define cell_data
cell_data_value = []
e1 = list_elements[:, -1][0]
tmp = []
# get maker
for e in list_elements[:, -1]:
if e == e1:
tmp.append(e)
else:
cell_data_value.append(np.asarray(tmp))
e1 = e
tmp = []
tmp.append(e)
cell_data = {'gmsh:physical': cell_data_value}
# generate gmsh mesh
meshio.write_points_cells(
"new_machine.msh",
points,
cells,
cell_data=cell_data
)
The markers are not complete, as shown in picture below.
If you know how to fix this issue, please let me know.
Best regards