// generation du maillage Q1 a 4 noeuds
// lx, ly dimension du rectangle
// nex,ney nonbre de quad suivant x et y
// CONNEC mat de conectivite
// COOR mat des coordonnees des noeuds

function [CONNEC,COOR,Nelt,Nno,Npt] = maillage_2D_Q1(lx,ly,nex,ney)
//
//
hx=lx/nex;
hy=ly/ney;

Npt=(nex+1)*(ney+1);
Nelt = nex*ney;
Nno = 4;
//
// coordonnees des noeuds
//---------------------
//
COOR = zeros(Npt,2);
for  iy = 1:(ney+1);
  for ix = 1:(nex+1)
    INN=(iy-1)*(nex+1)+ix
    COOR(INN,1)= (ix-1)*hx
    COOR(INN,2)= (iy-1)*hy
  end;
end;  
//
// connectivite
//---------------------
//
CONNEC=zeros(Nelt,Nno);
it = nex+1;
for iy = 1:ney
    for ix = 1:nex
      inel=(iy-1)*nex+ix;
      i1 = (iy-1)*it + ix;
      i2 = i1 + 1;
      i3 = i2 + it;      
      i4 = i3 - 1;

      CONNEC(inel,1)=i1;
      CONNEC(inel,2)=i2;
      CONNEC(inel,3)=i3;
      CONNEC(inel,4)=i4;

   end
end

endfunction

