有什么方法可以使用gnuplot可视化自适应网格上的字段?

问题描述

我是gnuplot的初学者。最近,我试图可视化自适应网格上的压力场。

enter image description here

首先,我获得了节点和单元格中心的坐标以及在单元格中心的压力值。

enter image description here

而且,我发现一些难以处理的事情。那就是x和y方向的坐标不规则,这让我很难准备源数据的格式。对于规则且相等的矩形情况,我可以像执行x-y-z格式一样。但是在自适应网格中是否有成功的案例?

解决方法

我了解您有一些x,y,z数据,这些数据不在规则的网格中(嗯,您的自适应网格)。 我不确定这是否是您要找的东西,但是 gnuplot可以为您网格化数据,即在常规网格内对数据进行插值/外推,然后将其绘制出来。 选中help dgrid3d

代码:

### grid data
reset session

# create some test data
set print $Data
    do for [i=1:200] {
        x = rand(0)*100-50
        y = rand(0)*100-50
        z = sin(x/15)*sin(y/15)
        print sprintf("%g %g %g",x,y,z)
    }
set print

set view equal xyz
set view map
set multiplot layout 1,2

    set title "Original data with no regular grid"
    unset dgrid3d
    splot $Data u 1:2:3 w p pt 7 lc palette notitle
    
    set title "Gridded data"
    set dgrid3d 100,100 qnorm 2
    splot $Data u 1:2:3 w pm3d

unset multiplot
### end of code

结果:

enter image description here

,

如果具有每个单元格的大小,则可以使用“ boxxyerror”绘图样式。设xdelta和ydelta为沿x轴和y轴的单元格大小的一半。

figure to show xdelta and ydelta

脚本:

$datablock <<EOD
# x y xdelta ydelta pressure
 1  1 1 1 0
 3  1 1 1 1
 1  3 1 1 1
 3  3 1 1 3
 2  6 2 2 4
 6  2 2 2 4
 6  6 2 2 5
 4 12 4 4 6
12  4 4 4 6
12 12 4 4 7
EOD

set xrange [-2:18]
set yrange [-2:18]

set palette maxcolors 14
set style fill solid 1 border lc black 

plot $datablock using 1:2:3:4:5 with boxxyerror fc palette title "mesh",\
     $datablock using 1:2 with points pt 7 lc rgb "gray30" title "point" 

pause -1

在此脚本中,为“ boxxyerror”图提供了5列数据(x,y,xdelta,ydelta,压力)。要为单元着色,需要使用“ fc调色板”选项。

结果:

figure resulted from the script

我希望这个数字是您想要的。

谢谢。