/[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 1148 - (show annotations)
Wed May 16 22:45:33 2007 UTC (13 years, 4 months ago) by jongui
File MIME type: text/x-python
File size: 1363 byte(s)
Added the updated files for pyvisi and removed some incorrect reference images.
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 #... open PDE and set coefficients ...
21 mypde=LinearPDE(mydomain)
22 mypde.setSymmetryOn()
23 n=mydomain.getNormal()
24 x=mydomain.getX()
25 mypde.setValue(A=kappa*kronecker(mydomain),D=omega,Y=omega*x[0], \
26 d=eta,y=kappa*n[0]+eta*x[0])
27 #... calculate error of the PDE solution ...
28 u=mypde.getSolution()
29 print "error is ",Lsup(u-x[0])
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
46 # Render the object.
47 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, "helmholtz.jpg"))

  ViewVC Help
Powered by ViewVC 1.1.26