function [Accd, bccd] =  BC(nx,ny,nunk)
% [Accd, bccd] =  BC(nx,ny,nunk)
% This function creates matrices Accd and bccd to impose homogeneous 
% Dirichlet boudary conditions using Lagrange multipliers method.
%
%   nx,ny:  number of elements on each direction
%   nunk:   number of degrees of freedom for the velocity field
%

% Nodes on the Dirichlet boundary
nodesDy0 = [1 : nx+1]';                             % y = 0
nodesDx1 = [2*(nx+1) : nx+1 : (ny+1)*nx]';          % x = 1
nodesDx0 = [(ny-1)*(nx+1)+1 : -(nx+1) : nx+2]';     % x = 0
nodesDy1 = [(ny+1)*(nx+1) : -1 : ny*(nx+1)+1]';     % y = 1
nodesD   = [nodesDy0;nodesDx1;nodesDx0;nodesDy1];

% Imposed boundary conditions
C = [nodesD, zeros(size(nodesD))];

% Boundary conditions' matrix
nDir = size(C,1);
Accd = zeros(nDir,nunk);
Accd(:,C(:,1)) = eye(nDir);
% Boundary conditions' vector
bccd = C(:,2);

