function frame2D_C1_L2_defl (scale) % 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; pre_r=0 % 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 ) scale= 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 > 2 ) %b error ('This is not a 1D mesh') fprintf ('Not 2D: will use x- & y-coordinate only \n') end % if not 2D data % msh_bc_xyz has: pre_p items then: x, y x = msh_bc_xyz (1:np, (pre_p+1)) ; % extract x column fy = msh_bc_xyz (1:np, (pre_p+2)) ; % extract y column maxx = max (x) ; minx = min (x) ; maxy = max (fy) ; miny = min (fy) ; Max_Len= max((maxx-minx),(maxy-miny)) ; % 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) %b ng = 1 ; % number of generalized dof %% ==================== 1 files ==================== % file_1 = ['node_results']; % filename_1 = [file_1, '.tmp']; % fid_1= fopen(filename_1, 'r') ; % Get deflections load node_results.tmp % Get deflections load node_results.tmp nd = size (node_results, 1) ; if ( nd == 0 ) error ('Error missing file node_results.tmp') end % if error fprintf ('Read %g mesh deformations \n', nd) [X_X, L_X] = max ( abs (node_results (:, pre_r+1)) ); %CL [Y_X, L_Y] = max ( abs (node_results (:, pre_r+2)) ); %CL Max_Disp = max (X_X, Y_X) ; Good_Scale=Max_Len/Max_Disp/20 ; %b if (nargin == 0 ) %b d_scale = Good_Scale ; fprintf ('Suggested scale = %g \n', Good_Scale) %b end % if %% 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 ; % Result_1 = reshape (Result_1, ng, np) ; % Result_1 = Result_1' % ==================== end 1 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) ; %b a_1 = Result_1(:, 1) ; % axial nodal disp a_1 = node_results (:, pre_r+1) % axial nodal disp Rax = max(a_1) ; Ran = min(a_1); %b y_1 = Result_1(:, 1) ; % transverse nodal disp y_1 = node_results (:, pre_r+2) % transverse nodal disp R1x = max(y_1) ; R1n = min(y_1); %b dy_1 = Result_1(:, 2) ; % nodal slope dy_1 = node_results (:, pre_r+3) % 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 % scale up the displacements a_1 = a_1 * scale; y_1 = y_1 * scale; % Initialize plots xmax = max (x) ; xmin = min (x) ; fymax = max (fy) ; fymin = min (fy) ; y_1X = max (y_1) ; y_1N = min (y_1) ; xmax = xmax + y_1X ; xmin = xmin - y_1X ; fymax = fymax + y_1X ; fymin = fymin - y_1X ; ymax = max (y_1X) ; ymin = min (y_1N) ; if ( ymin == ymax ) disp(ymin) error('All values are the above constant') end % if clf % clear graphics 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 t_fy = fy (t_nodes) ; % y original c_x = t_x (loop) ; % x for nod_per_el line polygon c_fy = t_fy (loop) ; % y for nod_per_el line polygon dx = c_x(2) - c_x(1) ; dy = c_fy(2) - c_fy(1) ; A = sqrt(dx*dx + dy*dy) ; nx = dx/A; ny = dy/A; % dir cosine normal to beam dir_c = [nx, ny] T = [nx, ny, 0,0,0,0; ... -ny, nx, 0,0,0,0; ... 0, 0 1,0,0,0; ... 0,0,0, nx, ny, 0; ... 0,0,0,-ny, nx, 0; ... 0,0,0, 0, 0, 1] t_a = a_1 (t_nodes) ; 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 ; DXY(1:3:6) = t_a; DXY(2:3:6) = t_y; DXY(3:3:6) = t_dy; DXY % rotate to element direction Dxy = T * DXY' D (1) = Dxy(2); D(2)=Dxy(3); D(3)=Dxy(5); D(4)=Dxy(6); % 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 fy_el (k) = H * t_fy ; % true Y value a_el (k) = H * t_a; 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' ; % true 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 deformed_x = x_el + nx* a_el + nx*y_el ; deformed_y = fy_el + ny*a_el + ny*y_el ; format short plot (x, fy, 'ko') % nodal value symbols plot (deformed_x, deformed_y) max_el = max (y_el) ; min_el = min (y_el) ; 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 if ( el_max > ymax ) fprintf ('Max interior deflection was %g \n', el_max) ymax = el_max ; end % if if ( el_min < ymin ) ymin = el_min ; fprintf ('Min interior was %g \n', el_min) end % if axis ([xmin, xmax, fymin, fymax]) % set axes ylabel ('Y') title(['Frame Deformed Shape: ', int2str(nt),' Elements, ', ... int2str(np), ' Nodes, (', int2str(nod_per_el), ... ' per Element)']) grid % -depsc -tiff % for an eps version % print ('-dpsc', ['beam_', int2str(i_p), '_defl']) hold off % v_text = ['Created beam_', int2str(i_p), '_defl.ps'] ; % fprintf (1,'%s', v_text) ; fprintf (1, ' \n' ) % end of frame2D_C1_L2_defl