File Exchange

image thumbnail

Transform velocity field into wall coordinates

version (6.93 KB) by Alessandro Masullo
Interpolate velocity field on a wall-based grid. Useful to plot boundary layer

1 Download

Updated 09 Feb 2016

View License

[xw,yw,uw,vw,xgr,ygr,ugr,vgr] = VELOCITYPROFILE(xwall,ywall,x,y,u,v,height,varargin)
Interpolates the velocity field provided by [x,y,u,v] on a grid generated
as an offset of a 2D curve [xwall,ywall] and transforms the interpolated
field into wall coordinates, rotating each vector according to the wall
Typical example: plot of the boundary layer of an airfoil, provided the
velocity field and the airfoil points.

[xwall,ywall] are the coordinates of the wall

[x,y,u,v] are the points and the components of the velocity field (can be
both structured or unstructured)

[height] is the extent of the profile in the direction normal to the

Additional input arguments are:

[Nh] is number of points in which the grid is discretised vertically.
Default value is 20

[Nw] is number of points in which the grid is discretised horizontally.
By default, the points provided for the wall are used to generate the
grid. If Nw is specified, wall points are interpolated in Nw new

[interp_type]: type of interpolant ('nearest', 'linear' or 'natural'), see
scatteredInterpolant for additional info on the interpolation method.
Values outside the velocity field will always be linarly extrapolated

[graphic_mode]: true or false, create two figures with the velocity data
to show the result of the conversion

Output arguments
[xw,yw,uw,vw]: are the points and the components of the velocity data
rotated into wall coordinates. The first elements of uw and vw are the
velocities for the first point of the provided wall. Elements for the
successive columns are the velocities on the successive elements of the

[xgr,ygr,ugr,vgr]: are the points and the components of the velocity data
interpolated on the wall generated grid, before the coordinate

Additional info
The direction in which the mesh is extended can be changed flipping the
wall points direction. See fliplr

The interpolation is performed using the scatteredInterpolant function,
which uses a Delaunay triangulation. If no vectors are provided on the
wall, those values will be interpolated (or extrapolated) using a
Delaunay triangulation of the entire flow field. See help
scatteredInterpolant for more information.

Run the code without any input argument to see an example

Author: Alessandro Masullo 2016

Comments and Ratings (0)

MATLAB Release Compatibility
Created with R2015a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: inpaint_nans, interparc

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor