hi,
im trying to import a msh files but once i run it gives me the following error
Traceback (most recent call last):
File “/home/mirialex/PycharmProjects/fibers/31-05-24.py”, line 11, in
tet_data = msh.cell_data_dict[“gmsh:physical”][“tetra”]
KeyError: ‘gmsh:physical’
attaching the file and also the code
import meshio
from fenics import *
mesh_name = "godplease2"
# Read the mesh file
msh = meshio.read(mesh_name + ".msh")
# Write the volume mesh to XDMF
if "tetra" in msh.cells_dict:
tet_data = msh.cell_data_dict["gmsh:physical"]["tetra"]
meshio.write(mesh_name + ".xdmf",
meshio.Mesh(points=msh.points,
cells=[("tetra", msh.cells_dict["tetra"])],
cell_data={"dom_marker": [tet_data]}
)
)
# Write the surface mesh to XDMF
if "triangle" in msh.cells_dict:
tri_data = msh.cell_data_dict["gmsh:physical"]["triangle"]
meshio.write(mesh_name + "_surf.xdmf",
meshio.Mesh(points=msh.points,
cells=[("triangle", msh.cells_dict["triangle"])],
cell_data={"bnd_marker": [tri_data]}
)
)
# Read the volume mesh into FEniCS
mesh = Mesh()
with XDMFFile(mesh_name + ".xdmf") as file:
file.read(mesh)
# If needed, read the surface mesh (example for boundary conditions)
bnd_mesh = Mesh()
with XDMFFile(mesh_name + "_surf.xdmf") as file:
file.read(bnd_mesh)
since im having a real hard time of create a cylinder inside a box i tried to do it directly in gmsh and then to import it and start analyzing it
so if you have any tips how to continue i would be more that happy to read
well i cant attach the msh file, but hope that what i wrote here would be helpful