DIRECTION_ARROWS_GRID
Velocity Direction Plot,
Uniform Grid from Scattered Data


DIRECTION_ARROWS_GRID is a MATLAB program which reads velocity data defined at possibly scattered points, and creates a vector direction plot on a uniform grid of user-specified density.

The program is mainly a preprocessor for MATLAB's quiver routine. It reads the (X,Y) coordinates of a set of points from a "node" file, and the corresponding horizontal and vertical velocities from a "velocity" file. It uses MATLAB's griddata facility to create an interpolatory function to the given data. The interpolated function is then sampled on a regular grid. The velocities are divided by their norms to produce velocity directions, and then displayed.

The program is especially useful if simply displaying the original data is unsuitable, perhaps because there are too many points, or too few, or because the density of points varies greatly.

Both the node and velocity files are simple "table" files whose format is described online.

This program was written as a quick and convenient way to view finite element data. It can also be used for any situation in which a collection of points and velocities are available.

However, a small "sin" is committed when we use this program on finite element data, since we take only the node locations and velocities, but not the elements. We simply use MATLAB's grid data feature which constructs a cubic spline interpolant to scattered data. This is OK, and probably doesn't distort the data too much, but in fact, we are not actually viewing values of the finite element function, and there is no guarantee that this surrogate function will actually satisfy the boundary conditions or other characteristics of the finite element function.

DIRECTION_ARROWS_GRID is based in part on a plotting routine written by Professor Hyung-Chun Lee of Ajou University, Korea.

Usage:

The calling sequence is:

direction_arrows_grid ( node_file, velocity_file, scale, number )
where
node_file
the name of the node file, which must be a quoted string;
velocity_file
the name of the velocity file, which must be a quoted string;
scale
a scale factor for the direction vectors; A value of 1.0 is reasonable. A value of 0.0 results in automatic scaling.
number
the number of vectors to draw in one direction. This is actually the number that will appear in the longest dimension of the region. A value of 10 is reasonable to start with, which would result in 100 vectors if your region happens to be a square.

Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

Related Data and Programs:

DIRECTION_ARROWS, a MATLAB program which plots the velocity direction field.

DIRECTION_ARROWS_SEQUENCE, a MATLAB program which plots the velocity direction fields of many data files with names that are numbered in sequence.

VECTOR_MAGNITUDE_GRID, a MATLAB program which reads node and vector data from a file, computes an interpolatory function, evaluates on a uniform grid of points specified by the user, and displays a contour plot of the vector magnitude.

VECTOR_PLOT, a FORTRAN90 program which can read an XY file and a UV file and plot the velocity and velocity direction fields.

VECTOR_STREAM_GRID, a MATLAB program which reads node and vector data from a file, computes an interpolatory function, evaluates on a uniform grid of points specified by the user, and displays a streamline plot of the vector field.

VELOCITY_ARROWS, a MATLAB program which plots a velocity vector field.

VELOCITY_ARROWS_GRID, a MATLAB program which reads node and velocity data from separate files, and using interpolation is able to display a velocity vector field along any uniform grid of points specified by the user.

VELOCITY_ARROWS_SEQUENCE, a MATLAB program which can process a set of many data files with names that are numbered in sequence.

Source Code:

Examples and Tests:

BIG_CAVITY is a fluid flow problem involving an irregular mesh of 8,185 nodes in a square region. If you try to plot the velocity at every point, you will get an unusable blur. Using this software, you can ask for a plot on a 10x10 grid or a 20x20 grid, for instance.

You can go up one level to the MATLAB source codes.


Last revised on 30 September 2006.