function BS_Speculative_graph_1248 (i_p, first, mult, IC, SS) % Copyright 2000, J.E. Akin. All rights reserved. % ------------------------------------------------------ % Matlab graph of i_p-th component value, 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 % If IC = 1 show Initial Condtions also % If SS = 1 show Steady State also % ------------------------------------------------------ %? 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 = 0 ; first = 1 ; mult = 2; IC = 0; SS = 0; elseif ( nargin == 1 ) first = 1 ; mult = 2; IC = 0; SS = 0; elseif ( nargin == 2 ) mult = 2; IC = 0; SS = 0; elseif ( nargin == 3 ) IC = 0; SS = 0; elseif ( nargin == 4 ) SS = 0; end % if no arguments step_1 = first ; step_2 = step_1 * mult ; step_3 = step_2 * mult ; step_4 = step_3 * mult ; fprintf ('Step 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 ) error ('This is not a 1D mesh') 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) % ==================== 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 solution values \n', NP) error ('Error, incompatible mesh file size') end % if max_p = size (Result_1, 2) ; % fprintf (' with %g components each \n', max_p) if ( i_p > max_p ) error ('i_p > available data') end % if error 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 solution values \n', NP) error ('Error, incompatible mesh file size') end % if max_p = size (Result_2, 2) ; % fprintf (' with %g components each \n', max_p) if ( i_p > max_p ) error ('i_p > available data') end % if error % --------------------- 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 solution values \n', NP) error ('Error, incompatible mesh file size') end % if max_p = size (Result_3, 2) ; % fprintf (' with %g components each \n', max_p) if ( i_p > max_p ) error ('i_p > available data') end % if error % --------------------- 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 solution values \n', NP) error ('Error, incompatible mesh file size') end % if max_p = size (Result_4, 2) ; % fprintf (' with %g components each \n', max_p) if ( i_p > max_p ) error ('i_p > available data') end % if error % --------------------- plot IC -------------------------- %b if ( IC ) % add initial conditions 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 nodal solution values \n', NP) error ('Error, incompatible mesh file size') end % if max_p = size (Result_5, 2) ; % fprintf (' with %g components each \n', max_p) if ( i_p > max_p ) error ('i_p > available data') end % if error %b end % if % --------------------- plot SS -------------------------- if ( SS ) % add initial conditions file_6 = ['node_results']; filename_6 = [file_6, '.tmp']; fid_6= fopen(filename_6, 'r') ; % load the file array Result_6 = fscanf (fid_6, '%g \n', [inf]) ; NP = size (Result_6, 1) ; if ( NP == 0 ) error ('Error missing file ', file_6, '.tmp') end % if error if ( NP ~= np ) fprintf ('Read %g nodal solution values \n', NP) error ('Error, incompatible mesh file size') end % if max_p = size (Result_5, 2) ; % fprintf (' with %g components each \n', max_p) if ( i_p > max_p ) error ('i_p > available data') end % if error end % if 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 %b 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) ; %b if ( IC ) y_5 = Result_5(:, i_p) ; y_1 = y_1 - y_5 ; y_2 = y_2 - y_5 ; y_3 = y_3 - y_5 ; y_4 = y_4 - y_5 ; %b end % if %b if ( SS ) %b y_6 = Result_6(:, i_p) ; %b end % if %b else % i_p = 0, get root mean sq %b for k = 1:np %b y_1 (k) = sqrt ( sum (Result_1 (k, 1:max_p).^2)) ; %b y_2 (k) = sqrt ( sum (Result_2 (k, 1:max_p).^2)) ; %b y_3 (k) = sqrt ( sum (Result_3 (k, 1:max_p).^2)) ; %b y_4 (k) = sqrt ( sum (Result_4 (k, 1:max_p).^2)) ; %b if ( IC ) %b y_5 (k) = sqrt ( sum (Result_5 (k, 1:max_p).^2)) ; %b end % if %b if ( IC ) %b y_6 (k) = sqrt ( sum (Result_6 (k, 1:max_p).^2)) ; %b end % if %b end % for k %b 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) ; if ( IC ) y_5X = max (y_5) ; y_5N = min (y_5) ; else y_5X = y_1X ; y_5N = y_1N ; end % if if ( SS ) y_6X = max (y_6) ; y_6N = min (y_6) ; else y_6X = y_1X ; y_6N = y_1N ; end % if ymax = max ([y_1X, y_2X, y_3X, y_4X, y_5X, y_6X]) ; ymin = min ([y_1N, y_2N, y_3N, y_4N, y_5N, y_6N]) ; if ( ymax == ymin ) if ( abs (ymax) > 0 ) ymax = ymax + abs (ymax)/20. ; ymin = ymin - abs (ymin)/20. ; end % if 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 ('S') % add label %b if ( i_p >= 1 ) ylabel (['Speculative Value (max = ', num2str(ymax), ... ', min = ', num2str(ymin), ' dollars)']) title(['Value at Steps ', int2str(step_1), ', ', ... int2str(step_2), ... ', ', int2str(step_3), ', ', int2str(step_4), ... ': ', int2str(nt),' Elements, ', ... int2str(np), ' Nodes, (', int2str(nod_per_el), ... ' per Element)']) %b else % i_p = 0, get root mean sq %b title(['Steps ', int2str(step), ' to ', int2str(step_4), ... %b ' RMS Value: ', ... %b int2str(nt),' Elements, ', int2str(np), ... %b ' Nodes, (', int2str(nod_per_el), ' per Element)']) %b ylabel ('RMS Value') %b end % if get RMS value % plot node values plot (x, y_1, 'ko') plot (x, y_2, 'ks') plot (x, y_3, 'kd') plot (x, y_4, 'k*') if ( nargin < 4 ) legend (['Step ', int2str(step_1)], ['Step ', int2str(step_2)], ... ['Step ', int2str(step_3)], ['Step ', int2str(step_4)]) elseif ( nargin < 5 ) plot (x, y_5, 'k-.') legend (['Step ', int2str(step_1)], ['Step ', int2str(step_2)], ... ['Step ', int2str(step_3)], ['Step ', int2str(step_4)], ... ['Initial']) else plot (x, y_5, 'k-.') plot (x, y_6, 'k--') legend (['Step ', int2str(step_1)], ['Step ', int2str(step_2)], ... ['Step ', int2str(step_3)], ['Step ', int2str(step_4)], ... ['Initial'], ['Steady']) end % if SS and/or IC 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), '_time_graph_1248']) hold off % v_text = ['Created result_', int2str(i_p), '_time_graph_1248.ps'] ; % fprintf (1,'%s', v_text) ; fprintf (1, ' \n' ) % end of BS_Speculative_graph_1248