function TISE_C2_L2_graph (i_p, mode) % Copyright 2000 J.E. Akin. All rights reserved. % under construction: requires analytic exact solution % ------------------------------------------------------ % Matlab graph of i_p-th component value at mesh nodes % for a mesh of 3 node quintic Hermite line elements % i_p = 1 is solution, = 2 is solution slope % mode > 0 then is eigenvector to be scaled % ------------------------------------------------------ % 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 % UNDER_CONSTRUCTION if ( nargin == 0 ) i_p = 1 ; mode = 0 ; elseif ( nargin == 1 ) mode = 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 coordinates \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) if ( nod_per_el ~= 2 ) error ('This is not a mesh of 2 node line elements') end % if load node_results.tmp nr = size (node_results, 1); if ( nr == 0 ) error ('Error missing file node_results.tmp') end % if error max_p = size (node_results, 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 ) fprintf ('Data requested for component i_p = %g \n', i_p) error ('i_p > available data') end % if error H (2) = 0. ; HC2 (6) = 0. ; 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 t_dy (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) ; if ( mode > 0 ) % scale the eigenvector [Big, Loc] = max ( abs (node_results(:, 1)) ) ; node_results = node_results ./ node_results(Loc, 1) ; end % if mode y = node_results(:, 1) ; dy = node_results(:, 2) ; d2y = node_results(:, 3) ; ysq = y .^2 ; %% Cite max, min values %[V_X, L_X] = max (y) ; %[V_N, L_N] = min (y) ; % Initialize plots if ( i_p == 1 ) maxy = max (y) ; miny = min (y) ; maxysq = max (ysq) ; minysq = min (ysq) ; end % if if ( i_p == 2 ) maxy = max (dy) ; miny = min (dy) ; end % if if ( i_p == 3 ) maxy = max (d2y) ; miny = min (d2y) ; end % if % finalize axes ymax = maxy ; ymin = miny ; ymax = ymax + abs (ymax)/5.0 ; ymin = ymin - abs (ymin)/5.0 ; clf % clear graphics %b ymin=-0.7 axis ([xmin, xmax, ymin, ymax]) % set axes hold on % hold image for plots xlabel (['X, Node at 45 deg (', int2str(nod_per_el), ... ' per element), Element at 90 deg']) if ( i_p == 1 ) title(['TISE Qunitic C2 FEA Waveform from: ', ... int2str(nt),' Elements, ', int2str(np),' Nodes']) [V_X, L_X] = max (y) ; [V_N, L_N] = min (y) ; ylabel (['Y Value, solid (',num2str(V_N), ' to ', ... num2str(V_X), '), Y ^2 dashed']) elseif (i_p == 2 ) title(['TISE Qunitic C2 FEA Waveform Slope from: ', ... int2str(nt),' Elements, ', int2str(np),' Nodes']) [V_X, L_X] = max (dy) ; [V_N, L_N] = min (dy) ; ylabel (['Y Slope Value, solid (',num2str(V_N), ' to ', ... num2str(V_X), ')']) elseif (i_p == 3 ) title(['TISE Qunitic C2 FEA Waveform Curvature from: ', ... int2str(nt),' Elements, ', int2str(np),' Nodes']) [V_X, L_X] = max (d2y) ; [V_N, L_N] = min (d2y) ; ylabel (['Y" Value, solid (',num2str(V_N), ' to ', ... num2str(V_X), ')']) end % i_p 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 ; % Loop over all elements 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 A = abs(t_x(2) - t_x(1)) ; t_y = y (t_nodes) ; % y at those nodes, only t_dy = dy (t_nodes) ; % dy at those nodes, only t_d2y = d2y (t_nodes) ; % dy at those nodes, only D (1:3:6) = t_y ; D (2:3:6) = t_dy ; D (3:3:6) = t_d2y ; t_ysq = t_y .^2 ; if ( i_p == 1 ) plot (t_x, t_y, 'ko') % plot nodal value symbols elseif ( i_p == 2 ) plot (t_x, t_dy, 'ko') % plot nodal value symbols elseif ( i_p == 3 ) plot (t_x, t_d2y, 'ko') % plot nodal value symbols end % if % 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) % % c_x = t_x (loop) ; % x for nod_per_el line element % % c_y = t_y (loop) ; % values at nodes % % plot (c_x, c_y) % plot nod_per_el lines % plot (t_x, t_y) % plot nod_per_el lines % Loop over local points on the quadratic polynomial element n_poly = ceil ( 95 / nt) ; for k = 1: (n_poly + 1) % points in parametric space % get element parametric interpolation functions R = (k - 1)/n_poly ; % on 0 to 1 R3 = R*R*R ; % H = ELEMENT SHAPE FUNCTIONS % LOCAL NODE COORD. ARE 0,+1 1----------2 H (1) = 1. - R ; H (2) = R ; x_el (k) = H * t_x ; % true x value % if ( i_p == 1 ) HC2 (1) = 1 - 10*R3 + 15*R3*R - 6*R3*R*R ; HC2 (2) = (R - 6*R3 + 8*R3*R - 3*R3*R*R)*A ; HC2 (3) = (R*R - 3*R3 + 3*R3*R - R3*R*R)*A*A/2 ; HC2 (4) = 10*R3 - 15*R3*R + 6*R3*R*R ; HC2 (5) = (7*R3*R - 3*R3*R*R - 4*R3)*A ; HC2 (6) = (R3 - 2*R3*R + R3*R*R)*A*A/2 ; y_el (k) = HC2 * D' ; % true y value % elseif (i_p == 2 ) DHC2 (1) = 30 * (2 * R3 - R * R - R3 * R) / A ; DHC2 (2) = 1 - 18 * R * R + 32 * R3 - 15 * R3 * R ; DHC2 (3) = 0.5*(2 * R - 9 * R * R + 12 * R3 - 5 * R3 * R)*A ; DHC2 (4) = 30 * R * R * (1 - 2 * R + R * R) / A ; DHC2 (5) = 28 * R3 - 15 * R3 * R - 12 * R * R ; DHC2 (6) = 0.5 * R * R * (3 - 8 * R + 5 * R * R) * A ; dy_el (k) = DHC2 * D' ; % true y value % elseif ( i_p == 3) D2HC2 (1) = 30 * (6 * R^2 - 2 * R - 4 * R3) / A^2 ; D2HC2 (2) = ( - 36 * R + 96 * R * R - 60 * R3) / A ; D2HC2 (3) = 0.5 * (2 - 18 * R + 36 * R * R - 20 * R3) ; D2HC2 (4) = 30 * (2 * R - 6 * R * R + 4 * R3) / A^2 ; D2HC2 (5) = (84 * R * R - 60 * R3 - 24 * R) / A ; D2HC2 (6) = 0.5 * (6 * R - 24 * R * R + 20 * R3) ; d2y_el (k) = D2HC2 * D' ; % true y value end % if i_p end % for k if ( i_p == 1 ) plot (x_el, y_el) ysq_el = y_el .^2 ; plot (x_el, ysq_el,'k--') elseif ( i_p == 2 ) plot (x_el, dy_el) % ysq_el = dy_el .^2 ; % plot (x_el, ysq_el,'k--') elseif ( i_p == 3 ) plot (x_el, d2y_el) % ysq_el = d2y_el .^2 ; % plot (x_el, ysq_el,'k--') end % if 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', ['true_L3_TISE_', int2str(i_p), '_graph']) hold off %b v_text = ['Created true_L3_TISE_', int2str(i_p), '_graph.ps'] ; %b fprintf (1,'%s', v_text) ; fprintf (1, ' \n' ) % end of TISE_C2_L2_graph