function hcell_stream_display ( node_xy_file_name, uv_file_name ) %% HCELL_STREAM_DISPLAY displays a streamline plot for the H-Cell problem. % % Discussion: % % This function reads the H-Cell flow data for a single timestep: % % geometry ( X, Y values at the 6-node triangle nodes); % velocity ( or any corresponding vector quantity.) % % The data is arranged to suit a call to MATLAB's STREAM2 routine. % % Usage: % % hcell_stream_display ( node_xy_file_name, uv_file_name ) % % A typical invocation might be % % hcell_stream_display ( 'xy6.txt', 'uv6.txt' ) % % But if you simply say % % hcell_stream_display % % the program will give you a chance to enter the file names % interactively. % % Modified: % % 18 May 2004 % % Author: % % John Burkardt % % Parameters: % % Input, string NODE_XY_FILE_NAME, the name of the file containing the % coordinates of the nodes. % % Input, string UV_FILE_NAME, the name of the file containing the values of % the vector quantity (such as velocity) at the nodes. % fprintf ( 1, '\n' ); fprintf ( 1, 'HCELL_STREAM_DISPLAY:\n' ); fprintf ( 1, ' MATLAB version\n' ); fprintf ( 1, '\n' ); fprintf ( 1, ' Display vector data streamlines in the HCELL problem.\n' ); % % Do we have the XY file? % if ( nargin < 1 ) fprintf ( 1, '\n' ); fprintf ( 1, 'HCELL_STREAM_DISPLAY:\n' ); node_xy_file_name = input ( 'Enter the name of the XY coordinate file:' ); end node_xy = table_read ( node_xy_file_name ); [ m1, n1 ] = size ( node_xy ); % % Do we have the UV file? % if ( nargin < 2 ) fprintf ( 1, '\n' ); fprintf ( 1, 'HCELL_STREAM_DISPLAY:\n' ); uv_file_name = input ( 'Enter the name of the vector (velocity?) file:' ); end uv = table_read ( uv_file_name ); [ m2, n2 ] = size ( uv ); % % Make sure the number of coordinates and values match. % if ( n1 ~= n2 ) fprintf ( 1, '\n' ); fprintf ( 1, 'HCELL_STREAM_DISPLAY - Fatal error!\n' ); fprintf ( 1, ' The number of coordinates is %d\n', n1 ); fprintf ( 1, ' but the number of vector values is %d\n', n2 ); return end % % Our X, Y data is logically rectangular, with some holes. % STREAM2 requires 2D arrays, with no holes. % Figure out the number of rows and columns, construct the data, and fill in the holes. % x = sort ( node_xy(1,1:n1) ); x_tol = 0.0001 * ( x(n1) - x(1) ); [ n, x_unique ] = r8vec_sorted_unique ( n1, x, x_tol ); y = sort ( node_xy(2,1:n1) ); y_tol = 0.0001 * ( y(n1) - y(1) ); [ m, y_unique ] = r8vec_sorted_unique ( n1, y, y_tol ); [ x_grid, y_grid ] = meshgrid ( x_unique, y_unique ); u_grid(1:m,1:n) = 0.0; v_grid(1:m,1:n) = 0.0; % % For each computational node, copy the value of UV into the array. % for k = 1 : n1 i = r8vec_sorted_nearest ( n, x_unique, node_xy(1,k) ); j = r8vec_sorted_nearest ( m, y_unique, node_xy(2,k) ); u_grid(j,i) = uv(1,k); v_grid(j,i) = uv(2,k); end x_start = ... [ 10.5, 22.5, 34.5, 70.5, 82.5, 94.5, ... 0.0, 105.0, ... 0.0, 105.0, ... 0.0, 105.0, ... 0.0, 105.0, ... 0.0, 105.0, ... 10.3, 22.3, 34.3, 70.3, 82.3, 94.3, ... 10.4, 22.4, 34.4, 70.4, 82.4, 94.4, ... 10.5, 22.5, 34.5, 70.5, 82.5, 94.5, ... 10.6, 22.6, 34.6, 70.6, 82.6, 94.6, ... 10.7, 22.7, 34.7, 70.7, 82.7, 94.7, ... 10.3, 22.3, 34.3, 70.3, 82.3, 94.3, ... 10.4, 22.4, 34.4, 70.4, 82.4, 94.4, ... 10.5, 22.5, 34.5, 70.5, 82.5, 94.5, ... 10.6, 22.6, 34.6, 70.6, 82.6, 94.6, ... 10.7, 22.7, 34.7, 70.5, 82.7, 94.7, ... 0.0, 105.0, ... 0.0, 105.0, ... 0.0, 105.0, ... 0.0, 105.0, ... 0.0, 105.0, ... 22.5, 52.5, 82.5 ]; y_start = ... [ 11.0, 11.0, 11.0, 11.0, 11.0, 11.0, ... 8.7, 8.7, ... 8.6, 8.6, ... 8.5, 8.5, ... 8.4, 8.4, ... 8.3, 8.3, ... 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, ... 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, ... 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, ... 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, ... 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, ... 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, ... 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, ... 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, ... 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, ... 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, ... 2.7, 2.7, ... 2.6, 2.6, ... 2.5, 2.5, ... 2.4, 2.4, ... 2.3, 2.3, ... 0.0, 0.0, 0.0 ]; streams = stream2 ( x_grid, y_grid, u_grid, v_grid, x_start, y_start ); % [ C1, h1 ] = streamline ( streams ); H = streamline ( streams ); axis equal; % % Add the boundary of the region to the plot. % hcell_boundary_add ( 'r' ) % % Add the invisible bounding box. % hcell_box_add ( 'w' ) % % Set up a colormap. % colormap ( jet ); % % Label the axes and the plot. % xlabel ( 'X', 'FontName', 'Helvetica', 'FontWeight', 'bold', ... 'FontSize', 16 ); ylabel ( 'Y', 'FontName', 'Helvetica', 'FontWeight', 'bold', ... 'FontSize', 16, 'Rotation', 0 ); title ( 'Streamlines', 'FontName', 'Helvetica', 'FontWeight', ... 'bold', 'FontSize', 16 ); fprintf ( 1, '\n' ); fprintf ( 1, 'HCELL_STREAM_DISPLAY:\n' ); fprintf ( 1, ' Normal end of execution.\n' );