function C1_L3_beam_plots (i_p) % ========================== % Copyright 2008 J.E. Akin. All rights reserved. % ------------------------------------------------------ % Matlab graph of i_p-th component value at mesh nodes % for a mesh of 3 node quintic Hermite line elements % i_p = 1 is deflection, = 2 is slope % = 3 is curvature (moment), = 4 is curvature rate (shear) % ------------------------------------------------------ % c_x = x coordinates of nod_per_el line element % msh_typ_nodes = connectivity list , nt x nod_per_el % loop = corners for nod_per_el line element % 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 if ( nargin == 0 ) i_p = 1 ; end % if no arguments Pts_wide = 2 ; % draw fat lines format short % 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 %b fprintf ('Read %g mesh coordinates \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 1D 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 %b fprintf ('Read %g elements connections \n', nt) if ( nod_per_el ~= 3 ) error ('This is not a mesh of 3 node line elements') end % if load node_results.tmp nr = size (node_results, 1); if ( nr == 0 ) error ('Error missing file node_results.tmp') end % if error max_p = size (node_results, 2) ; % number of columns %b fprintf ('Read %g nodal solution values \n', nr) %b fprintf (' with %g components each \n', max_p) if ( i_p > 4 ) fprintf ('Data requested for component i_p = %g \n', i_p) error ('i_p > available data') end % if error H (3) = 0. ; HC1 (6) = 0. ; DHC1 (6) = 0. ; D2HC1 (6) = 0. ; D3HC1 (6) = 0. ; D4HC1 (6) = 0. ; x (np) = 0. ; % pre-allocate array x y (np) = 0. ; % pre-allocate array y dy (np) = 0. ; % pre-allocate array y 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 t_dy (nod_per_el) = 0 ; % Optional pre-allocation c_x (nod_per_el) = 0 ; % Optional pre-allocation c_y (nod_per_el) = 0 ; % Optional pre-allocation % set constants loop = [1:nod_per_el] ; % default to sequential order % msh_bc_xyz has: pre_p items then: x, y x = msh_bc_xyz (1:np, (pre_p+1)) ; % extract x column xmax = max (x) ; xmin = min (x) ; y = node_results(:, 1) ; dy = node_results(:, 2) ; if ( any (y) == 0 ) fprintf ('All values are zero. Plot skipped. \n') return end % if null solution clf % clear graphics hold on % hold image for plots xlabel (['X, Node at 45 deg (', int2str(nod_per_el), ... ' per element), Element at 90 deg']) % Are properties needed ? if ( i_p > 2 ) load msh_properties.tmp n_mats = size (msh_properties, 2) ; n_vals = size (msh_properties, 1) ; else n_mats = 0; n_vals = 0; EI = 1 ; end % if % Loop over all elements max_all = -1e9 ; min_all = 1e9 ; 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 if ( t_x(2) ~= (t_x(1) + t_x(3))/2 ) fprintf ('WARNING: fixed bad mid-point in element %g \n', it) t_x(2) = (t_x(1) + t_x(3))/2 ; end % if non-constant Jacobian t_y = y (t_nodes) ; % y at those nodes, only t_dy = dy (t_nodes) ; % dy at those nodes, only D (1:2:6) = t_y ; D (2:2:6) = t_dy ; if ( i_p == 1 ) plot (t_x, t_y, 'ko') % plot nodal value symbols end % if % Loop over local points on the quadratic 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,0,+1 1-----2-----3 H (1) = 0.5*(X*X - X) ; H (2) = 1. - X*X ; H (3) = 0.5*(X*X + X) ; x_el (k) = H * t_x ; % true x value A = abs(t_x(3) - t_x(1)) ; P = X ; P_2 = P * P ; P_3 = P * P_2 ; P_4 = P * P_3 ; P_5 = P * P_4 ; % select result of interest, r_el if ( i_p == 1 ) % deflection HC1(1) = (4*P_2 - 5*P_3 - 2*P_4 + 3*P_5) * 0.25 ; HC1(2) = (P_2 - P_3 - P_4 + P_5) * 0.125 * A ; HC1(3) = 1 - 2*P_2 + P_4 ; HC1(4) = (P - 2*P_3 + P_5) * A * 0.5 ; HC1(5) = (4*P_2 + 5*P_3 - 2*P_4 - 3*P_5) * 0.25 ; HC1(6) = (-P_2 - P_3 + P_4 + P_5) * 0.125 * A ; r_el (k) = HC1 * D' ; % true y value elseif ( i_p == 2 ) % slope DHC1 (1) = (8*P - 15*P_2 - 8*P_3 + 15*P_4) * 0.5 / A ; DHC1 (2) = (2*P - 3*P_2 - 4*P_3 + 5*P_4) * 0.25 ; DHC1 (3) = (-4*P + 4*P_3) * 2 / A ; DHC1 (4) = (1 - 6*P_2 + 5*P_4) ; DHC1 (5) = (8*P + 15*P_2 - 8*P_3 - 15*P_4) * 0.5 / A ; DHC1 (6) = (-2*P - 3*P_2 + 4*P_3 + 5*P_4) * 0.25 ; r_el (k) = DHC1 * D' ; % true y' value elseif ( i_p == 3 ) % curvature or moment D2HC1 (1) = (8 - 30*P - 24*P_2 + 60*P_3) /A/ A ; D2HC1 (2) = (2 - 6*P - 12*P_2 + 20*P_3) * 0.5/A ; D2HC1 (3) = (-4 + 12*P_2) * 4 / A / A ; D2HC1 (4) = (-12*P + 20*P_3)*2 / A ; D2HC1 (5) = (8 + 30*P - 24*P_2 - 60*P_3) / A /A; D2HC1 (6) = (-2 - 6*P + 12*P_2 + 20*P_3) * 0.5 / A ; r_el (k) = D2HC1 * D' ; % true y'' value elseif ( i_p == 4 ) % curvature rate or shear force D3HC1 (1) = (-30 - 48*P + 180*P_2) * 2 /A/A/ A ; D3HC1 (2) = (-6 - 24*P + 60*P_2) /A /A; D3HC1 (3) = (24*P) * 8 / A / A/A ; D3HC1 (4) = (-12 + 60*P_2)*4 / A/A ; D3HC1 (5) = (30 - 48*P - 180*P_2) * 2 / A /A/A; D3HC1 (6) = (-6 + 24*P + 60*P_2) / A/A ; r_el (k) = D3HC1 * D' ; % true y''' value end % if plot type end % for k plot points if ( n_vals > 1 ) EI = msh_properties(it,1)*msh_properties(it,2) ; r_el = r_el* EI ; elseif ( n_vals == 1 ) EI = msh_properties( 1,1)*msh_properties( 1,2) ; r_el = r_el* EI ; end % if % elem max, min values [V_X, L_X] = max (r_el) ; [V_N, L_N] = min (r_el); if ( V_X > max_all ) max_all = V_X ; end if ( V_N < min_all ) min_all = V_N ; end plot (x_el, r_el, 'b-', 'LineWidth',Pts_wide) end % if zero in connectivity % Plot the element number x_bar = sum (t_x' )/nod_per_el ; y_bar = mean (r_el) ; t_text = sprintf (' (%g)', it); % offset # from pt text (x_bar, y_bar, t_text) % incline end % for over all elements null (1:np) = 0.5*(V_N + V_X) ; if ( V_N <= 0 & V_X >= 0 ) null (1:np) = 0. ; end % if % finalize axes ymax = max_all ; ymin = min_all ; diff = abs(ymax-ymin) ; ymax = ymax + abs (diff)/10. ; ymin = ymin - abs (diff)/10. ; axis ([xmin, xmax, ymin, ymax]) % set axes if ( i_p == 1 ) title(['Qunitic Beam Deflection from: ', ... int2str(nt),' Elements, ', int2str(np),' Nodes']) ylabel (['Deflection: max=', num2str(max_all), ... ', min=', num2str(min_all)]) fprintf ('Max deflection value is %g \n', max_all) fprintf ('Min deflection value is %g \n', min_all) elseif ( i_p == 2 ) title(['Qunitic Beam Slope from: ', ... int2str(nt),' Elements, ', int2str(np),' Nodes']) ylabel (['Slope: max=', num2str(max_all), ... ', min=', num2str(min_all)]) fprintf ('Max slope value is %g \n', max_all) fprintf ('Min slope value is %g \n', min_all) elseif ( i_p == 3 ) title(['Qunitic Beam Moment from: ', ... int2str(nt),' Elements, ', int2str(np),' Nodes']) ylabel (['Moment: max=', num2str(max_all), ... ', min=', num2str(min_all)]) fprintf ('Max moment value is %g \n', max_all) fprintf ('Min moment value is %g \n', min_all) elseif ( i_p == 4 ) title(['Qunitic Beam Shear from: ', ... int2str(nt),' Elements, ', int2str(np),' Nodes']) ylabel (['Transverse Shear: max=', num2str(max_all), ... ', min=', num2str(min_all)]) fprintf ('Max shear value is %g \n', max_all) fprintf ('Min shear value is %g \n', min_all) end % if % plot node points on axis for i = 1:np t_text = sprintf (' %g', i); % offset # from pt text (x(i), null(i), t_text, 'Rotation', 45) % incline end % for all plot (x, null, 'k*') 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'] ; elseif ( i_p == 3 ) print ('-dpng', ['Beam_moments']) v_text = ['Created Beam_moments.png'] ; elseif ( i_p == 4 ) print ('-dpng', ['Beam_shears']) v_text = ['Created Beam_shears.png'] ; end % if fprintf (1,'%s', v_text) ; fprintf (1, ' \n' ) hold off % end of C1_L3_beam_plots % ==========================