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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1100 - (hide annotations)
Tue Apr 17 05:36:24 2007 UTC (14 years, 7 months ago) by jongui
File MIME type: text/x-python
File size: 1361 byte(s)
Fixed the problem related to the use of point and cell data. Both point and cell data should now be able to work properly together. i.e. plotting a velocity field using 'vector point data' but coloring the arrows using 'scalar cell data'.
1 jongui 1100 # 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    
8     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images/"
9     X_SIZE = 400
10     Y_SIZE = 300
11     JPG_RENDERER = Renderer.ONLINE_JPG
12    
13     #... set some parameters ...
14     kappa=1.
15     omega=0.1
16     eta=10.
17     #... generate domain ...
18     mydomain = Rectangle(l0=5.,l1=1.,n0=50, n1=10)
19     #... open PDE and set coefficients ...
20     mypde=LinearPDE(mydomain)
21     mypde.setSymmetryOn()
22     n=mydomain.getNormal()
23     x=mydomain.getX()
24     mypde.setValue(A=kappa*kronecker(mydomain),D=omega,Y=omega*x[0], \
25     d=eta,y=kappa*n[0]+eta*x[0])
26     #... calculate error of the PDE solution ...
27     u=mypde.getSolution()
28     print "error is ",Lsup(u-x[0])
29    
30     # Create a Scene.
31     s = Scene(renderer = JPG_RENDERER, x_size = X_SIZE, y_size = Y_SIZE)
32    
33     # Create a DataCollector reading directly from an escript object.
34     dc = DataCollector(source = Source.ESCRIPT)
35     dc.setData(sol = u)
36    
37     # Create a Map.
38     Map(scene = s, data_collector = dc, viewport = Viewport.SOUTH_WEST,
39     lut = Lut.COLOR, cell_to_point = False, outline = True)
40    
41     # Create a Camera.
42     c = Camera(scene = s, data_collector = dc, viewport = Viewport.SOUTH_WEST)
43    
44     # Render the object.
45     s.render(image_name = PYVISI_EXAMPLE_IMAGES_PATH + "helmholtz.jpg")

  ViewVC Help
Powered by ViewVC 1.1.26