// generation du maillage a 9 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_Q2(lx,ly,nex,ney)
//

hx=lx/nex;
hy=ly/ney;

Npt=(2*nex+1)*(2*ney+1);
Nelt = nex*ney;
Nno = 9;

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

      CONNEC(inel,1)=i1;
      CONNEC(inel,2)=i2;
      CONNEC(inel,3)=i3;
      CONNEC(inel,4)=i4;
      CONNEC(inel,5)=i5;
      CONNEC(inel,6)=i6;     
      CONNEC(inel,7)=i7;
      CONNEC(inel,8)=i8;
      CONNEC(inel,9)=i9;
   end
end

endfunction

