%
%  beam_data_entry.m  ver 1.1  January 15, 2014
%
function[E,I,A,rho,ibc,ne,total_length,xv,dx,dof,ipm,pm,xpm]=...
                                                        beam_data_entry(iu)
%
pm=0.;
xpm=0.;
%
[A,I,total_length]=beam_geometry(iu);
%
disp(' ');
disp(' Select material '); 
disp(' 1=aluminum  2=steel  3=G10  4=other '); 
imat = input(' '); 
% 
if(imat==1)      % aluminum 
    if(iu==1)
        E=1.0e+07; 
        rho=0.1;
    else
        E=6.891e+010; 
        rho=2768;        
    end
end  
% 
if(imat==2)      % steel 
    if(iu==1)
        E=3.0e+07; 
        rho=0.285; 
    else
        E=2.067e+011;
        rho=7887;
    end
end
%
if(imat==3)   % G10
    if(iu==1)
       E=2.7e+006;  
       rho=0.065 ;
    else
       E=1.8606e+010; 
       rho=1799.;
    end
end
% 
if(imat~=1 && imat ~=2 && imat ~=3) 
    disp(' ');
    if(iu==1)
        disp(' Enter elastic modulus (lbf/in^2)');
    else
        disp(' Enter elastic modulus (N/m^2)');        
    end
    E=input(' '); 
%
    disp(' '); 
    if(iu==1)
        disp(' Enter mass density (lbm/in^3)');
    else
        disp(' Enter mass density (kg/m^3)');      
    end
    rho=input(' '); 
%    
end 
% 
if(iu==1)
    rho=rho/386.;
end
%
rho=rho*A;  
%
%
%  Recommend at least 16 elements to obtain reasonably accurate effective
%  modal mass values.
%
disp(' ');
ne = input(' Enter the number of elements ');
%
if(ne > 100) 
    ne=100;
end
%
disp(' ');
disp(' Enter boundary conditions ');
disp('  1=free-free ');
disp('  2=fixed-free ');
disp('  3=fixed-fixed ');
disp('  4=fixed-pinned ');
disp('  5=pinned-pinned ');
ibc=input(' ');
%
%
disp(' ');
disp(' Enter point mass? ');
ipm=input(' 1=yes  2=no ');
if(ipm==1)
   xpm= input(' What is the distance of the point mass from the left boundary ?');
   disp(' ');
   if(iu==1)
      pm= input(' What is the point mass (lbm)?');
      pm=pm/386.;
   else
      pm= input(' What is the point mass (kg)?');       
   end    
end
%
dxx=total_length/ne;
xv=zeros(ne+2,1);
for i=2:(ne+2)
    xv(i)=xv(i-1)+dxx;
end
dx=zeros(ne+1,1);
for i=1:(ne+1)
    dx(i)=xv(i+1)-xv(i);
end
%
iflag=0;
if(ipm==1)
    for i=1:(ne+1)
      if( abs(xpm-xv(i))< total_length/1000.)
          xpm=xv(i);
          iflag=1;
          break;
      end
    end
end
if(ipm==1 && iflag==0)
    xv(ne+2)=xpm;
    temp=sort(xv);
    num=max(size(temp));
    num=num-1;
    for i=1:num
        dx(i)=temp(i+1)-temp(i);
    end    
    ne=ne+1;
end
dof=2*ne+2;