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

As far as I can tell you would like to have a 3D mesh (tetrahedrons). Then you also need to mark the volumes:

// Gmsh project created on Tue May 18 16:34:55 2021
SetFactory("OpenCASCADE");
//+
Circle(1) = {0, 00, 00, 0.6, 0, 2*Pi};
//+
Circle(2) = {0, 00, 00, 0.4, 0, 2*Pi};
//+
Curve Loop(1) = {1};
//+
Curve Loop(2) = {2};
//+
Plane Surface(1) = {1, 2};
//+
Extrude {0, 0, 10} {
  Curve{2}; Curve{1}; Layers {1}; Recombine;
}
//+
Curve Loop(5) = {6};
//+
Curve Loop(6) = {4};
//+
Plane Surface(4) = {5, 6};
//+
Physical Surface("Brime", 7) = {2};
//+
Physical Surface("AirSide", 8) = {3};
//+
Physical Surface("Top", 9) = {1};
//+
Physical Surface("Bottom", 10) = {4};
//+
Surface Loop(1) = {2, 4, 3, 1};
//+
Volume(1) = {1};
//+
Physical Volume(11) = {1};

This file, converted to msh with gmsh 4.6.0,
reads nicely with:

import meshio


msh = meshio.read("cylinderv5.msh")


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


tetra_mesh = create_mesh(msh, "tetra")
triangle_mesh = create_mesh(msh, "triangle")
meshio.write("mesh.xdmf", tetra_mesh)

meshio.write("mf.xdmf", triangle_mesh)
2 Likes