/[escript]/trunk/doc/examples/pyvisi/poisson_with_pyvisi.py
ViewVC logotype

Contents of /trunk/doc/examples/pyvisi/poisson_with_pyvisi.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1148 - (show annotations)
Wed May 16 22:45:33 2007 UTC (13 years, 3 months ago) by jongui
File MIME type: text/x-python
File size: 1184 byte(s)
Added the updated files for pyvisi and removed some incorrect reference images.
1 # Import the necesary modules.
2 from esys.escript import *
3 from esys.escript.linearPDEs import Poisson
4 from esys.finley import Rectangle
5 from esys.pyvisi import Scene, DataCollector, Map, Camera
6 from esys.pyvisi.constant import *
7 import os
8
9 PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
10 X_SIZE = 400
11 Y_SIZE = 300
12 JPG_RENDERER = Renderer.ONLINE_JPG
13
14 # generate domain:
15 mydomain = Rectangle(l0=1.,l1=1.,n0=40, n1=20)
16 # define characteristic function of Gamma^D
17 x = mydomain.getX()
18 gammaD = whereZero(x[0])+whereZero(x[1])
19 # define PDE and get its solution u
20 mypde = Poisson(domain=mydomain)
21 mypde.setValue(f=1,q=gammaD)
22 u = mypde.getSolution()
23
24 # Create a Scene.
25 s = Scene(renderer = JPG_RENDERER, x_size = X_SIZE, y_size = Y_SIZE)
26
27 # Create a DataCollector reading directly from an escript object.
28 dc = DataCollector(source = Source.ESCRIPT)
29 dc.setData(sol = u)
30
31 # Create a Map.
32 Map(scene = s, data_collector = dc, viewport = Viewport.SOUTH_WEST,
33 lut = Lut.COLOR, cell_to_point = False, outline = True)
34
35 # Create a Camera.
36 c = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
37
38 # Render the object.
39 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, "poisson.jpg"))

  ViewVC Help
Powered by ViewVC 1.1.26