Skip to content

Importing Data to ParaView

Xiaolong Du edited this page Oct 1, 2021 · 7 revisions

HDF5

ParaView can read XDMF files which provide a specification of how to read data from your HDF5 files.

An example for wrapping dataset stored in [HDF5] file in a [XDMF] file

Suppose you have some data, e.g. density field, defined on a uniform grid from your simulation, and they are stored in a [HDF5] file, you can create a [XDMF] file which contains the information of the dataset. The [XDMF] file can then be used by ParaView to load the data. An example of the [XDMF] file can be found below

<?xml version="1.0" ?>
<!DOCTYPE Xdmf SYSTEM "Xdmf.dtd" []>
<Xdmf Version="2.0">
  <Domain>
    <Grid Name="Simulation" GridType="Uniform">
      <Topology TopologyType="3DCoRectMesh" Dimensions="256 256 256"/>
      <Geometry GeometryType="ORIGIN_DXDYDZ">
        <DataItem DataType="Float" Dimensions="3" Format="XML">0.0 0.0 0.0</DataItem>
        <DataItem DataType="Float" Dimensions="3" Format="XML">1.0 1.0 1.0</DataItem>
      </Geometry>
      <Attribute Name="density" AttributeType="Scalar" Center="Node">
        <DataItem Dimensions="256 256 256" NumberType="Float" Precision="8" Format="HDF">simulation_data.h5:density</DataItem>
      </Attribute>
    </Grid>
  </Domain>
</Xdmf>

First, we need to define the Topology and Geometry of the box. In the example above, we have a box of size (1,1,1). The data are defined on a uniform 256^3 grid.

Then we add the information of the data to an Attribute. We need to specify the Dimensions, NumberType, Precision and Format of the dataset. Finally, simulation_data.h5:density specifies the name of [HDF5] file and the name of the dataset in the file.

Now your data are ready to use in ParaView. Just put the [XDMF] file and the [HDF5] in the same folder.

Clone this wiki locally