function bare_fiber_loc_plot (inc_e, inc_p, row) %CL % Copyright 2007, J.E. Akin. All rights reserved. % ------------------------------------------------------ % bare minimum borders % 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 type & connectivity list % pre_p = Nodal items before coordinates % row = row number where cord & connectivity start, 1 or 2 %CL % LIST1DN_001 = 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 pre_e = 0 ; pre_p = 0; if ( nargin == 0 ) inc_e = 0 ; inc_p = 0 ; row = 1 ; %CL elseif ( nargin == 1 ) inc_p = 0 ; row = 1 ; %CL elseif ( nargin == 2 ) %CL row = 1; %CL elseif ( nargin == 3 ) % Chad's data %CL pre_e = 0; %CL end %if less = row - 1 ; %CL % 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 LIST1DN_001.tmp ; np = size (LIST1DN_001,1) ; % number of nodal points np = np - less ; %CL ns = size (LIST1DN_001,2) - pre_p ; % dimension of space if ( np == 0 ) error ('Error missing file LIST1DN_001.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 % LIST1DN_001 has: pre_p items then: x, y x = LIST1DN_001 (row:(np+less), (pre_p+1)) ; % extract x %CL if ( ns >= 2) y = LIST1DN_001 (row:(np+less), (pre_p+2)) ; % extract y %CL else y (1:np) = 0. ; end % if 1D % Set control data: number elements & nodes_per_element load LIST1DE_001.tmp ; % nod_per_el nodes per element nt = size (LIST1DE_001,1); % number of elements nt = nt - less ; %CL if ( nt == 0 ) error ('Error missing file LIST1DE_001.tmp') end % if error nod_per_el = size (LIST1DE_001,2) - pre_e ; % nodes per element fprintf ('Read %g elements with %g nodes each \n', nt,nod_per_el) Col_1 = 1 ; %b pre_e+2 ; %CL Col_2 = 2 ; %b nod_per_el+pre_e+1 ; %CL n_type = 1 ; %b max(Types) ; [M_min, J_min] = min ( LIST1DE_001 (row:less+nt, Col_1:Col_2) ); %CL 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 % set constants [loop] = get_El_Loop (nod_per_el) ; % 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.1 * xdiff ; % allow for 1-D mesh (with y == 0) ymax = ymin + ydiff ; 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 Fiber Geometry: ', int2str(nt), ... ' Segments, ', int2str(np),' Nodes', ... ' (', int2str(nod_per_el), ' per segment)']) % Plot input mesh points & label them if (lab_p == 1) % plot all points plot (x, y, 'b.') % mark each node end % if show labels if (inc_p > 0) % plot node numbers, if node in mesh 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 (' ') % Loop over all elements for it = 1:nt ; % Extract corner connectivity t_nodes = LIST1DE_001 ((it+less), Col_1:Col_2 ) ; %CL [N_min, I_min] = min ( t_nodes ) ; if ( N_min < 1 ) fprintf ('Element %g connectivity corrected \n', it) t_nodes ( I_min:nod_per_el ) = t_nodes ( I_min - 1 ) ; % repeat the last non-zero node end % if % 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) % plot nod_per_el lines 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 % -depsc -tiff % for an eps version hold off % end of bare_fiber_loc_plot