//  trace la fonction U
function [u,x,y]=trace_u_2D(U,no)
//
    global F1 F2 F3 F4 Ca Cb
//
   global CONNEC COOR NUMER ADRESS UC Nelt Nno Npt NI;
   global XG PG Ng
//  calcule le maillage initial
//
   x0 = min(COOR(:,1)); x1 = max(COOR(:,1));
   y0 = min(COOR(:,2)); y1 = max(COOR(:,2));
   
   Nx = 20; Ny = 20;
   Dx = (x1-x0)/(Nx-1); Dy = (y1-y0)/(Ny-1);
   x = x0 + (0:Nx-1)*Dx; 
   y = y0 + (0:Ny-1)*Dy;

//  on evalue la fonction au points du maillage
//
   [Nel,Nno]=size(CONNEC);
   u = zeros(Nx,Ny);
   test = zeros(Nel,4);
   for i = 1:Nx
      xi = x(i);
      for j = 1:Ny
        yj = y(j)
        val = [1; xi; yj; xi*yj ]; 
// On cherche a quel element appartient le point xi, yj
        test(:,1) = yj-(Ca(:,1)*xi + Cb(:,1)) >= 0 ;
        test(:,2) = yj-(Ca(:,2)*xi + Cb(:,2)) <= 0 ;
        test(:,3) = xi-(Ca(:,3)*yj + Cb(:,3)) <= 0 ;
        test(:,4) = xi-(Ca(:,4)*yj + Cb(:,4)) >= 0 ;
        iel = 1;
        while ~and(test(iel,:))
           iel = iel + 1;
        end;
       Uno = U(ADRESS(iel,1:4),1);
       u(i,j) = Uno(1)* F1(iel,:)*val + Uno(2)*F2(iel,:)*val + Uno(3)*F3(iel,:)*val + Uno(4)*F4(iel,:)*val
      end;
   end;
  
    
    xbasc(no);
    xset("window",no);
    rect = [x0,x1,y0,y1,0,max(u)]; 

    contour2d(x,y,u,10)

endfunction
         
      
