0

我有一个二维 CFD 代码,它给出了网格上每个点的 x 和 y 流速。我目前正在使用 gnuplot 中的矢量场来可视化数据。我的目标是看看喷发后的羽流延伸了多远,所以如果我能阻止矢量在低于一定量级时出现在现场,那会更干净。有谁知道如何去做?我当前的 gnuplot 脚本如下。我还可以根据需要修改输入文件。

reset
set nokey
set term png
set xrange [0:5.1]
set yrange [0:10.1]
do for [i=0:10] {
    set title 'Eruption simulation: Timestep '.i
    set output 'path/FlowVel'.sprintf('%04.0f',i).'.png'
    plot 'path/Flow'.sprintf('%04.0f',i).'.dat' using 1:2:3:4 with vec
}
4

1 回答 1

0

我猜你想要一种 gnuplot 没有的过滤,但可以通过以下技巧来实现(取自 gnuplot 中的“帮助使用示例”):

 One trick is to use the ternary `?:` operator to filter data:

       plot 'file' using 1:($3>10 ? $2 : 1/0)

 which plots the datum in column two against that in column one provided
 the datum in column three exceeds ten.  `1/0` is undefined; `gnuplot`
 quietly ignores undefined points, so unsuitable points are suppressed.
 Or you can use the pre-defined variable NaN to achieve the same result.

所以我想你会想要这样的东西

plot "data.dat" u 1:2:($3**2+$4**2>mag_sq?$3:NaN):($3**2+$4**2>mag_sq?$4:NaN) w vector

其中 mag_sq 是您想要的幅度的平方。

于 2013-03-21T06:31:48.980 回答