4

I'm trying to use a xdmf file for Paraview to get data from a hdf5 file. I have one of the variable in an array that contains 2 values and I need to use the first one. For that I have tried to use a Function but can't figure out how to use it. So if I do that :

<Attribute Name="rho" Center="Cell" AttributeType="Scalar">
    <DataItem Format="HDF" Precision="8" Dimensions="2">
        test.h5:/variables/rho_cell
    </DataItem>
</Attribute>

Paraview gives a warning that I have an array with 2 values while I have only one cell (this warning was expected). So I have added a Function like that :

<Attribute Name="rho" Center="Cell" AttributeType="Scalar">
    <DataItem ItemType="Function" Function="$0[1:2]" Dimensions="1">
        <DataItem Format="HDF" Precision="8" Dimensions="2">
            test.h5:/variables/rho_cell
        </DataItem>
    </DataItem>
</Attribute>

And with that Paraview crashes (no error message). To be honest I'm not even sure if the array indexing is like in python (start at 0 and 0:1 means only the first element)... and I can't find any help on that. I have tried almost any combination of parameters but nothing seem to work.

To be sure that my function syntax is not completely wrong I have tried that :

<Attribute Name="rho" Center="Cell" AttributeType="Scalar">
    <DataItem ItemType="Function" Function="$0 + 1.5" Dimensions="2">
        <DataItem Format="HDF" Precision="8" Dimensions="2">
            test.h5:/variables/rho_cell
        </DataItem>
    </DataItem>
</Attribute>

And it works, but obviously still give the warning about the number of cells.

Thomas Leonard
  • 1,047
  • 11
  • 25

2 Answers2

1

Have you tried using a Coordinates DataItem?

<Attribute Name="rho" Center="Cell" AttributeType="Scalar">
    <DataItem ItemType="Coordinates" Dimensions="2" Type="Coordinates">
        <DataItem Format="XML" Dimensions="1">
            0
        </DataItem>
        <DataItem Format="HDF" Precision="8" Dimensions="2">
            test.h5:/variables/rho_cell
        </DataItem>
    </DataItem>
</Attribute>
Yossarian
  • 5,226
  • 1
  • 37
  • 59
  • I didnt try your solution cause it would be too exhaustive for a huge mesh with a lot of cells but it pointed me in the right direction. I found that you can specify a part of an array using an HyperSlab (instead of a function). – Thomas Leonard Nov 28 '15 at 00:09
1

I found that you can specify a part of an array using an HyperSlab (instead of a function). Here is the code for it :

<Attribute Name="ro" Center="Cell" AttributeType="Scalar">
    <DataItem ItemType="HyperSlab" Dimensions="1" Type="HyperSlab">
        <DataItem Dimensions="3 1" Format="XML">
            0
            1
            1
        </DataItem>
        <DataItem Format="HDF" Precision="8" Dimensions="2">
            test.h5:variables/rho_cell
        </DataItem>
    </DataItem>
</Attribute>
Thomas Leonard
  • 1,047
  • 11
  • 25