function beam_C1_L2_defl (i_p) % 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 ; 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 ==================== file_1 = ['node_results']; filename_1 = [file_1, '.tmp']; fid_1= fopen(filename_1, 'r') ; % load the file array for this result 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' ; % ==================== end 4 files ==================== H (2) = 0. ; HC1 (4) = 0. ; DHC1 (4) = 0. ; 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 y_1 = Result_1(:, 1) ; % nodal disp R1x = max(y_1) ; R1n = min(y_1); dy_1 = Result_1(:, 2) ; % nodal slope R2x = max(dy_1) ; R2n = min(dy_1); [norm, at] = max ( abs (y_1) ); if ( norm == 0 ) error ('Null displacement, nothing to plot') end % if %b norm = y_1 (at) ; %b y_1 = y_1 / norm ; %b dy_1 = dy_1 / norm ; if ( i_p == 1 ) y = y_1 ; else y = dy_1 ; end % if % Initialize plots xmax = max (x) ; xmin = min (x) ; y_1X = max (y) ; y_1N = min (y) ; 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 %b ymin=-2 clf % clear graphics %b axis ([xmin, xmax, ymin, ymax]) % set axes hold on % hold image for plots xlabel ('X') % add label % Loop over all elements el_min = ymin ; el_max = ymax ; for it = 1:nt ; % Extract element connectivity t_nodes = msh_typ_nodes (it, (pre_e+2):(nod_per_el+pre_e+1)); % Skip point elements, if any if ( all (t_nodes) ) % then valid line % Extract element coordinates & values t_x = x (t_nodes) ; % x at those nodes, only A = abs( t_x(2) - t_x(1)) ; % element length t_y = y_1 (t_nodes) ; % y at those nodes, only t_dy = dy_1 (t_nodes) ; % dy at those nodes, only D (1:2:4) = t_y ; D (2:2:4) = t_dy ; % Loop over local points on the cubic polynomial element n_poly = ceil ( 95 / nt) ; for k = 1: (n_poly + 1) % points in parametric space % get element parametric interpolation functions R = (k - 1)/n_poly ; % on 0 to 1 X = 2*R - 1 ; % on -1 to 1 % H = ELEMENT SHAPE FUNCTIONS % X = LOCAL COORDINATE OF POINT, -1 TO +1 % LOCAL NODE COORD. ARE -1,+1 1------------2 H (1) = 0.5*(1 - X) ; H (2) = 0.5*(1 + X) ; x_el (k) = H * t_x ; % true X value HC1(1) = (2 - 3*X + X^3)/4; HC1(2) = (1 - X - X^2 + X^3)*A/8; HC1(3) = (2 + 3*X - X^3)/4; HC1(4) = (-1 - X + X^2 + X^3)*A/8; y_el (k) = HC1 * D' ; % tXue y value DHC1(1) = (-3 + 3*X*X) * 0.5 / A; DHC1(2) = (-1 - 2*X + 3*X*X) * 0.25 ; DHC1(3) = ( 3 - 3*X*X) * 0.5d0 / A; DHC1(4) = (-1 + 2*X + 3*X*X) * 0.25; dy_el (k) = DHC1 * D' ; % true y value end % for k format short plot (x, y, 'ko') % nodal value symbols if ( i_p == 1 ) plot (x_el, y_el) % interpolated values max_el = max (y_el) ; min_el = min (y_el) ; elseif ( i_p == 2 ) plot (x_el, dy_el) % interpolated values max_el = max (dy_el) ; min_el = min (dy_el) ; end % if if ( max_el > el_max ) el_max = max_el ; end % if if ( min_el < el_min ) el_min = min_el ; end % if end % if has non-zero nodes end % for all elements %b if ( el_max > ymax ) fprintf ('Max interior value was %g \n', el_max) ymax = el_max ; %b end % if %b if ( el_min < ymin ) ymin = el_min ; fprintf ('Min interior value was %g \n', el_min) %b end % if axis ([xmin, xmax, ymin, ymax]) % set axes if ( i_p == 1 ) ylabel (['Beam Displacement (nodal max = ', ... num2str(R1x), ', min = ', num2str(R1n), ')']) title(['Displacement: ', int2str(nt),' Elements, ', ... int2str(np), ' Nodes, (', int2str(nod_per_el), ... ' per Element)']) elseif ( i_p == 2 ) ylabel (['Beam Slope (nodal max = ', ... num2str(R2x), ', min = ', num2str(R2n), ')']) title(['Slope: ', int2str(nt),' Elements, ', ... int2str(np), ' Nodes, (', int2str(nod_per_el), ... ' per Element)']) end % if grid % Create plot copies for report use if ( i_p == 1 ) print ('-dpng', ['Beam_deflections']) v_text = ['Created Beam_deflections.png'] ; elseif ( i_p == 2 ) print ('-dpng', ['Beam_slope']) v_text = ['Created Beam_slope.png'] ; end % if fprintf (1,'%s', v_text) ; fprintf (1, ' \n' ) hold off % end of beam_C1_L2_defl