@dokken I tried the code but as I was thinking about the physical tags, that came as an error when I implemented the below code by importing my .msh file.
from dolfin import *
import meshio
msh = meshio.read("/home/ratan/Documents/gmsh/mp1.msh")
for cell in msh.cells:
if cell.type == "triangle":
triangle_cells = cell.data
elif cell.type == "tetra":
tetra_cells = cell.data
for key in msh.cell_data_dict["gmsh:physical"].keys():
if key == "triangle":
triangle_data = msh.cell_data_dict["gmsh:physical"][key]
elif key == "tetra":
tetra_data = msh.cell_data_dict["gmsh:physical"][key]
tetra_mesh = meshio.Mesh(points=msh.points, cells={"tetra": tetra_cells})
triangle_mesh =meshio.Mesh(points=msh.points,
cells=[("triangle", triangle_cells)],
cell_data={"name_to_read":[triangle_data]})
meshio.write("mesh.xdmf", tetra_mesh)
meshio.write("mf.xdmf", triangle_mesh)
The error which came:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-11-1b306cf427a8> in <module>
9 tetra_cells = cell.data
10
---> 11 for key in msh.cell_data_dict["gmsh:physical"].keys():
12 if key == "triangle":
13 triangle_data = msh.cell_data_dict["gmsh:physical"][key]
KeyError: 'gmsh:physical'
Kindly suggest me on how do solve this issue.
Thank You