function L2_mesh_plot (inc_e, inc_p) % Copyright 2010, J.E. Akin. All rights reserved. % ------------------------------------------------------ % Matlab program to calculate & plot 2-D FE meshes % ------------------------------------------------------ % 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 % 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; % 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 % 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 % x_bar = x-centroid of each element % xy = Coordinates of points, np x 2 % y_bar = y-centroid of each element % Read coordinate file and connectivity file % integer bc code, real xy pairs for np points (pre_p = 1) if ( nargin == 1 ) inc_p = 0; end % if % Set control data: number of points load msh_bc_xyz.tmp ; pre_p = 1; %b pre_p = 0 %b para.e subset only np = size (msh_bc_xyz,1) ; % number of nodal points nt=(np-1)/2 ; % number of elements if sequential nod_per_el = 3 ; ns = size (msh_bc_xyz,2) - pre_p ; % dimension of space if ( np == 0 ) error ('Error missing file msh_bc_xyz.tmp') end % if error fprintf ('Read %g mesh coordinate pairs \n', np) % fprintf (' x y \n') x (np) = 0. ; % pre-allocate array x y (np) = 0. ; % pre-allocate array y % msh_bc_xyz has: pre_p items then: x, y x = msh_bc_xyz (1:np, (pre_p+1)) ; % extract x column of xy if ( ns >= 2) y = msh_bc_xyz (1:np, (pre_p+2)) ; % extract y column of xy else y (1:np) = 0. ; end % if 1D % 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) if ( nod_per_el ~= 2 ) error ('This is not a mesh of 3 node line elements') end % if % Initialize plots xmax = max (x) ; xmin = min (x) ; ymax = max (y) ; ymin = min (y) ; xdiff = xmax - xmin ; ydiff = ymax - ymin ; if ( ydiff == 0.0 ) ydiff = 0.5 ; % allow for 1-D mesh (with y == 0) end % if no y coordinates xmax = xmax + xdiff/10; ymax = ymax + ydiff/10; xmin = xmin - xdiff/10; ymin = ymin - ydiff/10; 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') % add label ylabel ('Y') % add label title (['FE Mesh Geometry: ', int2str(nt), ... ' L2 Elements, ', int2str(np),' Nodes']) % Plot input mesh elements & label them %b true_L2_plot (x, y) ; n_poly = 8 ; x_el = zeros (n_poly, 1) ; y_el = zeros (n_poly, 1) ; for it = 1:nt ; % Extract element connectivity t_nodes = msh_typ_nodes (it, (pre_e+2):(nod_per_el+pre_e+1)); t_x = x (t_nodes) ; % x at those nodes, only t_y = y (t_nodes) ; % y at those nodes, only e_text = sprintf (' (%i)', it); % offset # from pt text (t_x(2), t_y(2), e_text) % Plot element number plot (t_x,t_y) end % for it over all elements % add the node numbers for j = 1:np p_text = sprintf (' %i', j) ; text (x(j), y(j), p_text) ; end % for plot ( x, y, 'k*') extra=0 ; if (extra == 1 ) % add true quarter circle for ang = 1:1:91 ; xex (ang) = 4 * cosd(ang-1) ; yex (ang) = 4 * sind(ang-1) ; end % for ; plot ( xex, yex, 'r-') end % if % -depsc -tiff % for an eps version % print -dpsc mesh_plot hold off % fprintf ('Created file L2_mesh_plot.ps \n') % end of L2_mesh_plot