%
%  annular_plate_bc_apply.m  ver 1.2  September 7, 2012
%
function[mass,stiff,pp,con]=annular_plate_bc_apply(mass,stiff,nc,nr)
%
%%   
%%    The constraint matrix must have three four columns:  node number   TZ RX RY 
%%    A value of 1 indicates a constraint.  A value of 0 indicates free. 
%
    pp=0;
    con(1)=0;
%
    THM=zeros(nc*nr,4);
    for i=1:nc*nr
        THM(i,1)=i;
    end
%    
%
    disp(' ');
    disp(' Enter inner BC:  1=fixed  2=simply supported  3=free ');
    inner_BC=input(' ');
%
    disp(' ');
    disp(' Enter outer BC:  1=fixed  2=simply supported  3=free ');
    outer_BC=input(' ');
%
    if(inner_BC ==1)
        THM(1:nc,2)=1;
        THM(1:nc,3)=1;
        THM(1:nc,4)=1;       
    end
    if(inner_BC ==2)
        THM(1:nc,2)=1;       
    end    
%
    ia=nc*(nr-1)+1;
    ib=nc*nr;
    if(outer_BC ==1)
        THM(ia:ib,2)=1;
        THM(ia:ib,3)=1;
        THM(ia:ib,4)=1;       
    end
    if(outer_BC ==2)
        THM(ia:ib,2)=1;        
    end
%
if(inner_BC ==3 && outer_BC ==3)
else
%
    sz = size(THM);
    nc=sz(1);
%
    ij=1;
%
        progressbar;
        for i=1:nc
            progressbar(i/nc);
%        
            nodec=THM(i,1);
%        
            if(THM(i,2)==1)
                con(ij)=3*nodec-2;
                ij=ij+1;
            end
%        
            if(THM(i,3)==1)
                con(ij)=3*nodec-1;
                ij=ij+1;
            end
%     
            if(THM(i,4)==1)
                con(ij)=3*nodec;
                ij=ij+1;
            end       
%
        end
        progressbar(1);
%
        clear length;
        pp=length(con);
        con=con';
        con=sort(con,1,'descend');
        con;
%
    progressbar;
    for ij=1:pp
        progressbar(ij/pp);
%        
         k=con(ij);
         mass(:,k)=[];
         mass(k,:)=[];
        stiff(:,k)=[];
        stiff(k,:)=[];        
%
    end
    progressbar(1);
end   