[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gnuplot-info
Subject:    Re: [Gnuplot-info] unexpected difference between plot and splot of binary files with unstructured da
From:       cédric_ody <cedric.listes () gmail ! com>
Date:       2013-12-09 14:41:47
Message-ID: CA+DdpC1htO9Xr-CZM-Qf7G73pQJyyVJ1reW2nxiVEfCQYVsynA () mail ! gmail ! com
[Download RAW message or body]

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.
>

------------------------------------------------------------------------------
Sponsored by Intel(R) XDK 
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
gnuplot-info mailing list
gnuplot-info@lists.sourceforge.net
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic