Hello,
When I try to convert my 3D structured mesh from .msh to .xdmf format, only some physical surfaces are kept (groups 101 to 103 when we should have groups from 101 to 107). For the conversion, I used the following code from the FEniCS tutorial, and added a line to print the different physical surfaces of the mesh:
import meshio
import numpy as np
# Read in mesh
msh = meshio.read("3Dmesh/3Dblock.msh")
# Helper function to extract the cells and physical data
def create_mesh(mesh, cell_type, prune_z=False):
cells = mesh.get_cells_type(cell_type)
cell_data = mesh.get_cell_data("gmsh:physical", cell_type)
points = mesh.points[:,:2] if prune_z else mesh.points
out_mesh = meshio.Mesh(points=points, cells={cell_type: cells}, cell_data={"name_to_read":[cell_data]})
return out_mesh
print(np.unique(msh.cell_data_dict['gmsh:physical']['quad']))
print(np.unique(msh.cell_data_dict['gmsh:physical']['hexahedron']))
# Convert mesh to XDMF
quad_mesh = create_mesh(msh, "quad", prune_z=False)
meshio.write("3Dmesh/3Dblock_facet_mesh.xdmf", quad_mesh)
hexahedron_mesh = create_mesh(msh, "hexahedron", prune_z=False)
meshio.write("3Dmesh/3Dblock_mesh.xdmf", hexahedron_mesh)
Output:
[1]
[101 102 103]
In the header of the .msh file, the number of physical surfaces is indicated correctly:
Do you have any idea where the problem could come from? Could this be due to the fact that the mesh is structured?
Thanks a lot for your help!