Skip to content

absolute HDF5 file path in XDMF makes ParaView unhappy under Windows #302

Closed
@tianyikillua

Description

@tianyikillua
import numpy as np
import meshio

points = np.array([[0, 0],
                   [1, 0],
                   [0, 1]])  # thanks to meshio 2.2.5 I can now use 2d points
cells = {"triangle": np.array([[0, 1, 2]], dtype=int)}
meshio.write_points_cells("D:/test.xdmf", points, cells)

If you run this script in a different path than D:/, you will end up having D:/test.xdmf like this

<Xdmf Version="3.0">
  <Domain>
    <Grid Name="Grid">
      <Geometry GeometryType="XY">
        <DataItem DataType="Int" Dimensions="3 2" Format="HDF" Precision="4">D:\test.h5:/data0</DataItem>
      </Geometry>
      <Topology NumberOfElements="1" TopologyType="Triangle">
        <DataItem DataType="Int" Dimensions="1 3" Format="HDF" Precision="4">D:\test.h5:/data1</DataItem>
      </Topology>
    </Grid>
  </Domain>
</Xdmf>

where the HDF5 file is indicated by its absolute path, and this makes ParaView crash everytime I load this XDMF file (not sure if it is due to the presence of \ or :, replacing \ by / doesn't make it happy).

Maybe it's simply better (and simpler) to use just its basename since these two files are always put together. Under FEniCS (XDMFFile.cpp) it is done this way (only the basename, i.e. just the filename without the path).

So line 440, do

return os.path.basename(self.h5_filename) + ":/" + name

I could upload a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions