function true_flux_scp_qp_zoom (i_p, Exact) % ZOOM version of true_flux_scp_qp_graph for text figure % Copyright 2000 J.E. Akin. All rights reserved. % under construction: requires analytic exact solution % variable "ar" (analytic result) for "Exact" case number % ------------------------------------------------------ % Matlab graph of i_p-th flux component value at mesh nodes % If i_p = 0, show RMS value % ------------------------------------------------------ % c_x = x coordinates of nod_per_el line element % msh_typ_nodes = connectivity list for elements, nt x nod_per_el % loop = corners for nod_per_el line element % 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 % fprintf ('Begin component value graph: \n') if ( nargin == 0 ) i_p = 0 ; Exact = 0 ; end % if no arguments if ( nargin == 1 ) Exact = 0 ; end % if 1 argument % fprintf ('Begin graph for exact case %g \n', Exact) % 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 ~= 1) error ('This is not a 1D mesh') end % if not 1D 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) % Read new Gauss locations & flux component load el_qp_xyz_fluxes.tmp ; % x, du/dx % Set control data: number of gauss points npg = size(el_qp_xyz_fluxes,1) ; % quadrature pts w vectors if ( npg == 0 ) error ('Error: missing file el_qp_xyz_fluxes.tmp') end % if error % Gauss points are always inside the mesh geometry g_x = el_qp_xyz_fluxes(:,1) ; % position g_dx = el_qp_xyz_fluxes(:,2) ; % flux 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 solution values \n', nr) fprintf (' with %g components each \n', max_p) if ( i_p > max_p ) error ('i_p > available data') end % if error x (np) = 0. ; % pre-allocate array x y (np) = 0. ; % pre-allocate array y 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) = 0 ; % Optional pre-allocation c_y (nod_per_el) = 0 ; % Optional pre-allocation g_y (nod_per_el) = 0 ; % Optional pre-allocation % set constants loop = [1:nod_per_el] ; % default to sequential order % msh_bc_xyz has: pre_p items then: x, y x = msh_bc_xyz (1:np, (pre_p+1)) ; % extract x column xmax = max (x) ; xmin = min (x) ; % add analytic points a_inc = (xmax-xmin)/(10*nt) ; ax = [xmin:a_inc:xmax] ; % analytic points if ( i_p >= 1 ) y = scp_node_ave_fluxes(:, i_p) ; if ( Exact == 9 ) % u" + U + x = 0, EBC, EBC ar = cos(ax)/sin(1) - 1.0; % analytic result elseif ( Exact == 10 ) % u" + U + x = 0, EBC, NBC ar = cos(ax)/cos(1) - 1. ; % analytic result elseif ( Exact == 11 ) % u" + X^N = 0, U(0)=0=U(1), N = input ('Enter source exponent N in Q = x^N ') ar = (1.-(N+2)*ax.^(N+1))/((N+1)*(N+2)) ; % analytic result else fprintf ('Unknown exact_case %g \n', Exact) error ('No solution given for Exact_Case number') end % if Exact % ar = (1. - (N+2)*ax.^(N+1))/((N+1)*(N+2)) ;% analytic result % ar = cos(ax)/sin(1) - 1.0; % analytic result % ar = cos(ax)/cos(1) - 1.0; % analytic result else % i_p = 0, get root mean sq for k = 1:np y (k) = sqrt ( sum (scp_node_ave_fluxes (k, 1:max_p).^2)) ; end % for k g_dx = abs(g_dx) ; % Gauss values if ( Exact == 9 ) % u" + U + x = 0, EBC, EBC ar = abs(cos(ax)/sin(1) - 1.0); % analytic result elseif ( Exact == 10 ) % u" + U + x = 0, EBC, NBC ar = abs(cos(ax)/cos(1) - 1.) ; % analytic result elseif ( Exact == 11 ) % u" + X^N = 0, U(0)=0=U(1), N = input ('Enter source exponentt N in Q = x^N ') ar = abs(1.-(N+2)*ax.^(N+1))/((N+1)*(N+2)) ; % analytic result else error ('No solution given for Exact_Case number') end % if Exact % ar = abs( (1. - (N+2)*ax.^(N+1))/((N+1)*(N+2)) );% analytic result % ar = abs( cos(ax)/sin(1) - 1.0) ; % analytic result % ar = abs( cos(ax)/cos(1) - 1.0) ; % analytic result end % if get RMS value maxa = max (ar) ; mina = min (ar) ; % Cite max, min values [V_X, L_X] = max (y) ; [V_N, L_N] = min (y) ; 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) null (1:np) = V_N ; % Initialize plots maxy = max (y) ; miny = min (y) ; % finalize axes ymax = max ([maxy, maxa]) ; ymin = min ([miny, mina]) ; if ( ymax == ymin ) if ( abs (ymax) > 0 ) ymax = ymax + abs (ymax)/20. ; ymin = ymin - abs (ymin)/20. ; end % if end % if clf % clear graphics %b ymax= 0.25 %b ymin = -0.35 xmin = .15 xmax = .45 ymin = 0.03 ymax = 0.19 axis ([xmin, xmax, ymin, ymax]) % set axes hold on % hold image for plots xlabel (['X, Near Element 2 (of ', ... int2str(nt),' Elements, ', int2str(np),' Nodes)']) % xlabel ('X, Node number at 45 deg, Element number at 90 deg') if ( i_p >= 1 ) title(['Exact (dash), FEA SCP (solid), Gauss Point ', ... '(dash dot) Flux. Estimated Error (vertical)']) % title(['Exact (dash), FEA SCP (solid) & GPFlux Component\_', ... % int2str(i_p),': ', ... % int2str(nt),' Elements, ', int2str(np),' Nodes']) ylabel (['Component ', int2str(i_p), ' (SCP max = ', ... num2str(V_X), ', min = ', num2str(V_N), ')']) else % i_p = 0, get root mean sq title(['RMS\_value of EXACT, SCP, GP Flux Component\_',int2str(i_p),': ',... int2str(nt), ' Elements, ', int2str(np),' Nodes']) ylabel (['Flux Component\_', int2str(i_p), ... ' RMS Value (SCP max = ', num2str(V_X), ', min = ', num2str(V_N), ')']) end % if get RMS value % add analytic plot and Gauss plot plot (ax, ar, 'r--') plot (g_x, g_dx, 'ko') % for L2 element add constant flux line % Loop over all elements p_div = 20 ; p_er(1:2) = 0. ; p_x (1:2) = 0. ; x_c(p_div) = 0 ; cap(p_div) = 0 ; for it = 1:nt ; % Extract element connectivity t_nodes = msh_typ_nodes (it, (pre_e+2):(nod_per_el+pre_e+1)); % Skip point elements, if any if ( all (t_nodes) ) % then valid line % Extract element coordinates & values t_x = x (t_nodes) ; % x at those nodes, only t_y = y (t_nodes) ; % y at those nodes, only % Plot the element number x_bar = sum (t_x' )/nod_per_el ; t_text = sprintf (' (%g)', it); % offset # from pt text (x_bar, V_N, t_text, 'Rotation', 90) % incline plot (x_bar, V_N, 'k+') %b text (x_bar, 0.0, t_text, 'Rotation', 90) % incline %b plot (x_bar, 0.0, 'k+') % Plot this element (if non-sequential use loop) plot (t_x, t_y) % plot nod_per_el lines if ( nod_per_el == 2 ) % add qp constant line g_y (1) = g_dx (2*it) ; g_y (2) = g_dx (2*it) ; plot (t_x, g_y,'k-.') % plot nod_per_el lines end % if horz line % add vertical error lines p1 = min(t_x); p2 = max(t_x); p_dif=(p2 - p1); p_inc=p_dif/p_div ; j = 0; p_er(1) = g_dx (2*it) ; % constant qp for p = p1:p_inc:p2 % loop over points inside element p_x(1:2) = p ; %------------- if ( i_p >= 1 ) y = scp_node_ave_fluxes(:, i_p) ; if ( Exact == 9 ) % u" + U + x = 0, EBC, EBC p_ar = cos(p)/sin(1) - 1.0; % analytic result elseif ( Exact == 10 ) % u" + U + x = 0, EBC, NBC p_ar = cos(p)/cos(1) - 1. ; % analytic result elseif ( Exact == 11 ) % u" + X^N = 0, U(0)=0=U(1), N = input ('Enter source exponent N in Q = x^N ') p_ar = (1.-(N+2)*p^(N+1))/((N+1)*(N+2)) ; % analytic result else error ('No solution given for Exact_Case number') end % if Exact else % i_p = 0, get root mean sq for k = 1:np y (k) = sqrt ( sum (scp_node_ave_fluxes (k, 1:mp_p).^2)) ; end % for k if ( Exact == 9 ) % u" + U + x = 0, EBC, EBC p_ar = abs(cos(p)/sin(1) - 1.0); % analytic result elseif ( Exact == 10 ) % u" + U + x = 0, EBC, NBC p_ar = abs(cos(p)/cos(1) - 1.) ; % analytic result elseif ( Exact == 11 ) % u" + X^N = 0, U(0)=0=U(1), N = input ('Enter source exponentt N in Q = x^N ') p_ar = abs(1.-(N+2)*p^(N+1))/((N+1)*(N+2)) ; % analytic result else error ('No solution given for Exact_Case number') end % if Exact value end % if i_p = 0 %------------- %b p_ar = (1. - (N+2)*p^(N+1))/((N+1)*(N+2)) ;% %b p_ar = cos(p)/sin(1) - 1.0 ; % analytic result % linear element interpolation h1 = (t_x(2) - p)/p_dif; p_el = h1*t_y(1) + (1. - h1)*t_y(2) ; %b er_el = (p_el - p_ar) ; p_er(2) = p_el ; % p_er(2) = p_ar ; %b er_el ; plot (p_x, p_er) % plot vertical lines j = j + 1; %b x_c(j) = p ; %b cap(j) = er_el ; end % for pt in elem end % if zero in connectivity end % for over all elements % plot node points on axis for i = 1:np t_text = sprintf (' %g', i); % offset # from pt text (x(i), null(i), t_text, 'Rotation', 45) % incline end % for all plot (x, null, 'k*') grid % label max min points % plot (x(L_X), y(L_X), 'kx') % plot (x(L_N), y(L_N), 'ko') %b v_text = sprintf ('---min') ; %b text (x(L_N), V_N, v_text) ; %b v_text = sprintf ('---max') ; %b text (x(L_X), V_X, [v_text]) ; % -depsc -tiff % for an eps version %b print ('-dpsc', ['zoom_true_qp_flux_', int2str(i_p), '_1d']) hold off y %b fprintf (1,'%s', v_text) ; fprintf (1, ' \n' ) % end of true_flux_scp_qp_zoom