function smooth_result (i_p) % Copyright 2000 J.E. Akin. All rights reserved. % plot finite element result as a surface for 1 <= i_p<= n_g_fre % convert any type of mesh to a structured square mesh % x,y == nodal coordinates of the FEA % f == nodal solution of the FEA % X,Y == nodal coordinates of the structured square mesh % F == interpolated solution for the structured square mesh % NX == number of nodes in x-direction for structured mesh % NY == number of nodes in y-direction for structured mesh % clear if ( nargin == 0 ) i_p = 0 ; end % if no arguments load msh_bc_xyz.tmp; pre_p = 1; np = size (msh_bc_xyz, 1); fprintf ('Read %g mesh coordinate pairs \n', np) ns = size (msh_bc_xyz,2) - pre_p ; % space dimension if ( ns < 2 ) error ('This is not a 2D mesh') end % if not 2D data load node_results.tmp nr = size (node_results, 1); if ( nr == 0 ) error ('Error missing file node_results.tmp') end % if error max_p = size (node_results, 2) ; % number of columns fprintf ('Read %g nodal solution values \n', nr) fprintf (' with %g components each \n', max_p) if ( i_p > max_p ) error ('i_p > available data') end % if error % NX, NY = 31 are default values, these can be altered by user NX = 31; NY = 31; x = msh_bc_xyz (:, 2); y = msh_bc_xyz (:, 3); if ( i_p >= 1 ) f = node_results(:, i_p) ; else % i_p = 0, get root mean sq for k = 1:np f (k) = sqrt ( sum (node_results (k, 1:max_p).^2)) ; end % for k end % if get RMS value % Cite max, min values [V_X, L_X] = max (f) ; [V_N, L_N] = min (f) ; fprintf ('Max value is %g at node %g \n', V_X, L_X) fprintf ('Min value is %g at node %g \n', V_N, L_N) xlin = linspace (min(x), max(x), NX); ylin = linspace (min(y), max(y), NY); [X, Y] = meshgrid (xlin, ylin); F = griddata (x, y, f, X, Y, 'cubic'); clf % mesh (X, Y, F) % haxes=gca haxes=mesh (X, Y, F) % set(haxes,'xcolor','k'); % set(haxes,'ycolor','k'); hold on if ( i_p >= 1 ) zlabel (['Component ', int2str(i_p), ' (max = ', ... num2str(V_X), ', min = ', num2str(V_N), ')']) %title(['Matlab Smoothed FEA Solution Component\_', int2str(i_p)]); title(['Matlab Smoothed FEA Solution Component\_', ... int2str(i_p),': at ', int2str(np),' Nodes']); else % i_p = 0, get root mean sq zlabel (['RMS Value (max = ', ... num2str(V_X), ', min = ', num2str(V_N), ')']) title(['Matlab Smoothed FEA RMS Solution Value at ', ... int2str(np),' Nodes']) %title(['Matlab Smoothed FEA RMS Solution Value']) end % if get RMS value % xlabel ('X'); ylabel (['Y: ', int2str(np),' Nodes']) xlabel ('X'); ylabel ('Y'); % label max min points v_text = sprintf ('-------min') ; text (x(L_N), y(L_N), V_N, v_text) ; v_text = sprintf ('-------max') ; text (x(L_X), y(L_X), V_X, [v_text]) ; % -depsc -tiff % for an eps version % print ('-dpsc', ['smooth_result_', int2str(i_p)]) % print ('-dps', ['smooth_result_', int2str(i_p)]) hold off % v_text = ['Created smooth_result_', int2str(i_p), '.ps'] ; % fprintf (1,'%s', v_text) ; fprintf (1, ' \n' ) % end of smooth_result