function eigen_modes_graph_1248 (i_p, first, mult) % Copyright 2004, J.E. Akin. All rights reserved. % ------------------------------------------------------ % Matlab graph of i_p-th component value of eigenvector, % at mesh node % locations for 4 geometric step progressions: % steps 1, 2, 4, 8 or first, 2*first, 4*first, 8*first % or first, mult*first, mult^2*first, mult^3*first % If i_p = 0, show RMS value % If first = 0 show initial conditions ONLY % ------------------------------------------------------ %? global az el ? these are not changing with new view % 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_2 fid_3 fid_4 if ( nargin == 0 ) i_p = 1 ; first = 1 ; mult = 2; elseif ( nargin == 1 ) first = 1 ; mult = 2; elseif ( nargin == 2 ) mult = 2; end % if step_1 = first ; step_2 = step_1 * mult ; step_3 = step_2 * mult ; step_4 = step_3 * mult ; fprintf ('Mode progression: %g, %g, %g, %g \n', ... step_1,step_2,step_3,step_4) save_1 = step_1; save_2 = step_2; save_3 = step_3; save_4 = step_4; if ( step_1 > 999 ) save_1 = mod(step_1,999) end % if if ( step_2 > 999 ) save_2 = mod(step_2,999) end % if if ( step_3 > 999 ) save_3 = mod(step_3,999) end % if if ( step_4 > 999 ) save_4 = mod(step_4,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: wll 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' ; if ( first > 0 ) % then multiple plots % --------------------- plot 2 -------------------------- if ( save_2 < 10 ) file_2 = ['node_results_00', int2str(save_2)]; elseif ( save_2 < 100 ) file_2 = ['node_results_0', int2str(save_2)]; else file_2 = ['node_results_', int2str(save_2)]; end % if filename_2 = [file_2, '.tmp']; fid_2= fopen(filename_2, 'r') ; % load the file array Result_2 = fscanf (fid_2, '%g \n', [inf]) ; NP = size (Result_2, 1) ; if ( NP == 0 ) error ('Error missing file ', file_2, '.tmp') end % if error if ( NP ~= np ) fprintf ('Read %g nodal dof \n', NP) end % if Result_2 = reshape (Result_2, ng, np) ; Result_2 = Result_2' ; % --------------------- plot 3 -------------------------- if ( save_3 < 10 ) file_3 = ['node_results_00', int2str(save_3)]; elseif ( save_3 < 100 ) file_3 = ['node_results_0', int2str(save_3)]; else file_3 = ['node_results_', int2str(save_3)]; end % if filename_3 = [file_3, '.tmp']; fid_3= fopen(filename_3, 'r') ; % load the file array Result_3 = fscanf (fid_3, '%g \n', [inf]) ; NP = size (Result_3, 1) ; if ( NP == 0 ) error ('Error missing file ', file_3, '.tmp') end % if error if ( NP ~= np ) fprintf ('Read %g nodal dof \n', NP) end % if Result_3 = reshape (Result_3, ng, np) ; Result_3 = Result_3' ; % --------------------- plot 4 -------------------------- if ( save_4 < 10 ) file_4 = ['node_results_00', int2str(save_4)]; elseif ( save_4 < 100 ) file_4 = ['node_results_0', int2str(save_4)]; else file_4 = ['node_results_', int2str(save_4)]; end % if filename_4 = [file_4, '.tmp']; fid_4= fopen(filename_4, 'r') ; % load the file array Result_4 = fscanf (fid_4, '%g \n', [inf]) ; NP = size (Result_4, 1) ; if ( NP == 0 ) error ('Error missing file ', file_4, '.tmp') end % if error if ( NP ~= np ) fprintf ('Read %g nodal dof \n', NP) end % if Result_4 = reshape (Result_4, ng, np) ; Result_4 = Result_4' ; end % if initial condition only (first == 0) % --------------------- get frequencies ------------------- 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) ; mode_2 = Result_5 (step_2) ; mode_3 = Result_5 (step_3) ; mode_4 = Result_5 (step_4) ; %b end % if initial condition only (first == 0) % ==================== 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) ; y_2 = Result_2(:, i_p) ; y_3 = Result_3(:, i_p) ; y_4 = Result_4(:, 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)) ; y_2 (k) = sqrt ( sum (Result_2 (k, 1:max_p).^2)) ; y_3 (k) = sqrt ( sum (Result_3 (k, 1:max_p).^2)) ; y_4 (k) = sqrt ( sum (Result_4 (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) ; y_2X = max (y_2) ; y_2N = min (y_2) ; y_3X = max (y_3) ; y_3N = min (y_3) ; y_4X = max (y_4) ; y_4N = min (y_4) ; ymax = max ([y_1X, y_2X, y_3X, y_4X]) ; ymin = min ([y_1N, y_2N, y_3N, y_4N]) ; %b if ( ymax == ymin ) %b if ( abs (ymax) > 0 ) ymax = ymax + abs (ymax)/20. ; ymin = ymin - abs (ymin)/20. ; %b end % if %b end % if %b ymax=1.0 clf % clear graphics axis ([xmin, xmax, ymin, ymax]) % set axes % view([52.5,30]) hold on % hold image for plots xlabel ('X') % add label ylabel (['Component ', int2str(i_p), ' (max = ', ... num2str(ymax), ', min = ', num2str(ymin), ')']) title(['Modes ', int2str(step_1), ', ', int2str(step_2), ... ', ', int2str(step_3), ', ', int2str(step_4), ... ' Component\_', ... int2str(i_p),': ', int2str(nt),' Elements, ', ... int2str(np), ' Nodes, (', int2str(nod_per_el), ... ' per Element)']) % plot node values plot (x, y_1, 'ko') plot (x, y_2, 'ks') plot (x, y_3, 'kd') plot (x, y_4, 'k*') legend (['Freq ', int2str(step_1), ' = ', num2str(mode_1)], ... ['Freq ', int2str(step_2), ' = ', num2str(mode_2)], ... ['Freq ', int2str(step_3), ' = ', num2str(mode_3)], ... ['Freq ', int2str(step_4), ' = ', num2str(mode_4)]) plot (x, y_1, 'k-') plot (x, y_2, 'k-') plot (x, y_3, 'k-') plot (x, y_4, 'k-') grid % end % if show labels % -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_1248