def crosssection(x, NP, k, N, pN): points2 = pu.uniformsquarepoints(NP) points3 = np.hstack((np.ones((NP*NP,1)) * x, points2)) meshevents = lambda m: pps.stokescubemesh(N, m) u, p = pps.stokespressure(k,meshevents,{pps.inputbdytag:pps.pfn(0), pps.outputbdytag:pps.pfn(1.0)}, points3, False, N==1) ur, _ = pep.poisson(pN, points2) pp = points2.reshape(NP,NP,2).transpose(2,0,1) mpl.figure(facecolor='white') c = mpl.contour(pp[0], pp[1], u[:,0].reshape(NP,NP), fontsize=14) mpl.clabel(c, inline=1, fontsize = 14) mpl.figure(facecolor='white') c = mpl.contourf(pp[0], pp[1], ur.reshape(NP,NP) - u[:,0].reshape(NP,NP), fontsize=14, colors = None, cmap=mpl.get_cmap('Greys')) mpl.colorbar(c, shrink=0.8) # mpl.clabel(c, inline=1, fontsize = 14) mpl.figure(facecolor='white') c = mpl.contourf(pp[0], pp[1], p.reshape(NP,NP), fontsize=14, colors = None, cmap=mpl.get_cmap('Greys')) mpl.colorbar(c, shrink=0.8)
e[n] = math.sqrt(sum((Nv - nv)**2 * w)) / Nvl2 print e p = mp.semilogy(np.arange(N)*2, e) mp.xlabel("polynomial degree", fontsize=14) mp.ylabel("relative error", fontsize=14) if __name__ == '__main__': mp.rcParams['font.size'] = 14 mp.figure(facecolor='white') convergence(30) # N = 20 NP = 50 # points = np.vstack((np.arange(0,1,0.1),)*2).transpose() + np.array([[0.0001,0.2]]) points = pu.uniformsquarepoints(NP) print points u, ddu = poisson(N, points) mp.figure(facecolor='white') c = mp.contour(points[:,0].reshape(NP,NP), points[:,1].reshape(NP,NP), u.reshape(NP,NP), fontsize=14) mp.clabel(c, inline=1, fontsize = 14) pylab.show() # emm.figure(bgcolor=(1,1,1), fgcolor=(0,0,0)) # s = emm.surf(points[:,0].reshape(NP,NP), points[:,1].reshape(NP,NP), u.reshape(NP,NP), warp_scale='auto') # emm.axes(s) # emm.colorbar() ## emm.outline() # emm.figure() # emm.surf(points[:,0].reshape(NP,NP), points[:,1].reshape(NP,NP), ddu.reshape(NP,NP), warp_scale='auto') #