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

Annotation of /trunk/doc/examples/pyvisi/diffusion_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: 1664 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 modules.
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 = 400
11     JPG_RENDERER = Renderer.ONLINE_JPG
12    
13     #... set some parameters ...
14     xc=[0.02,0.002]
15     r=0.001
16     qc=50.e6
17     Tref=0.
18     rhocp=2.6e6
19     eta=75.
20     kappa=240.
21     tend=5.
22     # ... time, time step size and counter ...
23     t=0
24     h=0.1
25     i=0
26     #... generate domain ...
27     mydomain = Rectangle(l0=0.05,l1=0.01,n0=250, n1=50)
28     #... open PDE ...
29     mypde=LinearPDE(mydomain)
30     mypde.setSymmetryOn()
31     mypde.setValue(A=kappa*kronecker(mydomain),D=rhocp/h,d=eta,y=eta*Tref)
32     # ... set heat source: ....
33     x=mydomain.getX()
34     qH=qc*whereNegative(length(x-xc)-r)
35     # ... set initial temperature ....
36     T=Tref
37    
38     # Create a Scene.
39     s = Scene(renderer = JPG_RENDERER, x_size = X_SIZE, y_size = Y_SIZE)
40     # Create a DataCollector reading directly from escript objects.
41     dc = DataCollector(source = Source.ESCRIPT)
42    
43     # ... start iteration:
44     while t<tend:
45     i+=1
46     t+=h
47     print "time step :",t
48     mypde.setValue(Y=qH+rhocp/h*T)
49     T=mypde.getSolution()
50    
51     dc.setData(temp = T)
52     # Create a Map.
53     Map(scene = s, data_collector = dc,
54     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
55     cell_to_point = False, outline = True)
56    
57     # Create a Camera.
58     c= Camera(scene = s, data_collector = dc,
59     viewport = Viewport.SOUTH_WEST)
60    
61     # Render the object.
62     s.render(image_name = PYVISI_EXAMPLE_IMAGES_PATH +
63     "diffusion_%02d.jpg" % i)
64    

  ViewVC Help
Powered by ViewVC 1.1.26