function eigen_modes_graph (i_p, first) % Copyright 2004, J.E. Akin. All rights reserved. % ------------------------------------------------------ % Matlab graph of i_p-th component value of 1 eigenvector, % at mesh node locations % ------------------------------------------------------ % c_x = x coordinates of nod_per_el line polygon % c_y = y coordinates of nod_per_el line polygon % msh_typ_nodes = connectivity list for elements, nt x nod_per_el % loop = corners for nod_per_el line polygon % nod_per_el = Nodes per element % np = Number of Points % nt = Number of elements % pre_e = Element items before connectivity list pre_e = 0 ; % pre_p = Nodal items before coordinates pre_p = 1; % msh_bc_xyz = Nodal coordinates (with preceeding data) % t_x = x coordinates of nod_per_el corners % t_y = y coordinates of nod_per_el corners clear fid_1 fid_5 if ( nargin == 0 ) i_p = 1 ; first = 1 ; elseif ( nargin == 1 ) first = 1 ; end % if step_1 = first ; fprintf ('Mode selected = %g \n', step_1) save_1 = step_1; if ( step_1 > 999 ) save_1 = mod(step_1,999) end % if % Read coordinate file and connectivity file % integer bc code, real xy pairs for np points (pre_p = 1) load msh_bc_xyz.tmp ; % Set control data: number of points np = size (msh_bc_xyz,1) ; % number of nodal points fprintf ('Read %g mesh coordinate pairs \n', np) ns = size (msh_bc_xyz,2) - pre_p ; % space dimension if ( ns > 1 ) %b error ('This is not a 1D mesh') fprintf ('Not 1D: will use x-coordinate only \n') end % if not 2D data % Set control data: number elements load msh_typ_nodes.tmp ; % nod_per_el nodes per element nt = size (msh_typ_nodes,1) ; % number of elements in mesh nod_per_el = size (msh_typ_nodes,2) - pre_e -1 ; % nodes per elem fprintf ('Read %g elements connections \n', nt) ng = 1 ; % number of generalized dof % ==================== 4 files ==================== if ( save_1 < 10 ) file_1 = ['node_results_00', int2str(save_1)]; elseif ( save_1 < 100 ) file_1 = ['node_results_0', int2str(save_1)]; else file_1 = ['node_results_', int2str(save_1)]; end % if filename_1 = [file_1, '.tmp']; fid_1= fopen(filename_1, 'r') ; % load the file array Result_1 = fscanf (fid_1, '%g \n', [inf]) ; NP = size (Result_1, 1) ; if ( NP == 0 ) error ('Error missing file ', file_1, '.tmp') end % if error if ( NP ~= np ) fprintf ('Read %g nodal dof \n', NP) ng = NP / np ; fprintf ('with %g per node \n', ng ) end % if max_p = ng ; if ( i_p > max_p ) error ('i_p > available data') end % if error Result_1 = reshape (Result_1, ng, np) ; Result_1 = Result_1' ; file_5 = ['node_results_000']; filename_5 = [file_5, '.tmp']; fid_5= fopen(filename_5, 'r') ; % load the file array Result_5 = fscanf (fid_5, '%g \n', [inf]) ; NP = size (Result_5, 1) ; if ( NP == 0 ) error ('Error missing file ', file_5, '.tmp') end % if error if ( NP ~= np ) fprintf ('Read %g system eigen values \n', NP) end % if mode_1 = Result_5 (step_1) ; % ==================== end 4 files ==================== x (np) = 0. ; % pre-allocate array x t_nodes (nod_per_el) = 0 ; % Optional pre-allocation t_x (nod_per_el) = 0 ; % Optional pre-allocation t_y (nod_per_el) = 0 ; % Optional pre-allocation c_x (nod_per_el + 1) = 0 ; % Optional pre-allocation c_y (nod_per_el + 1) = 0 ; % Optional pre-allocation loop (nod_per_el + 1) = 0 ; % Optional pre-allocation % set constants [loop] = get_El_Loop (nod_per_el) ; % msh_bc_xyz has: pre_p items then: x, y x = msh_bc_xyz (1:np, (pre_p+1)) ; % extract x column if ( i_p >= 1 ) y_1 = Result_1(:, i_p) ; else % i_p = 0, get root mean sq for k = 1:np y_1 (k) = sqrt ( sum (Result_1 (k, 1:max_p).^2)) ; end % for k end % if get RMS value % Initialize plots xmax = max (x) ; xmin = min (x) ; y_1X = max (y_1) ; y_1N = min (y_1) ; ymax = max (y_1X) ; ymin = min (y_1N) ; ymax = ymax + abs (ymax)/10. ; ymin = ymin - abs (ymin)/10. ; if ( ymin == ymax ) disp(ymin) error('All values are the above constant') end % if %b ymax=1.0 clf % clear graphics axis ([xmin, xmax, ymin, ymax]) % set axes hold on % hold image for plots xlabel ('X') % add label ylabel (['Component ', int2str(i_p), ' (max = ', ... num2str(ymax), ', min = ', num2str(ymin), ')']) title(['Mode ', int2str(step_1), ... ' Component\_', ... int2str(i_p),': ', int2str(nt),' Elements, ', ... int2str(np), ' Nodes, (', int2str(nod_per_el), ... ' per Element)']) % plot node values format short plot (x, y_1, 'ko') legend (['Freq ', int2str(step_1), ' = ', num2str(mode_1)]) plot (x, y_1, 'k-') grid % -depsc -tiff % for an eps version % print ('-dpsc', ['result_', int2str(i_p), '_eigen_graph_1248']) hold off % v_text = ['Created result_', int2str(i_p), '_eigen_graph_1248.ps'] ; % fprintf (1,'%s', v_text) ; fprintf (1, ' \n' ) % end of eigen_modes_graph