function flux_on_const_y (i_p, y_p) % Copyright 2000, J.E. Akin. All rights reserved. % ------------------------------------------------------ % If i_p = 0, show RMS 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 = 0 ; % 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 fprintf ('Begin component value carpet plots: \n') if ( nargin == 0 ) i_p = 0 ; y_p = 0. ; elseif ( nargin == 1 ) y_p = 0. ; end % if no arguments % 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 load scp_node_ave_fluxes.tmp nr = size (scp_node_ave_fluxes, 1); if ( nr == 0 ) error ('Error missing file scp_node_ave_fluxes.tmp') end % if error max_p = size (scp_node_ave_fluxes, 2) ; % number of columns fprintf ('Read %g nodal stress values \n', nr) fprintf (' with %g components each \n', max_p) if ( i_p > (max_p+1) ) error ('i_p > available data') end % if error x (np) = 0. ; % pre-allocate array x y (np) = 0. ; % pre-allocate array y z (np) = 0. ; % pre-allocate array z % set constants % msh_bc_xyz has: pre_p items then: x, y y = msh_bc_xyz (1:np, (pre_p+2)) ; % extract x column ymax = max (y) ; ymin = min (y) ; diff = ymax - ymin ; tol = abs ( diff / (10 * np) ) ; given = 0 ; for j = 1:np ; % check all nodes if ( abs (y(j) - y_p) <= tol ) % found a point given = given + 1 ; x (given) = msh_bc_xyz (j, (pre_p+1)) ; % extract y if ( i_p >= 1 & i_p <=3 ) z(given) = scp_node_ave_fluxes(j, i_p) ; elseif ( i_p == 4 ) % Von Mises Stress root_2 = sqrt (2.) ; temp = (scp_node_ave_fluxes (j, 1) ... - scp_node_ave_fluxes (j, 2))^2 ... + scp_node_ave_fluxes (j, 1)^2 ... + scp_node_ave_fluxes (j, 2)^2 ... + scp_node_ave_fluxes (j, 3)^2 * 6 ; z (given) = sqrt ( temp ) / root_2 ; else % i_p = 0, get root mean sq z (given) = sqrt(sum(scp_node_ave_fluxes(j,1:max_p).^2)); end % if get RMS value end % if tol end % for j % Cite max, min values if ( given > 0 ) [V_X, L_X] = max (z(1:given)) ; [V_N, L_N] = min (z(1:given)) ; fprintf ('Max value is %g at node %g \n', V_X, L_X) fprintf ('Min value is %g at node %g \n', V_N, L_N) if ( V_X == V_N ) % constant V_X = V_X + 2; end % if end % if given % Initialize plots xmax = max (x(1:given)) ; xmin = min (x(1:given)) ; zmax = max (z(1:given)) ; zmin = min (z(1:given)) ; clf % clear graphics axis ([xmin, xmax, zmin, zmax]) % set axes axis ('square') hold on % hold image for plots xlabel (['X for ', int2str(given),' Nodes at Y = ', ... num2str(y_p)]) if ( i_p > 0 ) ylabel (['Flux (max = ', ... num2str(V_X), ', min = ', num2str(V_N), ')']) title(['Nodal FEA SCP Flux Component\_',int2str(i_p)]) else % i_p = 0, get root mean sq ylabel (['Nodal RMS Flux Value (max = ', ... num2str(V_X), ', min = ', num2str(V_N), ')']) title(['Nodal RMS SCP Flux Value']) end % if get RMS value plot(x(1:given), z(1:given),'k*') grid [y(1:given),i_sort] = sort( x(1:given) ) ; plot(x(i_sort), z(i_sort), 'k-'); %% end % if show labels % -depsc -tiff % for an eps version %b print ('-dpsc', ['stress_', int2str(i_p), '_on_y']) hold off %b v_text = ['Created stress_', int2str(i_p), '_on_y.ps'] ; %b fprintf (1,'%s', v_text) ; fprintf (1, ' \n' ) % end of flux_on_const_y