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

trunk/doc/user/examples/mypoisson.py revision 565 by gross, Mon Feb 27 00:04:17 2006 UTC trunk/doc/examples/usersguide/poisson.py revision 2574 by gross, Mon Aug 3 09:09:20 2009 UTC
# Line 1  Line 1
1  # \$Id\$
2    ########################################################
3    #
4    # Copyright (c) 2003-2009 by University of Queensland
5    # Earth Systems Science Computational Center (ESSCC)
6    # http://www.uq.edu.au/esscc
7    #
8    # Primary Business: Queensland, Australia
11    #
12    ########################################################
13
15    Earth Systems Science Computational Center (ESSCC)
16    http://www.uq.edu.au/esscc
21
22  from esys.escript import *  from esys.escript import *
23  from linearPDEs import Poisson  from esys.escript.linearPDEs import Poisson
24  from esys.finley import Rectangle  from esys.finley import Rectangle
25    import numpy
26    import matplotlib
27
28    import pylab
29  # generate domain:  # generate domain:
30  mydomain = Rectangle(l0=1.,l1=1.,n0=40, n1=20)  mydomain = Rectangle(l0=1.,l1=1.,n0=40, n1=20)
31  # define characteristic function of Gamma^D  # define characteristic function of Gamma^D
35  mypde = Poisson(domain=mydomain)  mypde = Poisson(domain=mydomain)
37  u = mypde.getSolution()  u = mypde.getSolution()
38  # write u to an external file
39  saveVTK("u.xml",sol=u)  # interpolate u to a matplotlib grid:
40    x_grid = numpy.linspace(0.,1.,50)
41    y_grid = numpy.linspace(0.,1.,50)
42    z_grid = matplotlib.mlab.griddata(x=mydomain.getX()[0].toListOfTuples(),y=mydomain.getX()[1].toListOfTuples(),
43                                      z=interpolate(u,mydomain.getX().getFunctionSpace()).toListOfTuples(),
44                                      xi=x_grid,yi=y_grid )
45    # interpolate u to a rectangular grid:
46    matplotlib.pyplot.contourf(x_grid, y_grid, z_grid, 5)
47    matplotlib.pyplot.show()
48    matplotlib.pyplot.savefig("u.png")
49

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