Commit 7110a7f4 by Romain Hild

### extend stencil, random mesh up to h/3, show picture

parent a2b69c9a
 ... ... @@ -21,8 +21,8 @@ def test_function(x,y): def random_mesh(x,h): theta=ran.uniform(-1.0,1.0) x[0] = x[0] +theta*h[0]/5 x[1] = x[1] +theta*h[1]/5 x[0] = x[0] +theta*h[0]/3 x[1] = x[1] +theta*h[1]/3 return x def id_mesh(x,h): ... ... @@ -69,6 +69,7 @@ class mesh: def create_stencil(self): self.stencil=[1,-1,self.Nx,-self.Nx,self.Nx-1,self.Nx+1,-self.Nx-1,-self.Nx+1] self.stencil.extend([2,self.Nx+2,2*self.Nx+2,2*self.Nx+1,2*self.Nx,2*self.Nx-1,2*self.Nx-2,self.Nx-2,-2,-self.Nx-2,-2*self.Nx-2,-2*self.Nx-1,-2*self.Nx,-2*self.Nx,-2*self.Nx+1,-2*self.Nx+2]) class projection: ... ... @@ -195,7 +196,6 @@ class Picture: [qx,qy]=M.local_nodes(ic) res = self.test_point(qx,qy,x,y) k =k +1 return ic def construct_picture(self, M, Pi): ... ... @@ -209,7 +209,7 @@ class Picture: t0=time.clock() M = mesh(1.0,1.0,200,200) M = mesh(1.0,1.0,500,500) M.create(random_mesh) t1=time.clock() P = projection(2) ... ... @@ -224,5 +224,7 @@ Pic.construct_picture(M,Pi) print "coucou " + str(Pic.picture) t3=time.clock() print " mesh " + str(t1-t0) + " projection " + str(t2-t1) + " image " + str(t3-t2) # x = np.linspace(M.Lx/(Pic.raf*M.Nx+1), Pic.raf*M.Nx* M.Lx/(Pic.raf*M.Nx+1), Pic.raf*M.Nx) # y = np.linspace(M.Ly/(Pic.raf*M.Ny+1), Pic.raf*M.Ny* M.Ly/(Pic.raf*M.Ny+1), Pic.raf*M.Ny) x = np.linspace(M.Lx/(Pic.raf*M.Nx+1), Pic.raf*M.Nx* M.Lx/(Pic.raf*M.Nx+1), Pic.raf*M.Nx) y = np.linspace(M.Ly/(Pic.raf*M.Ny+1), Pic.raf*M.Ny* M.Ly/(Pic.raf*M.Ny+1), Pic.raf*M.Ny) plt.imshow(Pic.picture) plt.show()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!