function drawU(xl,xt,xpl,xpt,xyl,xyr,xyt,xcl,xcr,xct,Ishape,p,h,X,Y,U)

% drawU(xl,xt,xpl,xpt,xyl,xyr,xyt,xcl,xcr,xct,p,h,X,Y,U)
%         Draws both the geometry and the magnetic field lines
%         for a given design p.


shapeDisplacement = designMap(Ishape,p);
shape = shapeDisplacement;
shape(1,:) = shape(1,:) + xyr;
shape(2,:) = 0:h:xyt;

figure
hold on;

plot([0,0],[0,xt]);
plot([0,xl],[xt,xt]);
plot([xl,xl],[xt,0]);
plot([xl,0],[0,0]);
plot([0,xpl],[xpt,xpt]);
plot([xpl,xpl],[xpt,0]);

for i=1:max(size(shape))-1
    plot([shape(1,i),shape(1,i+1)],[shape(2,i),shape(2,i+1)]);
end

plot([xyr,xyl],[xyt,xyt]);
plot([xyl,xyl],[xyt,0]);
plot([xcr,xcr],[xyt,xct]);
plot([xcr,xcl],[xct,xct]);
plot([xcl,xcl],[xct,xyt]);

contour(X,Y,U,30);

hold off;
