Reading a mesh stored in XDMF format with multiple cell_data

Hi,

See the corresponding binder notebook for reproducing the error (tried several different ways but the same error).

I have been trying to store cell_data to load into MeshValueCollection and then create corresponding MeshFunctions as follows:

from dolfin import *
msh = Mesh()
mvc = MeshValueCollection("size_t", msh, 3)
mvc2 = cpp.mesh.MeshValueCollection_double(msh, 3)
mvc3 = cpp.mesh.MeshValueCollection_double(msh, 3)
with XDMFFile(comm, os.path.join(workDir, "SphereinCube.xdmf")) as infile:
    infile.read(msh)
    infile.read(mvc, "domains")
    infile.read(mvc2, "mu") # it throws the following error here 
    infile.read(mvc3, "eta")

domainMarks = MeshFunction("size_t", msh, mvc) 
# muFunc = MeshFunction("double", msh, mvc2)
# etaFunc = MeshFunction("double", msh, mvc3)
*** Error:   Unable to recognise cell type.
*** Reason:  Unknown value "".

I checked the XDMF file and it has the required attributes:

<Xdmf Version="3.0"><Domain><Grid Name="Grid"><Information Name="Information" Value="0">
<![CDATA[<main />]]>
</Information><Geometry GeometryType="XYZ"><DataItem DataType="Float" Dimensions="8737 3" Format="HDF" Precision="8">SphereinCube.h5:/data0</DataItem></Geometry><Topology NumberOfElements="43650" TopologyType="Tetrahedron"><DataItem DataType="Int" Dimensions="43650 4" Format="HDF" Precision="4">SphereinCube.h5:/data1</DataItem></Topology><Attribute AttributeType="Scalar" Center="Cell" Name="domains"><DataItem DataType="Int" Dimensions="43650" Format="HDF" Precision="4">SphereinCube.h5:/data2</DataItem></Attribute><Attribute AttributeType="Scalar" Center="Cell" Name="mu"><DataItem DataType="Float" Dimensions="43650" Format="HDF" Precision="8">SphereinCube.h5:/data3</DataItem></Attribute><Attribute AttributeType="Scalar" Center="Cell" Name="eta"><DataItem DataType="Float" Dimensions="43650" Format="HDF" Precision="8">SphereinCube.h5:/data4</DataItem></Attribute></Grid></Domain></Xdmf>

and loads fine in Paraview

And ideas on what could be going wrong ?

Save the different domain data in multiple files, that avoids this issue. As far as I can tell the read function is only able to read the first set of attributes of a given dimension.

1 Like