# Diff of /trunk/doc/examples/usersguide/poisson.py

revision 2574 by gross, Mon Aug 3 09:09:20 2009 UTC revision 2578 by jfenwick, Tue Aug 4 04:05:36 2009 UTC
22  from esys.escript import *  from esys.escript import *
23  from esys.escript.linearPDEs import Poisson  from esys.escript.linearPDEs import Poisson
24  from esys.finley import Rectangle  from esys.finley import Rectangle
import numpy
import matplotlib

import pylab
25  # generate domain:  # generate domain:
26  mydomain = Rectangle(l0=1.,l1=1.,n0=40, n1=20)  mydomain = Rectangle(l0=1.,l1=1.,n0=40, n1=20)
27  # define characteristic function of Gamma^D  # define characteristic function of Gamma^D
31  mypde = Poisson(domain=mydomain)  mypde = Poisson(domain=mydomain)
33  u = mypde.getSolution()  u = mypde.getSolution()
34    # write u to an external file
35  # interpolate u to a matplotlib grid:  saveVTK("u.vtu",sol=u)
x_grid = numpy.linspace(0.,1.,50)
y_grid = numpy.linspace(0.,1.,50)
z_grid = matplotlib.mlab.griddata(x=mydomain.getX()[0].toListOfTuples(),y=mydomain.getX()[1].toListOfTuples(),
z=interpolate(u,mydomain.getX().getFunctionSpace()).toListOfTuples(),
xi=x_grid,yi=y_grid )
# interpolate u to a rectangular grid:
matplotlib.pyplot.contourf(x_grid, y_grid, z_grid, 5)
matplotlib.pyplot.show()
matplotlib.pyplot.savefig("u.png")
36

Legend:
 Removed from v.2574 changed lines Added in v.2578