function type_rank_mesh_plot (Type, i_val) % Copyright 2000, J.E. Akin. All rights reserved. % ------------------------------------------------------ % Program to plot 2-D FE meshes by element type number % Flag undeleted elements as fat and red % If Type = 0, plot all elements, else only type % If inc_ < 0 show no numbers, = 0 show max of 10 % > 0 use given increment in plotting numbers % ------------------------------------------------------ % 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 inc_e = 0 ; inc_p = 0 ; if (nargin == 0) Type = 0 ; inc_e = 0 ; inc_p = 0 ; i_val = 0 ; % do not show value end % if if (nargin == 1) inc_e = 0 ; inc_p = 0 ; i_val = 0 ; % do not show value end % if % Read coordinate file and connectivity file % integer bc code, real xy pairs for np points (pre_p = 1) % Set control data: number of points load msh_bc_xyz.tmp ; pre_p = 1; np = size (msh_bc_xyz,1) ; % number of nodal points 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 & nodes_per_element load msh_typ_nodes.tmp ; % nod_per_el nodes per element nt = size (msh_typ_nodes,1); % number of elements if ( nt == 0 ) error ('Error missing file msh_typ_nodes.tmp') end % if error %b nod_per_el = size (msh_typ_nodes,2) - pre_e ; % nodes per element nod_per_el = size (msh_typ_nodes,2) - pre_e - 1 ; % nodes per element fprintf ('Read %g elements with an element type \n', nt) fprintf ('and %g nodes each \n', nod_per_el) % Read the list of deleted elements % **************************************************************** % *** in msh_deleted.tmp global substitute 1 for T and 0 for F *** % **************************************************************** load msh_deleted.tmp ; % element number, 1 or 0 for T or F nt_check = size (msh_deleted,1); % number of elements, fibers, segments if ( nt_check == 0 ) error ('Error missing file msh_deleted.tmp') end % if error if ( nt_check < nt ) error ('Error deleted list shorter than mesh list') end % if error n_del = sum ( msh_deleted (:, 2) == 1 ); fprintf ('Number of undeleted elements = %i \n', n_del) %d deleted = msh_deleted (:, 2) load fiber_rank.tmp % elem number to delete, value (in rank sequence) n_f = size (fiber_rank,1); % number of fibers remaining after deletes if ( n_f == 0 ) error ('Error missing file fiber_rank.tmp') end % if error elem = fiber_rank (:, 1) ; value = fiber_rank (:, 2) ; %b value = fiber_rank (:, 3) ; el_type (nt) = 0 ; % pre-allocate array el_type x_bar (nt) = 0. ; % pre-allocate array x_bar 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 % 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: ', int2str(nt),' Elements']) ylabel (['Y: ', int2str(np),' Nodes']) % get the element types el_type = msh_typ_nodes (:, pre_e+1) ; Max_type = max (el_type) ; fprintf (' Maximum element type number is %g \n', Max_type) if ( Type < 0 | Type > Max_type ) error ('Error requested type not available') end % if error % count various types Type_count (1:Max_type) = 0 ; if ( Max_type > 1 ) for j = 1:nt k = el_type (j) ; Type_count ( k ) = Type_count ( k ) + 1 ; end % for j for j = 1:Max_type fprintf ('Type %g has %g elements \n', j, Type_count (j)) end % for j end % if Max_typ %b % Show 10 nodes and 10 elements, or all for small mesh %b if ( inc_e == 0 ) %b nt_show = nt ; %b if ( Type > 0 ) %b nt_show = Type_count (Type) ; %b end % if Type %b if ( nt_show <= 10 ) %b inc_e = 1 ; %b % else %b % inc_e = floor(nt_show/10) ; %b end % if show %b end % if inc_e %b if (inc_p == 0 ) %b if ( np <= 10 ) %b inc_p = 1 ; %b % else %b % inc_p = floor(np/10) ; %b end % if np %b end % if inc_p if ( inc_p > 0 ) in_mesh (1:np) = 0 ; % assume nodes absent end % if % Plot input mesh points & label them if (lab_p == 1) % plot all points plot (x, y, 'b.') % mark each node end % if show labels % Loop over all elements %d nod_per_t = nod_per_el ; Pts_wide = 3 ; % to draw fat lines Old_type = 0; for it = 1:nt ; % ====> ====> ====> ====> ====> ====> ====> ====> %d if ( deleted(it) == 0 ) % then undeleted This_type = el_type (it) ; if ( This_type == Type | Type == 0 ) % then plot it % Extract corner connectivity t_nodes = msh_typ_nodes (it, (pre_e+2):(nod_per_el+pre_e+1)); % Get the type, nodes per type and loop array if ( Old_type ~= This_type ) % ---> ---> ---> ---> ---> ---> Old_type = This_type ; nod_per_t = nod_per_el ; [Low_node, Low_I] = min (t_nodes) ; if ( Low_node <= 0 ) nod_per_t = Low_I - 1 ; end % if shorter topology list % set constants [loop] = get_El_Loop (nod_per_t) ; end % if a new type <--- <--- <--- <--- <--- <--- <--- <--- <--- % Extract corner coordinates t_x = x (t_nodes (1:nod_per_t)) ; % x at those nodes, only t_y = y (t_nodes (1:nod_per_t)) ; % y at those nodes, only % Flag these element's nodes as present in the mesh if ( inc_p > 0 ) in_mesh (t_nodes (1:nod_per_t)) = 1 ; end % if inc_p % Get the centroid x_bar (it) = sum (t_x (1:nod_per_t)' )/nod_per_t ; y_bar (it) = sum (t_y (1:nod_per_t)' )/nod_per_t ; % Plot this polygon c_x = t_x (loop (1:nod_per_t+1)) ; % x for nod_per_t line polygon c_y = t_y (loop (1:nod_per_t+1)) ; % y for nod_per_t line polygon plot (c_x, c_y) % plot nod_per_el lines % re-plot if it was undeleted if ( msh_deleted (it, 2) == 0 ) % then it was undeleted plot (c_x, c_y, 'r-', 'LineWidth',Pts_wide) % re-plot as fat red end % if re-plot end % if the right type %d end % if not deleted yet end % for over all elements <==== <==== <==== <==== <==== <==== <==== <==== if ( Type == 0 ) title (['Rank Undeleted: ', int2str(Max_type), ' Types, ', ... int2str(nt), ' Elements, ', int2str(np),' Nodes', ... ' (', int2str(nod_per_el), ' per el)']) else title (['Type ', int2str(Type), ' Rank Undeleted: ', ... int2str(Type_count (Type)), ' of ', ... int2str(nt), ' Elements, ', int2str(np),' Nodes', ... ' (', int2str(nod_per_t), ' per el)']) end % if % Add the node numbers if requested if ( inc_p > 0 ) % show labels for i = 1:inc_p:np % convert to string if ( in_mesh (i) > 0 ) % it is present p_text = sprintf (' %g', i); % offset # from pt text (x(i), y(i), p_text) % plot pt number end % if present end % for all points end % if show labels %b % Finish the plots with polygon numbers %b if (inc_e > 0) % plot elem number, inclined %b % plot (x_bar, y_bar, 'g.') % centroid of each element %b for it = 1:inc_e:nt % convert to string %b This_type = el_type (it) ; %b if ( This_type == Type | Type == 0 ) % then plot it %b t_text = sprintf (' %g', it); % offset # from pt %b text (x_bar(it), y_bar(it), t_text, 'Rotation', 45) % incline %b plot (x_bar(it), y_bar(it), 'g.') % centroid of each element %b end % if right type %b end % for all polygons %b end % if show labels % Finish the plots with polygon rank format short g for k = 1:n_f if ( i_val == 0 ) % show rank number r_text = sprintf (' %i, %i', k, elem (k)) ; else % show rank value r_text = sprintf (' %i, %g', k, value(k)) ; end % if text (x_bar(elem (k)), y_bar(elem (k)), r_text, 'Rotation', 30) % incline end % for k % -depsc -tiff % for an eps version %bprint -dpsc type_rank_mesh_plot hold off %bfprintf ('Created file type_rank_mesh_plot.ps \n') % end of type_rank_mesh_plot