Need help converting GMSH to FEniCS

Please note that you have some errors in your geo-file, i.e.

Correcting these, and adding

Physical Surface("surf", 1) = {2};

at the end, the following file (mesh.geo)

// Gmsh project created on Thu Nov 18 16:23:27 2021
SetFactory("OpenCASCADE");
Rectangle(1) = {0, 0, 0, 18, 6, 0};
Point(5) = {3, 2.8, 0, 0.05};
Point(6) = {3, 3.2, 0, 0.05};
Point(7) = {3.3464, 3.4, 0, 0.05};
Point(8) = {3.3464, 2.6, 0, 0.05};
Point(9) = {3.6928, 2.8, 0, 0.05};
Point(10) = {3.6928, 3.2, 0, 0.05};
Point(11) = {3.6928, 3.2, 0, 0.05};
Line(5) = {6, 7};
Line(6) = {10, 9};
Line(7) = {9, 8};
Line(8) = {8, 5};
Line(9) = {5, 6};
Line(10) = {7, 10};
Curve Loop(2) = {4, 1, 2, 3};
Curve Loop(3) = {5, 10, 6, 7, 8, 9};
Plane Surface(2) = {2, 3};
Physical Curve("inlet", 11) = {4};
Physical Curve("outlet", 12) = {2};
Physical Curve("top", 13) = {3};
Physical Curve("bottom", 14) = {1};
Physical Curve("hex", 15) = {5, 6, 7, 8, 9, 10};
Physical Point("points", 16) = {4, 1, 3, 2, 5, 6, 7, 10, 9, 8};
Physical Curve("curves", 17) = {4, 3, 1, 2, 9, 5, 8, 10, 6, 7};
Physical Surface("surf", 1) = {2};

can be read and converted with:

import meshio
import numpy
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


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

mesh_out = create_mesh(mesh, "triangle", prune_z=True)
meshio.write("mesh.xdmf", mesh_out)