function plotflex
%
%  Name:   plotflex
%
%  Usage:  plotflex
%
%

%  Version SWD970916
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This matlab source code was originally     %
% developed as part of "DIAMOND" at          %
% Los Alamos National Laboratory. It may     %
% be copied, modified, and distributed in    %
% any form, provided:                        %
%  a) This notice accompanies the files and  %
%     appears near the top of all source     %
%     code files.                            %
%  b) No payment or commercial services are  %
%     received in exchange for the code.     %
%                                            %
% Original copyright is reserved by the      %
% Regents of the University of California,   %
% in addition to Scott W. Doebling, Phillip  %
% J. Cornwell, Erik G. Straser, and Charles  %
% R. Farrar.                                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

global DAMAGEID GEOM

%
%  Form the Flexibility Shapes
%
switch DAMAGEID.nflexload,
case 'Uniform',
   loadvec = ones(size(DAMAGEID.undamflex,1),1);
   DAMAGEID.undamflexshp = DAMAGEID.undamflex * loadvec * DAMAGEID.iflexsgn;
   DAMAGEID.damflexshp = DAMAGEID.damflex * loadvec * DAMAGEID.iflexsgn;
case 'Multi Point',
   DAMAGEID.undamflexshp = diag(DAMAGEID.undamflex) * DAMAGEID.iflexsgn;
   DAMAGEID.damflexshp = diag(DAMAGEID.damflex) * DAMAGEID.iflexsgn;
case 'Single Point'
   loadvec = zeros(size(DAMAGEID.undamflex,1),1);
   loadvec(DAMAGEID.iflexdof) = 1;
   DAMAGEID.undamflexshp = DAMAGEID.undamflex * loadvec * DAMAGEID.iflexsgn;
   DAMAGEID.damflexshp = DAMAGEID.damflex * loadvec * DAMAGEID.iflexsgn;
end

%
%  Generate the plot vector
%

switch DAMAGEID.iflextype,
case 'Flexibility Change',
   DAMAGEID.flexplt = DAMAGEID.damflexshp - DAMAGEID.undamflexshp;
case 'Undamaged Flexibility',
	DAMAGEID.flexplt = DAMAGEID.undamflexshp;
case 'Damaged Flexibility',
	DAMAGEID.flexplt = DAMAGEID.damflexshp;
end

%
%  Set plot parameters
%

inodal = 1; % Damage Indicator is Nodal quantity

colormap cool

if ~isempty(GEOM.Bars),
   ngrad = 4; % Number of increments for color gradient shading
   ptdambar(GEOM.Nodes,GEOM.Bars,DAMAGEID.flexplt,DAMAGEID.haxes,inodal,ngrad);
elseif ~isempty(GEOM.Shells),
   ngrad = 4;  % Number of divisions in each direction for shell elements
   ptdamshl(GEOM.Nodes,GEOM.Shells,DAMAGEID.flexplt,DAMAGEID.haxes,inodal,ngrad);
else
   errordlg('ERROR: No Bar or Shell Geometry Defined')
end

damscale(DAMAGEID.hlegax,DAMAGEID.flexplt);

axes(DAMAGEID.haxes)
DAMAGEID.damtitstr = damtitle(['Flexibility Method -',DAMAGEID.iflextype],DAMAGEID.undampath,DAMAGEID.undamfile,...
   DAMAGEID.dampath,DAMAGEID.damfile,[DAMAGEID.nflexload,', ','Modes: ',num2str(DAMAGEID.mode_anal)]);
title(['Flexibility Method -',DAMAGEID.iflextype])

return