function color_fiber_loc_plot (from) % 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 % 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 ) from = 0 ; end %if if ( from == 0 ) name_n = ['LIST1DN.tmp']; name_e = ['LIST1DE.tmp']; name_r = ['fiber_result.tmp']; else if ( from < 10 ) name_n = ['LIST1DN_00', int2str(from), '.tmp']; name_e = ['LIST1DE_00', int2str(from), '.tmp']; name_e = ['fiber_result_00', int2str(from), '.tmp']; elseif ( from < 100 ) name_n = ['LIST1DN_0', int2str(from), '.tmp']; name_e = ['LIST1DE_0', int2str(from), '.tmp']; name_e = ['fiber_result_0', int2str(from), '.tmp']; else name_n = ['LIST1DN_', int2str(from), '.tmp']; name_e = ['LIST1DE_', int2str(from), '.tmp']; name_e = ['fiber_result_', int2str(from), '.tmp']; end % if end % if fid_n = fopen (name_n, 'r') ; fid_e = fopen (name_e, 'r') ; fid_r = fopen (name_r, 'r') ; % load the file arrays Fiber_xy = fscanf (fid_n, '%g \n', [inf]) ; Fiber_ij = fscanf (fid_e, '%g \n', [inf]) ; Fiber_T = fscanf (fid_r, '%g \n', [inf]) ; % Set control data: number of points !b load LIST1DN_001.tmp ; np = size (Fiber_xy,1) ; % number of nodal points ns = size (Fiber_xy,2) - pre_p ; % dimension of space if ( np == 0 ) error ('Error missing file Fiber_xy.tmp') end % if error x (np) = 0. ; % pre-allocate array x y (np) = 0. ; % pre-allocate array y % Fiber_xy has: pre_p items then: x, y x = Fiber_xy (1:np, (pre_p+1)) ; % extract x %CL y = Fiber_xy (1:np, (pre_p+2)) ; % extract y %CL z = (Fiber_T (1:np, 1) + Fiber_T (1:np, 2)) * 0.5 V_X = max (max ( Fiber_T )) V_N = min (min ( Fiber_T )) % Set control data: number elements & nodes_per_element !b load LIST1DE_001.tmp ; % nod_per_el nodes per element nt = size (Fiber_ij,1); % number of elements if ( nt == 0 ) error ('Error missing file Fiber_ij.tmp') end % if error nod_per_el = size (Fiber_ij,2) - pre_e ; % nodes per element Col_1 = 1 ; Col_2 = 2 ; 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 % set constants [loop] = [ 1, 2, 1] ; % Initialize plots xmax = max (x) ; xmin = min (x) ; ymax = max (y) ; ymin = min (y) ; !b xdiff = xmax - xmin ; ydiff = ymax - ymin ; 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), ... ' Elements, ', int2str(np),' Nodes', ... ' (', int2str(nod_per_el), ' per element)']) Rank_X = 8 ; Rank_N = 1; % for color scale caxis([Rank_N Rank_X]) ; % set full color ranges % Loop over all elements for it = 1:nt ; % Extract corner connectivity t_nodes = Fiber_ij ((it), 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 t_z = z (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 V_R = z (it) ; Rank = round ((Rank_X * (V_R-V_N) + Rank_N * (V_X-V_R)) / V_XN); plot (c_x, c_y, Rank) % plot nod_per_el lines end % for over all elements colorbar hold off % end of color_fiber_loc_plot %b % Rank the colors %b Rank = Rank - 1 ; %b if ( Rank == 0 ) %b Rank = 7 ; %b end % if %b % scale colors as one set of 7 %b if ( Rank == 7) ; color = 'r' ; % red %b elseif ( Rank == 6) ; color = 'y' ; % yellow %b elseif ( Rank == 5) ; color = 'g' ; % green %b elseif ( Rank == 4 ) ; color = 'b' ; % blue %b elseif ( Rank == 3 ) ; color = 'c' ; % cyan %b elseif ( Rank == 2 ) ; color = 'm' ; % magenta %b elseif ( Rank == 1 ) ; color = 'w' ; % white %b else ; color = 'k' ; % black (impossible ??) %b end % if for rank color