|
From: cédric o. <ced...@gm...> - 2013-12-09 14:41:54
|
Hi all, For those interested in plotting unstructured meshes with gnuplot from *binary* files, I found a trick to solve the issue I submitted in a previous post. I used to do > plot 'file.dat' binary record=(15,-1) format='%float' u 1:2:3 w l palette where the the binary file file.dat was written using octave (fwrite(file,vector,kind)). The 15 is because I plot cells of 5 points of two coordinates + the value at the point (we can do cell or vertex centered as wished). The -1 tells gnuplot to read all records. A cell has thus the structure cell=[ptA ptB ptC ptD ptA] #ptA is repeated to close the cell And I used octave to write the final 1D array vector=[ptAx ptAy ptAval ptBx ptBy ptBval ptCx ptCy ptCval ptDx ptDy ptDval ptAx ptAy ptAval ..]; The problem was that gnuplot does know that we are passing from one element to another one and can draw lines between the last point of an element to the first of the next one in the file. This may be undesirable if for instance two elements are well separated. To prevent gnuplot from such linking and to reproduce the effect of a blank record in ascii file, I have added two copies of an existing first point to the definition of the cells cell=[ptA ptA ptB ptC ptD ptA ptA] Adding the first and last instances of PtA now allows one to attribute some like of a missing value to these 'virtual' points so that the vector containing data reads vector=[ptAx ptAy ptAmissingvalue ptAx ptAy ptAval ptBx ptBy ptBval ptCx ptCy ptCval ptDx ptDy ptDval ptAx ptAy ptAval ptAx ptAy ptAmissingvalue..]; Now I can use something like that using the gnuplot ?: operator and the NaN value 1/0. plot 'tmpbin.dat' binary record=(21,-1) format='%float' u 1:2:($3<missingvalue?$3:1/0) w l pal So that elements are not connected to each other now. The file is a bit bigger but the time to write much decreased. Hope this helps cedric > The plot command gives expected results (I would expect that I have > used an ascii filename). However, the splot command does not as some > cells of the unstructured mesh are now connected although they should > not. > |