Labels of the element in h5/XDMF file

I have a XDMF file that contains three 3 different sets of data: the coordinates of the vertices of a mesh, the vertices of the elements of the mesh, and the labels of the elements (either 1 or 2). When I load the mesh using the following code:

mesh = Mesh()
with XDMFFile(“test.xdmf”) as infile:

I can view/use the vertices using mesh.coordinates( ) and the elements using mesh.cells( ) but I cannot find where the third set of data is contained. Is it possible to view/use the labels of the elements in the mesh?

See for instance: Bitbucket
Or Bitbucket

Are those two lines in addition to what I am currently running or instead of? Can the cell data then be used to create mesh subdomains?

These lines are in addition to what you are currently running, i.e.

mesh = Mesh()
with XDMFFile(“test.xdmf”) as infile:
mf_in = MeshFunction("size_t", mesh, mesh.topology().dim())
with XDMFFile(mesh.mpi_comm(), "test.xdmf") as xdmf:, "cells")

As they are read into a mesh function, they can be used in all the same ways as a mesh function defined using subdomains in python.

Using this I get the error:

*** -------------------------------------------------------------------------
*** Error:   Unable to open MeshFunction for reading.
*** Reason:  Mesh Grid with data Attribute not found in XDMF.
*** Where:   This error was encountered inside XDMFFile.cpp.
*** Process: 0
*** DOLFIN version: 2019.1.0
*** Git changeset:  
*** -------------------------------------------------------------------------

The same error message popped up in Fluent.msh to XDMF; error was it ever resolved?

You need to post your XDMFFile such that one can inspect the data structure of it for anyone to be able to help you.
Following: Bitbucket
you can see that the XDMF reader expects the cell data to be attached to XDMF/domain/grid/attribute

The XDMFFile reads as follows:

<Xdmf Version="3.0">
       <Grid Name="Grid">
           <Geometry GeometryType="XYZ">
                <DataItem DataType="Float" Dimensions="3064 3" Format="HDF" Precision="4">
           <Topology TopologyType="Tetrahedron" NumberOfElements="12644" NodesPerElement="4">
                <DataItem DataType="Int" Dimensions="12644 4" Format="HDF" Precision="4">
           <Attribute Name="labels" AttributeType="Scalar" Center="Cell">
                <DataItem DataType="Int" Dimensions="12644" Format="HDF" Precision="4">

testclasses.h5/data0 is of the format

56.89500046 186.27000427 109.375
56.89500046 191.40600586 104.23899841
53.49889755 189.66600037 105.97899628 ....

testclasses.h5/data1 is of the format

 0    1    2    3
 2    4    0    5
 0    4    2    6....

testclasses.h5/data2 is of the format

 1.   1.   1.   1....

The complete file is in dropbox.