Problem with Paraview with solution

diego.peinado's picture
Submitted by diego.peinado on Sun, 02/22/2015 - 13:47

Hello. I've found that sometimes when reading in paraview I got the following Warning:

Generic Warning: In /Users/kitware/Dashboards/MyTests/NightlyMaster/ParaViewSuperbuild-Release-Python27/paraview/src/paraview/VTK/IO/Legacy/vtkDataReader.cxx, line 1359
Error reading ascii data. Possible mismatch of datasize with declaration.

When this occurs, only force values are loaded, no velocity, no radius, etc.

Searching in the web I found that it has to do with the numerics of numpy (python library used in pizza), and paraview. The float used in numpy is float64, and sometimes there are numbers like -5.23423e-328. In this case the paraview reader gives the error and stops loading values.

The smaller number paraview reader can load is 1e-38.

The workaround is in dump.py line 418 change from "else: atoms = np.zeros((snap.natoms,ncol),np.float)" to "else: atoms = np.zeros((snap.natoms,ncol),np.float16)". It is necessary to change to float16, because in numpy float32 still has 1e-44, value smaller than paraview can load.

ckloss's picture

ckloss | Mon, 02/23/2015 - 12:35

Hi DIego,

nice to see you came back to LIGGGHTS ;-)
Unfortunately I can't really help with this issue - we're not using Mac at all.
But it might be worthwile to try both the binary and source version of paraview, and maybe also older versions

Cheers
Christoph

diego.peinado's picture

diego.peinado | Wed, 02/25/2015 - 18:36

Hello Christoph, thanks. Only as hobbyist :-)
I'll try compiling the source and older versions, but I think that it has to do with numpy float definition.
By the way, congratulations, the software has evolved a lot in these recent times. I hope your project is succeding as you guys deserve.
Cheers.

Matteo | Tue, 06/07/2016 - 17:22

Unfortunately I have the same problem with Paraview 5.0 in Windows. I spent 3 days now trying to follow the different solutions proposed on the web.
I wrote a script to change all the values smaller than 1e-34 in my vtk files but Paraview kept returning the same warning message.
I tried making the modification to the dump.py file as suggested by diego but now lpp does not generate the vtk files anymore.

Any idea?

Thanks
Matteo

Matteo | Wed, 06/08/2016 - 09:31

Hello,

Problem solved!

As already said, I tried writing a script to find all the values below 1e-34 (or whatever value, I tried even with 1e-15) in the vtk files and change them with 0.0. This was the solution reported in several forums, with the explanation that ParaView could not read float numbers smaller that 1e-34 as it uses float 32 instead of float 64.
Unfortunately, ParaView kept returning warning messages.

I then tried to adopt the solution suggested by diego and also this one failed. I couldn't even generate the vtk files using lpp after the modification to the dump.py. At that point I realized that probably the declaration of "float16" was wrong, and it was!
It seems that numpy uses as default "float64" so, if you specify only "float" it will use 64bit floats numbers.
Also, float16 did not exist in the numpy release I used, under Linux.
I thus basically followed the suggestion given by diego but instead of writing float16, I specified float32.
After this modification I could successfully open the vtk files in ParaView under Windows!

Just to clarify: the vtk files were generated under Linux (I run LIGGGHTS and lpp in a cluster) they were then copied in a Windows workstation for visualisation in ParaView.

Hope to save time to other people as I have had very bad days trying to solve this trouble!

shawnwuch | Tue, 06/28/2016 - 21:40

Just want to show my appreciation to both of your solutions. I ran into the same problem and am so glad to see people posted their solutions here. Thank you!

neven.marticnevic | Mon, 06/19/2017 - 11:45

Hi,

I want to know how to save file after I changed float to float32??? Because "dump.py" is read only.

I want to do that for the same reason as You (on windows Paraview showing me a error because some values are very small example: 1e-300).

After You changed float to float32, do You still need Your script which transform values smaller than 1e-34 to 0.0??

Best regards, Neven.