function cubic_beam_pressure_bed (F_k) % Copyright 2008, J.E. Akin. All rights reserved. % ------------------------------------------------------ % Matlab graph of BEF pressure distribution m % ------------------------------------------------------ % 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 % loop = corners for nod_per_el line polygon % nod_per_el = Nodes per element % np = Number of Points % nt = Number of elements pre_e = 0 ; % Element items before connectivity list pre_p = 1; % Nodal items before coordinates % 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 i_p = 1 ; % temp n_fk = size (F_k, 2) ; % number of different foundationS % 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 coordinate pairs \n', np) ns = size (msh_bc_xyz,2) - pre_p ; % space dimension if ( ns > 1 ) fprintf ('Not 1D: will use x-coordinate only \n') end % if not 2D data null (1:np) = 0 ; Pts_wide = 2 ; % fat lines % 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) 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 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 = [1: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 xmax = max (x) ; xmin = min (x) ; y = node_results(:, 1) ; dy = node_results(:, 2) ; clf % clear graphics hold on % hold image for plots %b xlabel (['X, Node at 45 deg (', int2str(nod_per_el), ... %b ' per element), Element at 90 deg']) xlabel ('Height from foot (ft)') % Loop over all elements %B Pmax = -max (node_results(:, i_p)) * max (F_k) ; %B Pmin = -min (node_results(:, i_p)) * max (F_k) ; Pmax = -1e6 ; % -min (node_results(:, i_p)) * max (F_k) Pmin = 1e6 ; % max (node_results(:, i_p)) * max (F_k) el_max = Pmax ; el_min= Pmin ; % Loop over all elements for it = 1:nt ; % Element foundation stiffness, if any if ( n_fk == 1 ) % then homogeneous k_f = F_k (1) ; else k_f = F_k (it) ; end % if % 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 = t_x(2) - t_x(1) ; % element length t_y = y (t_nodes) ; % y at those nodes, only t_dy = dy (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 = 20 ; % 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 CUBIC 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' ; % true y value end % for k p_el = -y_el * k_f ; % true pressure plot(x_el, p_el, 'b-', 'LineWidth',Pts_wide) % Plot the element number x_bar = mean (x_el) ; y_bar = mean (p_el) ; t_text = sprintf (' (%g)', it); % offset # from pt text (x_bar, y_bar, t_text) % incline format short max_el = max (p_el) ; min_el = min (p_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 fprintf ('Max interior pressure was %g \n', el_max) fprintf ('Min interior pressure was %g \n', el_min) %B % plot node points on axis %B inc_p = 1 ; %B if ( inc_p > 0 ) %B for i = 1:np %B t_text = sprintf (' %g', i); % offset # from pt %B text (x(i), null(i), t_text, 'Rotation', 45) % incline %B end % for all %B plot (x, null, 'k*') %B end % if ylabel (['Pressure (max = ', num2str(el_max), ... ', min = ', num2str(el_min), ')']) %B ylabel (['Pressure (max = ', num2str(Pmax), ')']) %B num2str(Pmax), ', min = ', num2str(Pmin), ')']) title(['Bed Pressure: ', int2str(nt),' Elements, ', ... int2str(np), ' Nodes, (', int2str(nod_per_el), ... ' per Element)']) grid print -dpng pressure_plot hold off fprintf ('Saved pressure plot as pressure_plot.png \n') % end of cubic_beam_pressure_bed