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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1153 - (show annotations)
Thu May 17 06:33:54 2007 UTC (12 years, 8 months ago) by jongui
File MIME type: text/x-python
File size: 1332 byte(s)
Made some minor modifications and fixed minor bugs. Most tests appear to pass on the Altix although there are two tests which occasionally throw an error related to memory corruption.
1 # Import the necessary moduels.
2 from esys.escript import *
3 from esys.escript.linearPDEs import LinearPDE
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 #... set some parameters ...
15 kappa=1.
16 omega=0.1
17 eta=10.
18 #... generate domain ...
19 mydomain = Rectangle(l0=5.,l1=1.,n0=50, n1=10)
20
21 #... open PDE and set coefficients ...
22 mypde=LinearPDE(mydomain)
23 mypde.setSymmetryOn()
24 n=mydomain.getNormal()
25 x=mydomain.getX()
26 mypde.setValue(A=kappa*kronecker(mydomain),D=omega,Y=omega*x[0], \
27 d=eta,y=kappa*n[0]+eta*x[0])
28 #... calculate error of the PDE solution ...
29 u=mypde.getSolution()
30
31 # Create a Scene.
32 s = Scene(renderer = JPG_RENDERER, x_size = X_SIZE, y_size = Y_SIZE)
33
34 # Create a DataCollector reading directly from an escript object.
35 dc = DataCollector(source = Source.ESCRIPT)
36 dc.setData(sol = u)
37
38 # Create a Map.
39 Map(scene = s, data_collector = dc, viewport = Viewport.SOUTH_WEST,
40 lut = Lut.COLOR, cell_to_point = False, outline = True)
41
42 # Create a Camera.
43 c = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
44
45 # Render the object.
46 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, "helmholtz.jpg"))

  ViewVC Help
Powered by ViewVC 1.1.26