function sedambar
%
% Function: sedambar.m
% 
% Usage: sedambar
% 
% Description:
%    Computes and plots the strain energy
%    damage indicators for bar geometry
%

%
% Version SWD980701
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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 HANDLES DAMAGEID GEOM

%  Make sure we have enough points to compute curvature

err = zeros(size(GEOM.SEMbeams,2),1);

for i = 1:size(GEOM.SEMbeams,2),
   if length(GEOM.SEMbeams{i}) < 4, err(i) = 1; end
end

if sum(err) ~= 0,
   disp('WARNING: SEMbeams definition does not have at least three points on each SEMbeam (invalid curvature)')
end

numdiv=str2num(get(HANDLES.hsemb(10),'string'));
iopt=get(HANDLES.hsemb(12),'value');

%
%  Compute the damage index for each subdivision of each element
%

[DAMAGEID.DImat,DAMAGEID.DIlocs] = dibars(GEOM.Nodes,GEOM.SEMbeams,DAMAGEID.undammode,...
   DAMAGEID.dammode,DAMAGEID.respDOF,DAMAGEID.interpopt,DAMAGEID.numdiv,DAMAGEID.mode_anal);

%
%  Set plot parameters
%

ngrad = 0;  % ngrad not used for elemental DI values

inodal = 0;  % DI values are elemental

colormap cool

ptdambar(GEOM.Nodes,GEOM.SEMbeams,DAMAGEID.DImat,DAMAGEID.haxes,inodal,ngrad,DAMAGEID.DIlocs);

%  Plot undeformed geometry

damscale(DAMAGEID.hlegax,DAMAGEID.DImat);

axes(DAMAGEID.haxes)
DAMAGEID.damtitstr = damtitle(['Strain Energy Method - Beam Elements'],DAMAGEID.undampath,DAMAGEID.undamfile,...
   DAMAGEID.dampath,DAMAGEID.damfile,['Number of Divs:',num2str(DAMAGEID.numdiv),', ','Modes: ',num2str(DAMAGEID.mode_anal)]);
title(['Strain Energy Method - Beam Elements'])

rotate3d on