/[escript]/trunk/doc/examples/usersguide/poisson.py
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2549 by jfenwick, Mon Jul 20 06:43:47 2009 UTC revision 2574 by gross, Mon Aug 3 09:09:20 2009 UTC
# Line 22  __url__="https://launchpad.net/escript-f Line 22  __url__="https://launchpad.net/escript-f
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
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
# Line 31  gammaD = whereZero(x[0])+whereZero(x[1]) Line 35  gammaD = whereZero(x[0])+whereZero(x[1])
35  mypde = Poisson(domain=mydomain)  mypde = Poisson(domain=mydomain)
36  mypde.setValue(f=1,q=gammaD)  mypde.setValue(f=1,q=gammaD)
37  u = mypde.getSolution()  u = mypde.getSolution()
38  # write u to an external file  
39  saveVTK("u.vtu",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.2549  
changed lines
  Added in v.2574

  ViewVC Help
Powered by ViewVC 1.1.26