function [K,F] = applybc(numnp,bccode,boundn,boundt,K,F)
%applies boundary conditions

for i=1:numnp
  code=bccode(i);
  if(code==1)   %normal: traction; tangential: traction
    F(2*i)  =F(2*i)  +boundn(i);
    F(2*i-1)=F(2*i-1)+boundt(i);
  end 
  
  if(code==2)   %normal: displacement; tangential: traction
    K(2*i,2*i)=K(2*i,2*i)*1.0e+8 ;
    F(2*i)    =boundn(i)*K(2*i,2*i);
    F(2*i-1)  =F(2*i-1)+boundt(i);
  end
    
  if(code==3)   %normal: traction; tangential: displacement
    F(2*i)        =F(2*i)+boundn(i);
    K(2*i-1,2*i-1)=K(2*i-1,2*i-1)*1.0e+8;
    F(2*i-1)      =boundt(i)*K(2*i-1,2*i-1);
  end
  if(code==4)   %normal: displacement; tangential: displacement 
    K(2*i,2*i)      =K(2*i,2*i)*1.0e+8; 
    F(2*i)          =boundn(i)*K(2*i,2*i);
    K(2*i-1,2*i-1)  =K(2*i-1,2*i-1)*1.0e+8;
    F(2*i-1)        =boundt(i)*K(2*i-1,2*i-1);
  end
end                                                               
