function quiver_reaction_vec_mesh (scale, i_p, inc_v) %CL % default (1, 1.0, 1) % Copyright 2000, J.E. Akin. All rights reserved. % ------------------------------------------------------ % plot of 2-D FE reaction vectors, with increment of % inc_v, include mesh if mesh=1 % row = row number where cord & connectivity start, 1 or 2 %CL % ------------------------------------------------------ % c_x = x coordinates of nod_per_el line polygon % c_y = y coordinates of nod_per_el line polygon % inc_e = increment in element numbers on plot, if > 0 % inc_p = increment in node numbers on plot, if > 0 % inc_v = increment in vector plot, default = 1 % msh_typ_nodes = connectivity list for elements, nt x nod_per_el % loop = corners for nod_per_el line polygon % lab_p = 1, if node points are circled lab_p = 0; % length = maximum length of arrows, in scaled x,y units % nod_per_el = Nodes per element % np = Number of Points % nt = Number of elements % pre_e = Element items before connectivity list % pre_p = Nodal items before coordinates % msh_bc_xyz = Nodal coordinates (with preceeding data) % scale = standard Matlab scale argument, default 1.0 % t_x = x coordinates of nod_per_el corners % t_y = y coordinates of nod_per_el corners % x_bar = x-centroid of each element % xy = Coordinates of points, np x 2 % y_bar = y-centroid of each element pre_e = 0 ; pre_p = 1 ; pre_r = 0 ; mesh = 1 ; row = 1 ; if ( nargin == 0 ) scale = 1. ; % the default scale i_p = 1 ; inc_v = 1 ; elseif ( nargin == 1 ) i_p = 1 ; inc_v = 1 ; elseif ( nargin == 2 ) inc_v = 1 ; end % if less = row - 1 ; %CL fprintf ('Using a scale of %g and vector increment of %g \n', ... scale, inc_v) % 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 np = np - less ; %CL ns = size (msh_bc_xyz,2) - pre_p ; % dimension of space fprintf ('Read %g mesh coordinates in %g-D space. \n', np, ns) % fprintf (' x y \n') % 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 nt = nt - less ; %CL nod_per_el = size (msh_typ_nodes,2) - pre_e -1 % nodes per element fprintf ('Read %g elements connections \n', nt) Col_1 = pre_e+2 ; %CL Col_2 = nod_per_el+pre_e+1 ; %CL % read 2-d reaction vector at nodes (can be a beam) load node_reaction.tmp % Set control data: number of Reaction points npg = size(node_reaction,1) ; % reaction pts w vectors npg = npg - pre_r ; %CL if ( npg == 0 ) error ('Error: missing file node_reaction.tmp') end % if error fprintf ('Read %g nodal reaction sets \n', npg) %b if ( ns > 1 ) % not a beam %if ( ns == 1 ) % 1D beam, 2 dof % nf = size(node_reaction,2)-3 ; % flux components % if ( nf ~= 1 ) % vectors not meaningful % fprintf ('Read %g reaction components instead of 1 \n', nf) % end % if vector data %end % if not a beam x (np) = 0. ; % pre-allocate array x y (np) = 0. ; % pre-allocate array y %b x_bar (nt) = 0. ; % pre-allocate array x_bar %b y_bar (nt) = 0. ; % pre-allocate array y_bar 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 % Mesh Range Alone % msh_bc_xyz has: pre_p items then: x, y %b x = msh_bc_xyz (1:np, (pre_p+1)) ; % extract x column of xy %b y = msh_bc_xyz (1:np, (pre_p+2)) ; % extract y column of xy x = msh_bc_xyz (row:(np+less), (pre_p+1)) ; % extract x %CL if ( ns > 1 ) % not beam, use true y y = msh_bc_xyz (row:(np+less), (pre_p+2)) ; % extract y %CL end % if gxmax = max (x) ; gxmin = min (x) ; gymax = max (y) ; gymin = min (y) ; gxdiff = gxmax - gxmin ; gydiff = gymax - gymin ; if ( gydiff == 0.0 ) gydiff = 0.5 ; % allow for 1-D mesh (with y == 0) end % if no y coordinates % Vector Values g_x = zeros (npg, 1) ; g_y = zeros (npg, 1) ; g_dx = zeros (npg, 1) ; g_dy = zeros (npg, 1) ; if ( ns == 1 ) % beam empty = zeros (npg, 1) ; end % if for j = 1:npg ; node = node_reaction (j, 1) ; DOF = node_reaction (j, 2) ; value = node_reaction (j, 3) ; g_x (j) = x (node) ; % position g_y (j) = y (node) ; % position if ( DOF == 1 ) g_dx (j) = value ; else g_dy (j) = value ; end % if end % for g_sq = sqrt (g_dx.^2 + g_dy.^2) ; big = max (g_sq) ; % magnitude largest = 0.0 ; % Scale flux vectors if ( big > largest ) largest = big; end % if if ( ns > 1 ) % then 2D mesh with 2D vectors xmax = gxmax + gxdiff/10 ; ymax = gymax + gydiff/10 ; % keep xmin = gxmin - gxdiff/10 ; ymin = gymin - gydiff/10 ; % keep % xmax = gxmax + gxdiff/20 ; ymax = gymax + gydiff/20 ; % xmin = gxmin - gxdiff/20 ; ymin = gymin - gydiff/20 ; else % 1D mesh with y vector only xmax = gxmax + gxdiff/10 ; xmin = gxmin - gxdiff/10 ; if ( i_p == 1 ) % y force = g_dx ymax = max (g_dx) ; ymin = min (g_dx) ; else % z moment = g_dy ymax = max (g_dy) ; ymin = min (g_dy) ; end % if i_p end % if clf % clear graphics axis ([xmin, xmax, ymin, ymax]) % set axes axis ('equal') % true shape style hold on % hold image for plots grid % add grid dots xlabel (['X Coordinate at ', int2str(np),' Nodes']) ylabel (['Y Coordinate on ', int2str(nt),' Elements (with ', ... int2str(nod_per_el), ' nodes) ']) if ( ns <= 2 ) % not beam title (['FEA 2-D In-plane Beam Reaction Vectors, max = ', ... num2str(largest),' (Scale = ', num2str(scale),')']) elseif ( ns == 3) title (['FEA 2-D In-plane Frame Reaction Vectors, max = ', ... num2str(largest),' (Scale = ', num2str(scale),')']) end % if beam % Select element type details [loop] = get_El_Loop (nod_per_el) ; %% Plot input mesh points & label them % if (lab_p == 1) % plot all points % plot (x, y, 'b.') % mark each node % end % if show labels % Show 20 nodes and 10 elements inc_p = floor(np/10) ; inc_e = floor(nt/5) ; if (inc_p == 0 ) inc_p = np - 1 ; end % if inc_p if (inc_e == 0 ) inc_e = nt - 1 ; end % if inc_e % Show all if a small mesh if ( np <= 20 ) inc_p = 1 ; end % if np if ( nt <= 10 ) inc_e = 1 ; end % if nt % inc_p=0 % inc_e=0 if ( ns == 1 ) % small mesh, show all inc_p = 1 ; inc_e = 1 ; end % if beam if (inc_p > 0) % plot node numbers for i = 1:inc_p:np % convert to string p_text = sprintf (' %g', i); % offset # from pt text (x(i), y(i), p_text) % plot pt number end % for all points end % if show labels % disp (' ') if ( mesh == 1 ) % Loop over all elements for it = 1:nt ; % Extract corner connectivity %b t_nodes = msh_typ_nodes (it, (pre_e+2):(nod_per_el+pre_e+1)); t_nodes = msh_typ_nodes ((it+less), Col_1:Col_2 ) ; %CL % Extract corner coordinates t_x = x (t_nodes) ; % x at those nodes, only t_y = y (t_nodes) ; % y at those nodes, only % Get the centroid x_bar (it) = sum (t_x' )/nod_per_el ; y_bar (it) = sum (t_y' )/nod_per_el ; % Plot this polygon c_x = t_x (loop) ; % x for nod_per_el line polygon c_y = t_y (loop) ; % y for nod_per_el line polygon plot (c_x, c_y, 'g-') % plot nod_per_el lines, in blue end % for over all elements % Finish the plots with polygon numbers if (inc_e > 0) % plot elem number, inclined % plot (x_bar, y_bar, 'g.') % centroid of each element for i = 1:inc_e:nt % convert to string t_text = sprintf (' %g', i); % offset # from pt text (x_bar(i), y_bar(i), t_text, 'Rotation', 45) % incline end % for all polygons end % if show labels end % if mesh plot xtotal = sum (g_dx) ; x_s = sprintf ('Total = %g', xtotal); ytotal = sum (g_dy) ; y_s = sprintf ('Total = %g', ytotal); t_s = sprintf ('Total = [%g, %g]', xtotal, ytotal) ; x_tex = mean (x) / 3 ; dx_tex = (mean (g_dx) + min (g_dx)) / 3 ; dy_tex = (mean (g_dy) + min (g_dy)) / 3 ; %b total (1:2) = [xtotal, ytotal] ; % ---------------- Now add the vectors to the mesh -------------- if ( ns > 1 ) % not beam quiver (g_x, g_y, g_dx, g_dy, scale) else % beam, no scale (scale = 0) if ( i_p == 1 ) % transverse load g_dx = force in y ylabel (['Y Force at ', int2str(nt),' Elements (with ', ... int2str(nod_per_el), ' nodes) ']) yma = max(abs(g_dx)) title (['Beam Force Reaction Vectors, |max| = ', ... num2str(yma)]) quiver (g_x, g_y, empty, g_dx, 0) % , scale) text (x_tex, dx_tex, x_s) else % i_p = 2, moment ylabel (['Z Moment at ', int2str(nt),' Elements (with ', ... int2str(nod_per_el), ' nodes) ']) yma = max(abs(g_dy)) ; title (['Beam Moment Reaction Vectors, CCW is up, |max| = ', ... num2str(yma)]) ; quiver (g_x, g_y, empty, g_dy, 0) % , scale) % g_dy = moment text (x_tex, dy_tex, y_s) end % if reaction type i_p end % if beam, ns = 1 % -depsc -tiff % for an eps version %b print -dpsc quiver_reaction_vec_mesh hold off %b fprintf ('Created file reaction_vec_mesh.ps \n') % end quiver_reaction_vec_mesh