MATLAB: Plotting streamlines in 3D from a non-rectangular grid

gridMATLABstreamline

Hi,
I would like to know if it is possible to plot streamlines in 3D from a non-rectangular grid? In the simple piece of code below, I am creating a structured, but non-rectangular grid and I am associating velocity components to each point by interpolating the data from the built-in wind data. The code runs without any error, but the streamlines do not appear. The starting points are in red in the attached figure, and considering that the flow moves in the positive x direction, the streamlines should appear. I would be grateful if someone could help me on that matter.
Note that I tried the same method with a rectangular sub grid and it worked. Also, note that this is only a simple test case to eventually plot streamlines from some complex CFD simulations (with non-rectangular grids) in Matlab.
Cheers,
Mathias
% Loading the data
load wind
% Data association
x_wind = x; y_wind = y; z_wind = z;
u_wind = u; v_wind = v; w_wind = w;
clear x y z u v w
% Shifting the data
x_wind = x_wind - min(x_wind(:));
y_wind = y_wind - min(y_wind(:));
z_wind = z_wind - min(z_wind(:));
% Creating a structured and curved grid
[theta_grid,r_grid,z_grid] = meshgrid((1:1:80).*pi./180,19:0.5:21,5:0.5:10);
% Converting the mesh to cartesian coordinates
[x_grid,y_grid,z_grid] = pol2cart(theta_grid,r_grid,z_grid);
% Interpolating data from the original mesh
u_grid = griddata(x_wind,y_wind,z_wind,u_wind,x_grid,y_grid,z_grid,'natural');
v_grid = griddata(x_wind,y_wind,z_wind,v_wind,x_grid,y_grid,z_grid,'natural');
w_grid = griddata(x_wind,y_wind,z_wind,w_wind,x_grid,y_grid,z_grid,'natural');
% Settting the starting position of the streamlines
startx_wind = squeeze(x_wind(:,1,:)); starty_wind = squeeze(y_wind(:,1,:)); startz_wind = squeeze(z_wind(:,1,:));
startx_grid = x_grid(1,:,:); starty_grid = y_grid(1,:,:); startz_grid = z_grid(1,:,:);
% Plotting the data
figure
hold on
streamline(x_wind,y_wind,z_wind,u_wind,v_wind,w_wind,startx_wind,starty_wind,startz_wind)
h = streamline(x_grid,y_grid,z_grid,u_grid,v_grid,w_grid,startx_grid,starty_grid,startz_grid); set(h,'Color','r')
plot3(x_grid(:),y_grid(:),z_grid(:),'k.');
plot3(startx_grid(:),starty_grid(:),startz_grid(:),'r.');
hold off
xlabel('x')
ylabel('y')
zlabel('z')
box on; grid on
axis equal

Best Answer

I don't know what is wrong with streamline.however it's not my first time when it's not working (quiver3 works ok by the way)
But you can plot it manually using simple Euler method
x(i+1) = x(i) + dt*v;
See attached script