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

@Iactor, the problem with your code is your mesh. It is not a connected mesh, and consists of several bits and pieces. In particular, you add extra surfaces over the surfaces defined in the surface mesh.
I’ve rewritten your code, using boolean fragments in gmsh to generate what I think is the desired mesh. Note that in this mesh, elements align over boundaries, which was not the case in your original code.

// Gmsh project created by Jørgen S. Dokken 2020
SetFactory("OpenCASCADE");
Box(1) = {0, 0, 0, 1, 1, .285};
Box(2) = {0.4, 0.4, 0.285, .2, .2, .03};
Box(3) = {0., 0, 0.315, 1, 1, .01};
Box(4) = {0.0, 0.0, 0.325, 1, 1, 1};
v() = BooleanFragments{ Volume{1}; Delete;}{ Volume{2,3,4}; Delete; };
Physical Volume("air", 33) ={#v()};
Physical Volume("hBN", 32) ={#v()-1};
Physical Volume("cavity", 31) ={#v()-2};
Physical Volume("substrate", 30) ={#v()-3};
Physical Surface("backgate", 34) = {29};
Physical Surface("patterned_gate", 29) = {18, 23};

This mesh and the corresponding volume and facet data loads into FEniCS as they should. On the usage of gmsh i suggest reading through the tutorials.

4 Likes