function triangulation_order3_contour ( node_file, triangle_file, ... solution_file ) %% TRIANGULATION_ORDER3_CONTOUR creates contour plots on an order 3 triangulation. % % Discussion: % % This program assumes that you have computed the value of some scalar % quantity (such as pressure or temperature) at a set of nodes, and that % these nodes have been triangulated, forming a network of triangles. % % This program can read that data, and display a color contour of the % solution data. % % The program reads three data files: % % * node_file, containing X, Y coordinates of points, % one pair of coordinates per line; % % * triangle_file, containing, on each line, a list of the three nodes % that make up a particular triangle; % % * solution_file, containing the value of a scalar function % U(X,Y) evaluated at each node. % % The program first displays an image of the triangulation, then an image % of the data that uses a constant color over each triangle, and finally, % a nice looking contour plot that uses interpolation. % % The program pauses after each plot is displayed. Aside from admiring % a particular plot, you might also want to manipulate the viewing angle, % or save it as a JPEG file, for instance. % % Modified: % % 21 June 2005 % % Author: % % John Burkardt % % Parameters: % % Input, string NODE_FILE, the name of the node file. % % Input, string TRIANGLE_FILE, the name of the triangle file. % % Input, string SOLUTION_FILE, the name of the solution file. % timestamp; fprintf ( 1, '\n' ); fprintf ( 1, 'TRIANGULATION_ORDER3_CONTOUR:\n' ); fprintf ( 1, ' MATLAB version\n' ); fprintf ( 1, '\n' ); fprintf ( 1, ' Plot a scalar U(X,Y) on a triangulated data set.\n' ); fprintf ( 1, '\n' ); fprintf ( 1, ' This program expects to find three files to read:\n' ); fprintf ( 1, '\n' ); fprintf ( 1, ' * node_file, containing the node coordinates,\n' ); fprintf ( 1, ' * triangle_file, containing triples of nodes that form triangles,\n' ); fprintf ( 1, ' * solution_file, containing solution values.\n' ); fprintf ( 1, '\n' ); fprintf ( 1, ' It reads the files and makes plots of:\n' ); fprintf ( 1, '\n' ); fprintf ( 1, ' * the triangulation,\n' ); fprintf ( 1, ' * a crude contour plot that is constant over each triangle, and\n' ); fprintf ( 1, ' * a nicer contour plot that uses interpolation.\n' ); % % Read the data. % p = load ( node_file ); t = load ( triangle_file ); u = load ( solution_file ); % % Display the mesh. % trimesh ( t, p(:,1), p(:,2) ); xlabel ( 'X', 'FontName', 'Helvetica', 'FontWeight', 'bold', ... 'FontSize', 16 ); ylabel ( 'Y', 'FontName', 'Helvetica', 'FontWeight', 'bold', ... 'FontSize', 16, 'Rotation', 0 ); title ( 'Triangulation', 'FontName', 'Helvetica', 'FontWeight', ... 'bold', 'FontSize', 16 ); xmax = max ( p(:,1) ); xmin = min ( p(:,1) ); ymax = max ( p(:,2) ); ymin = min ( p(:,2) ); scale = max ( xmax - xmin, ymax - ymin ); xmax = xmax + 0.025 * scale; xmin = xmin - 0.025 * scale; ymax = ymax + 0.025 * scale; ymin = ymin - 0.025 * scale; axis ( [ xmin, xmax, ymin, ymax ] ) axis ( 'equal' ) fprintf ( 1, '\n' ); fprintf ( 1, 'Press return...\n' ); pause % % Display the solution on the mesh, constant over each triangle. % trisurf ( t, p(:,1), p(:,2), u ) xlabel ( 'X', 'FontName', 'Helvetica', 'FontWeight', 'bold', ... 'FontSize', 16 ); ylabel ( 'Y', 'FontName', 'Helvetica', 'FontWeight', 'bold', ... 'FontSize', 16, 'Rotation', 0 ); zlabel ( 'U', 'FontName', 'Helvetica', 'FontWeight', 'bold', ... 'FontSize', 16, 'Rotation', 0 ); title ( 'Scalar U(X,Y)', 'FontName', 'Helvetica', 'FontWeight', ... 'bold', 'FontSize', 16 ); fprintf ( 1, '\n' ); fprintf ( 1, 'Press return...\n' ); pause % % Make a nicer plot on the finer mesh by using color interpolation. % trisurf ( t, p(:,1), p(:,2), u, 'FaceColor', 'interp', ... 'EdgeColor', 'interp' ) xlabel ( 'X', 'FontName', 'Helvetica', 'FontWeight', 'bold', ... 'FontSize', 16 ); ylabel ( 'Y', 'FontName', 'Helvetica', 'FontWeight', 'bold', ... 'FontSize', 16, 'Rotation', 0 ); zlabel ( 'U', 'FontName', 'Helvetica', 'FontWeight', 'bold', ... 'FontSize', 16, 'Rotation', 0 ); title ( 'Scalar U(X,Y)', 'FontName', 'Helvetica', 'FontWeight', ... 'bold', 'FontSize', 16 ); fprintf ( 1, '\n' ); fprintf ( 1, 'Press return...\n' ); pause fprintf ( 1, '\n' ); fprintf ( 1, 'TRIANGULATION_ORDER3_CONTOUR:\n' ); fprintf ( 1, ' Normal end of execution.\n' ); fprintf ( 1, '\n' ); timestamp;