def METHOD_NAME(tempdir, encoding):
    try:
        import gmsh
    except ImportError:
        pytest.skip()
    if MPI.COMM_WORLD.rank == 0:
        gmsh.initialize()
        model = gmsh.model()
        model.add("test_read_write_p2_mesh")
        model.setCurrent("test_read_write_p2_mesh")
        model.occ.addSphere(0, 0, 0, 1, tag=1)
        gmsh.option.setNumber("Mesh.CharacteristicLengthMin", 0.3)
        gmsh.option.setNumber("Mesh.CharacteristicLengthMax", 0.4)
        model.occ.synchronize()
        model.mesh.generate(3)
        model.mesh.setOrder(2)
        idx, points, _ = model.mesh.getNodes()
        points = points.reshape(-1, 3)
        idx -= 1
        srt = np.argsort(idx)
        assert np.all(idx[srt] == np.arange(len(idx)))
        x = points[srt]
        element_types, element_tags, node_tags = model.mesh.getElements(dim=3)
        name, dim, order, num_nodes, local_coords, num_first_order_nodes = model.mesh.getElementProperties(
            element_types[0])
        cells = node_tags[0].reshape(-1, num_nodes) - 1
        num_nodes, gmsh_cell_id = MPI.COMM_WORLD.bcast(
            [cells.shape[1], model.mesh.getElementType("tetrahedron", 2)], root=0)
        gmsh.finalize()
    else:
        num_nodes, gmsh_cell_id = MPI.COMM_WORLD.bcast([None, None], root=0)
        cells, x = np.empty([0, num_nodes]), np.empty([0, 3])
    domain = ufl_mesh(gmsh_cell_id, 3)
    cell_type = _cpp.mesh.to_type(str(domain.ufl_cell()))
    cells = cells[:, cell_perm_array(cell_type, cells.shape[1])]
    mesh = create_mesh(MPI.COMM_WORLD, cells, x, domain)
    filename = Path(tempdir, "tet10_mesh.xdmf")
    with XDMFFile(mesh.comm, filename, "w", encoding=encoding) as xdmf:
        xdmf.write_mesh(mesh)
    with XDMFFile(mesh.comm, filename, "r", encoding=encoding) as xdmf:
        mesh2 = xdmf.read_mesh()
    topology, topology2 = mesh.topology, mesh2.topology
    assert topology.index_map(0).size_global == topology2.index_map(0).size_global
    assert topology.index_map(topology.dim).size_global == topology2.index_map(topology.dim).size_global