FEniCS / dolfinx

Next generation FEniCS problem solving environment
https://fenicsproject.org
GNU Lesser General Public License v3.0
731 stars 177 forks source link

error reading mesh topology from HDF5 dataset #2123

Closed GC-enriched closed 2 years ago

GC-enriched commented 2 years ago

Hi there, I'm using the latest Spack release of dolfinx and having trouble reading an Xdmf (version 3) file pointing to an HDF5:

HDF5-DIAG: Error detected in HDF5 (1.12.1) MPI-process 0:
  #000: /tmp/user/spack-stage/spack-stage-hdf5-1.12.1-aj6pmbfo67voycj7ong2lbomgfv6h4kb/spack-src/src/H5D.c line 276 in H5Dopen2(): invalid location identifier
    major: Invalid arguments to routine
    minor: Inappropriate type
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/media/user/EMTEC C410/MC/dev/shielding.py", line 177, in solve_weak_Smoluchowski
    dolfin_mesh = xdmf.read_mesh(name='Grid')
  File "/home/user/spack/var/spack/environments/fenicsx-env/.spack-env/view/lib/python3.9/site-packages/dolfinx/io.py", line 50, in read_mesh
    cells = super().read_topology_data(name, xpath)
RuntimeError: Failed to open HDF5 dataset by name

Here's my Xdmf:

<Xdmf Version="3.0">
    <Domain>
        <Grid Name="Grid">
            <Geometry GeometryType="XYZ">
                <DataItem DataType="Float" Dimensions="2935 3" Format="HDF" Precision="8">
                MC_TetMesh_2_slim.h5:/data0
                </DataItem>
            </Geometry>
            <Topology TopologyType="Tetrahedron" NumberOfElements="11487" NodesPerElement="4">
                <DataItem DataType="Int" Dimensions="11487 4" Format="HDF" Precision="8">
                MC_TetMesh_2_slim.h5:/data1
                </DataItem>
            </Topology>
            <Attribute Name="cell_scalars" AttributeType="Scalar" Center="Cell">
                <DataItem DataType="Int" Dimensions="11487" Format="HDF" Precision="4">
                MC_TetMesh_2_slim.h5:/data2
                </DataItem>
            </Attribute>
        </Grid>
    </Domain>
</Xdmf>

The Xdmf mesh is visualizable in Paraview so I assume the error should be when FEniCS tries to read the HDF5 file (which is compressed with gzip). Is H5Dopen2 expecting another syntax for the HDF5 reference? Thanks for the help.

MC_TetMesh_2_slim.h5.gz

jorgensd commented 2 years ago

Could you provide the whole xdmf file as one would need to see which grid the Grid the topology is situated in.

GC-enriched commented 2 years ago

Edited. Sorry about that

jorgensd commented 2 years ago

I would Need the h5 dataset as well.

jorgensd commented 2 years ago

@GC-enriched I cannot reproduce this error using the docker image dolfinx/dolfinx:

import dolfinx 
from mpi4py import MPI
with dolfinx.io.XDMFFile(MPI.COMM_WORLD, "MC_TetMesh_2_slim.xdmf", "r") as xdmf:
    mesh = xdmf.read_mesh(name = "Grid")

print(mesh.topology.index_map(mesh.topology.dim).size_local)

prints 11487 matching the number of cells in your mesh (by inspecting it in Paraview). This means that something has gone wrong with the hdf5 installation in spack.

The docker image uses: HDF5_SERIES=1.12 HDF5_PATCH=1 which matches the one in your spack.

@chrisrichardson Do you have any ideas?

GC-enriched commented 2 years ago

Solved, was an error on my side, thanks!