function color_qp_flux_mag_mesh (i_p, Ave) % Copyright 2000, J.E. Akin. All rights reserved. % ------------------------------------------------------ % Matlab color plot of i_p-th component value, % at mesh node locations % i_p: 1-Flux_x, 2-Flux_y, 3-resultant % Ave: 0-use maximum in element, 1-use average value % ------------------------------------------------------ % c_x = x coordinates of nod_per_el line polygon % c_y = y coordinates of nod_per_el line polygon % msh_typ_nodes = connectivity list for elements, nt x nod_per_el % loop = corners for nod_per_el line polygon % nod_per_el = Nodes per element % np = Number of Points % nt = Number of elements % pre_e = Element items before connectivity list pre_e = 1 % pre_p = Nodal items before coordinates pre_p = 1 % 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 format short g if ( nargin == 0 ) i_p = 3 ; Ave = 0; elseif ( nargin == 1) Ave = 0; end % if no arguments if ( i_p == 0 ) i_p = 3 ; end % if % 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 fprintf ('Read %g mesh coordinate pairs \n', np) ns = size (msh_bc_xyz,2) - pre_p ; % space dimension if ( ns < 2 ) error ('This is not a 2D mesh') end % if not 2D data % 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) t_n = sum ( msh_typ_nodes (:, nod_per_el + pre_e) > 0 ) ; % default types t_1 = sum ( msh_typ_nodes (:, pre_e) == 1 ) % Type 1 if ( nt > t_n) % then use default types only fprintf ('Using %i elements of default type out of %i \n', t_n, nt) nt = t_n ; end % if load el_qp_xyz_fluxes.tmp nr = size (el_qp_xyz_fluxes, 1); if ( nr == 0 ) error ('Error missing file el_qp_xyz_fluxes.tmp') end % if error max_p = size (el_qp_xyz_fluxes, 2) - ns ; % number of columns nr = nr / nt ; % convert to number of quadrature values per element fprintf ('Read %g qp sets per element \n', nr) fprintf (' with %g components each \n', max_p) %b nr = nr / nt ; % convert to number of quadrature values per element if ( i_p > 3 ) error ('i_p >3, no available data') end % if error x (np) = 0. ; % pre-allocate array x y (np) = 0. ; % pre-allocate array y z (nt) = 0. ; % pre-allocate array z 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) ; % msh_bc_xyz has: pre_p items then: x, y x = msh_bc_xyz (1:np, (pre_p+1)) ; % extract x column y = msh_bc_xyz (1:np, (pre_p+2)) ; % extract y column root_2 = sqrt (2.) ; %% average element nr quadrature values for color % for it = 1:nt % here = nr*(it-1) + 1; % last = here + nr - 1; % set = el_qp_xyz_fluxes(here:last, 1)^2 ... % + el_qp_xyz_fluxes(here:last, 2)^2 ; % set = sqrt (set) ; % if ( Ave == 1 ) % z (it) = mean ( set) ; % else % z (it) = max ( set) ; % end % if % end % for % Initialize plots xmax = max (x) ; xmin = min (x) ; ymax = max (y) ; ymin = min (y) ; % zmax = max (z) ; zmin = min (z) ; clf % clear graphics % axis ([xmin, xmax, ymin, ymax, zmin, zmax]) % set axes axis ([xmin, xmax, ymin, ymax]) % set axes axis('equal') hold on % hold image for plots xlabel (['X at ', int2str(np),' Nodes']) ylabel (['Y on ', int2str(nt),' Elements (with ', ... int2str(nod_per_el), ' nodes) ']) format short g % Loop over all elements %b for it = 1:nt ; for it = 1:126 ; %b type 1 only % Extract corner connectivity t_nodes = msh_typ_nodes (it, (pre_e+2):(nod_per_el+pre_e+1)); has_n = sum ( sum ( t_nodes > 0 )) ; if ( has_n == nod_per_el ) % default type here = nr*(it-1) + 1 ; last = here + nr - 1 ; qp_set = el_qp_xyz_fluxes(here:last, 3).^2 ... + el_qp_xyz_fluxes(here:last, 4).^2 ; qp_set = sqrt (qp_set) ; if ( Ave == 1 ) z (it) = mean ( qp_set) ; else z (it) = max ( qp_set) ; 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 % 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 color = z(it) ; fill (c_x, c_y, color) % plot nod_per_el lines end % if default end % for over all elements % Cite max, min values [V_X, L_X] = max (z) ; [V_N, L_N] = min (z) ; fprintf ('Max value is %g at element %g \n', V_X, L_X) fprintf ('Min value is %g at element %g \n', V_N, L_N) if ( V_X == V_N ) % constant value plot, trick colors caxis([V_N (V_X + 1)]) ; % set full color ranges else caxis([V_N V_X]) ; % set full color ranges end % if if ( i_p == 1 ) title([' Flux_x (max = ', ... num2str(V_X), ', min = ', num2str(V_N), ')']) elseif ( i_p == 2 ) title([' Flux_y (max = ', ... num2str(V_X), ', min = ', num2str(V_N), ')']) elseif ( i_p == 3 ) title([' Resultant flux (max = ', ... num2str(V_X), ', min = ', num2str(V_N), ')']) end % if select component fill (c_x, c_y, color), grid % add grid to last one colorbar % end % if show labels %b print ('-dpng', ['color_torsion_', int2str(i_p), '_step']) hold off %b v_text = ['Created color_torsion_', int2str(i_p), '_step.png'] ; %b fprintf (1,'%s', v_text) ; fprintf (1, ' \n' ) % end of color_qp_flux_mag_mesh