MATLAB: Mapping 3D velocity data onto a uniform grid

cfdmeshgrid

I am trying to map 3D velocity data from a non-uniform computational fluid dynamics (CFD) mesh grid onto a uniform Cartesian grid. The CFD data is generated using adaptive meshing, and therefore local grid density changes with every time step. However, I need results from each time step on the same Cartesian grid for input into another program.
I have created a uniform grid using meshgrid and then tried interp3 for mapping the data to the new grid. However, I haven't been successful in this approach because of difficulties interpolating from a non-uniform grid. Is there a more appropriate function that I could try?

Best Answer

Try this
[Xq,Yq,Zq] = meshgrid(min(x):0.001:max(x),min(y):0.001:max(y),min(z):0.001:max(z));
Uq = griddata(x,y,z,u,Xq,Yq,Zq);
Vq = griddata(x,y,z,v,Xq,Yq,Zq);
Wq = griddata(x,y,z,w,Xq,Yq,Zq);
quiver3(Xq(:),Yq(:),Zq(:),Uq(:),Vq(:),Wq(:))