Trying to get a contour plot from CFD ASCII data
이전 댓글 표시
Hello everyone. I am trying to use MATLAB as a post processor to visualize my CFD simulation results. I use ANSYS Fluent as the solver and I exported ASCII data (on the node) of certain quantities (velocity, vorticity etc). Now, I am interested in getting a 2D filled contour so I am using the contourf function.
The problem is that I make use of the command griddata for interpolation and meshgrid to generate a rectangular mesh (b/w min and max x and y). But my problem domain inherently is not rectangular but something like this . So of course, griddata interpolates values into regions where there should be none at all. Does anyone know of any workaround for this? Ideally, I would want the meshgrid itself to be oriented exactly to my domain and not be rectangular so that whatever interpolation griddata does, it is only inside the actual domain.
I have attached the code below.
clc
clear
close all
files = dir('*dat');
for i = 1 : 10
fname = files(i+1).name;
A{i} = dlmread(fname,'',1,1);
A{i}(:,3) = 0; % set all z coordinates to absolute zero for consistency
end
x = A{1}(:,1);
y = A{1}(:,2);
n = 500; % number of grid points
xx = linspace(min(x),max(x),n);
yy = linspace(min(y),max(y),n);
[xi,yi] = meshgrid(xx,yy);
for i = 1:10
quantity = A{i}(:,5);
zi = griddata(x,y,quantity,xi,yi);
zi(zi == 0) = NaN;
contourf(xi,yi,zi,50,'Linestyle','none')
set(gcf,'units','normalized','outerposition',[0 0 1 1]);
axis equal
xlabel('X');
ylabel('Y');
colormap('jet');
colorbar
pause(0.1);
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!