Mapping 3D velocity data onto a uniform grid
6 views (last 30 days)
Show older comments
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?
2 Comments
Accepted Answer
jonas
on 4 Oct 2018
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(:))
4 Comments
jonas
on 8 Oct 2018
Oh I understand. The data is being interpolated. It's not too difficult to remove those points again. Let x,y,z be your original scattered data pts and X,Y,Z your new grid
%%3d boundary
tri = delaunayn([x y z]);
%%find points inside of 3d boundary
tn = tsearchn([x y z], tri, [X(:) Y(:) Z(:)]);
IsInside = ~isnan(tn)
You can then set the points outside of the original boundary to NaN, and you are golden. You can also have a look at this Q ( link )
More Answers (0)
See Also
Categories
Find more on Volume Visualization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
