function true_qp_flux_er_sq_graph (i_p, Exact) % Copyright 2000 J.E. Akin. All rights reserved. % under construction: requires analytic exact solution % variable "p_ar" (analytic result) for "Exact" case number % ------------------------------------------------------ % Matlab graph of i_p-th 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) load el_qp_xyz_fluxes.tmp nr = size (el_qp_xyz_fluxes, 1); % rows ngp = nr/nt ; % gauss points if ( nr == 0 ) error ('Error missing file el_qp_xyz_fluxes.tmp') end % if error max_p = size (el_qp_xyz_fluxes, 2) ; % number of columns fprintf ('Read %g element flux values \n', nt) fprintf (' at %g quadrature pts \n', ngp) %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 % 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 % Cite max, min values [V_X, L_X] = max (el_qp_xyz_fluxes(:, 2)); [V_N, L_N] = min (el_qp_xyz_fluxes(:, 2)); fprintf ('Max flux is %g at elem %g \n', V_X, round(L_X/2)) fprintf ('Min flux is %g at elem %g \n', V_N, round(L_N/2)) null (1:np) = 0.0 ; % Initialize plots % maxy = max (y) ; miny = min (y) ; % maxe = max (error) ; mine = min (error) ; ymin=-0.10 ymax= 0.10 % manual set %% 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 % diff = ymax - ymin ; % ymax = ymax + abs (diff)/20. ; % ymin = ymin - abs (diff)/20. ; clf % clear graphics axis ([xmin, xmax, ymin, ymax]) % set axes hold on % hold image for plots xlabel ('X, Node number at 45 deg') if ( i_p >= 1 ) title(['Exact Error in Element Flux Component\_', int2str(i_p),': ', ... int2str(nt),' Elements, ', int2str(np),' Nodes']) ylabel ('Error in Flux ') else % i_p = 0, get root mean sq title(['Exact Error in RMS\_value of Element Flux Component\_', ... int2str(i_p),': ', int2str(nt), ' Elements, ', ... int2str(np),' Nodes']) ylabel ('Flux RMS Error ') end % if get RMS value % 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 ; p_el = el_qp_xyz_fluxes(2*it, 2) ; % Extract element connectivity t_nodes = msh_typ_nodes (it, (pre_e+2):(nod_per_el+pre_e+1)); % Extract linear element coordinates & values t_x = x (t_nodes) ; % x at those nodes, only t_y = y (t_nodes) ; % y at those nodes, only % Plot this element (if non-sequential use loop) p1 = min(t_x); p2 = max(t_x); p_dif=(p2 - p1); p_inc=p_dif/p_div; j = 0; for p = p1:p_inc:p2 % loop over points inside element p_x(1:2) = p ; %------------- if ( i_p >= 1 ) 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 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 %------------- % p_ar = (1. - (N+2)*p^(N+1))/((N+1)*(N+2)) ;% analytic result % 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) ; er_el = (p_el - p_ar) ; p_er(2) = er_el ; plot (p_x, p_er) % plot vertical lines j = j + 1; x_c(j) = p ; cap(j) = er_el ; end % for pt in elem plot (x_c, cap, 'r-') % capline 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 % v_text = sprintf ('---min') ; % text (x(L_N), V_N, v_text) ; % v_text = sprintf ('---max') ; % text (x(L_X), V_X, [v_text]) ; % -depsc -tiff % for an eps version print ('-dpsc', ['true_qp_flux_error_', int2str(i_p), '_graph']) hold off v_text = ['Created true_qp_flux_error_', int2str(i_p), '_graph.ps'] ; fprintf (1,'%s', v_text) ; fprintf (1, ' \n' ) % end of true_qp_flux_er_sq_graph