function hcell_vector_display ( node_xy_file_name, uv_file_name ) %% HCELL_VECTOR_DISPLAY displays a vector field in the H-Cell. % % Discussion: % % This MATLAB function file reads the H-Cell flow data for a single timestep: % % geometry (XY values at the 6-node triangle nodes) % flow (UV values at nodes) % % and plots the velocity vectors (U,V)(X,Y). % % The file plots either the velocity vector field, or the velocity % direction field, depending on the value of the internal logical % parameter "normalized". % % The MATLAB routine QUIVER internally scales the vectors, but this % can be adjusted by using a value of SCALE that is not 1. % % Usage: % % hcell_vector_display ( node_xy_file_name, uv_file_name ) % % A typical invocation might be % % hcell_vector_display ( 'xy6.txt', 'uv000.txt' ) % % But if you simply say % % hcell_vector_display % % the program will give you a chance to enter the file names % interactively. % % Modified: % % 27 April 2004 % % Author: % % John Burkardt % % Parameters: % % Input, string NODE_XY_FILE_NAME, the name of a file containing the % coordinates of the nodes. % % Input, string UV_FILE_NAME, the name of a file containing the velocity % components for a flow in the H-CELL. % fprintf ( 1, '\n' ); fprintf ( 1, 'HCELL_VECTOR_DISPLAY:\n' ); fprintf ( 1, ' MATLAB version\n' ); fprintf ( 1, '\n' ); fprintf ( 1, ' Display a vector plot in the HCELL problem.\n' ); FALSE = 0; TRUE = 1; scale = 1.0; normalized = TRUE; % % Read the coordinates. % if ( nargin < 1 ) fprintf ( 1, '\n' ); fprintf ( 1, 'HCELL_VECTOR_DISPLAY:\n' ); node_xy_file_name = input ( 'Enter the name of the XY coordinate file:' ); end node_xy = table_read ( node_xy_file_name ); % % Read the velocities. % if ( nargin < 2 ) fprintf ( 1, '\n' ); fprintf ( 1, 'HCELL_VECTOR_DISPLAY:\n' ); uv_file_name = input ( 'Enter the name of the velocity file:' ); end uv = table_read ( uv_file_name ); % % Do you want to normalize the velocities? % if ( normalized == TRUE ) norm = sqrt ( uv(1,:).^2 + uv(2,:).^2 ); nonzero = find ( norm ~= 0.0 ); uv(1,nonzero) = uv(1,nonzero) ./ norm(nonzero); uv(2,nonzero) = uv(2,nonzero) ./ norm(nonzero); end % % Display the vector field. % quiver ( node_xy(1,:), node_xy(2,:), uv(1,:), uv(2,:), scale ) % % Add the boundary of the region to the plot. % hcell_boundary_add ( 'r' ) % % Draw the invisible bounding box. % hcell_box_add ( 'w' ) axis equal if ( normalized == TRUE ) title ( 'H-Cell Direction Field' ) else title ( 'H-Cell Flow Field' ) end text ( 45.0, 20.0, uv_file_name ) fprintf ( 1, '\n' ); fprintf ( 1, 'HCELL_FLOW_DISPLAY:\n' ); fprintf ( 1, ' Normal end of execution.\n' );