Transitioning from mesh.xml to mesh.xdmf, from dolfin-convert to meshio

You are not concatenating data stemming from different cell blocks.
You have not followed the instructions in:

Need help converting GMSH to FEniCS - #8 by dokken

To repost this again:

import meshio


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)
    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("two_cantilever.msh")
facet_mesh = create_mesh(msh, "triangle", prune_z=True)
meshio.write("facet_mesh.xdmf", facet_mesh)

triangle_mesh = create_mesh(msh, "tetra", prune_z=True)
meshio.write("mesh.xdmf", triangle_mesh)

Note that you have not used boolean operations on your geometry, resulting in another mesh that what you would like. See: Using subdomains in diffusion equation - #6 by dokken

1 Like