Cannot read VTU file with `The data array in the element may be too short.` message

I have a following python script to take the time-average of XDMF file, which works completely fine with my MacBook Pro.

#### import the simple module from the paraview
from paraview.simple import *
from pathlib import Path
import argparse
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()

def parse_command_line_args() -> argparse.Namespace:
    parser = argparse.ArgumentParser()
    parser.add_argument("--input_path", type=str, required=True)
    return parser.parse_args()


def compute_time_average(input_path):

    print(" -- Reading file: ", input_path)
    xdmf_file = XDMFReader(FileNames=[input_path])
    print(" -- File read successfully")
    # create a new 'Temporal Statistics'
    print(" -- Computing time average")
    temporalStatistics1 = TemporalStatistics(registrationName='TemporalStatistics1', Input=xdmf_file)
    # Properties modified on temporalStatistics1
    temporalStatistics1.ComputeMinimum = 0
    temporalStatistics1.ComputeMaximum = 0
    temporalStatistics1.ComputeStandardDeviation = 0
    output_path = input_path.replace('.xdmf', '_time_average.vtu')
    # save data
    SaveData(output_path, proxy=temporalStatistics1, DataMode='Ascii')
    print(" -- Time average computed successfully and saved to: ", output_path)
    
    # delete objects
    del xdmf_file
    del temporalStatistics1


def main():
    args = parse_command_line_args()
    compute_time_average(args.input_path)


if __name__ == "__main__":
    main()

However, when I use this on the cluster, some files cannot be read with the following message.
A few files were fine, but most of the files throw the same error message. I opened up .vtu file and checked the number of components, but cannot really find any problem.

ERROR: In /opt/glr/paraview/paraview-ci/build/superbuild/paraview/src/VTK/IO/XML/vtkXMLDataReader.cxx, line 410
vtkXMLUnstructuredGridReader (0x167254170): Cannot read point data array "displacement_25_to_1000_amplitude_average" from PointData in piece 0.  The data array in the element may be too short.

In this google drive, you can find working and not-working VTU files.

https://drive.google.com/drive/folders/1-UU466lmmwOG1ep98IoN6Jcr0Edz8veR?usp=sharing

Opens fine with ParaView 5.12.0 Linux binary release:

Which version of paraview are you using on your cluster ?

1 Like

On the cluster, I first tried ParaView-5.12.0-egl-MPI-Linux-Python3.10-x86_6 but got an error

malloc_consolidate(): invalid chunk size
error: exception occurred: Subprocess aborted

So, I switched to ParaView-5.10.1-egl-MPI-Linux-Python3.9-x86_64, which did not give an error but the file was corrupted.

I’m using the cluster to generate .vtu file and read it on my local Mac computer after downloading. I tried Paraview 5.10, 5.11, 5.12 on my Mac but none of them was able to read this vtu file.

Update: I managed to run with ParaView-5.12.0-egl-MPI-Linux-Python3.10-x86_6 but the problem still happens when I tried to read on my Mac.

I found a solution to this problem. Opening the .vtu file, I noticed that

<DataArray type="Float32" Name="displacement_25_to_1000_amplitude_average" NumberOfComponents="3" format="ascii" RangeMin="0" RangeMax="3.0032659276248584e-7">

type was Float32. Changing it to Float64 manually solved the problem.

@mwestphal Could you please let me know how to specify the type when saving data?

Using a Calculator should let you do that but since is not really a fix imo.

1 Like

Thanks for the answer. Yes, that’s not really a fix but will do the job for me. Not sure if this is a bug that needs to be reported.

Have you considered writing out the data in binary format instead of ASCII format? I suspect there is a parse error somewhere when reading in the text representation of numbers.

1 Like

Thank you so much! It solved my problem!:slight_smile: