/[escript]/temp/doc/examples/pyvisi/heatedblock_with_pyvisi.py
ViewVC logotype

Diff of /temp/doc/examples/pyvisi/heatedblock_with_pyvisi.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1147 by ksteube, Wed May 16 06:39:11 2007 UTC revision 1153 by jongui, Thu May 17 06:33:54 2007 UTC
# Line 4  from esys.escript.linearPDEs import Line Line 4  from esys.escript.linearPDEs import Line
4  from esys.finley import Brick  from esys.finley import Brick
5  from esys.pyvisi import Scene, DataCollector, Velocity, Camera  from esys.pyvisi import Scene, DataCollector, Velocity, Camera
6  from esys.pyvisi.constant import *  from esys.pyvisi.constant import *
7    import os
8    
9  PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images/"  PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
10  X_SIZE = 400  X_SIZE = 400
11  Y_SIZE = 400  Y_SIZE = 400
12  JPG_RENDERER = Renderer.ONLINE_JPG  JPG_RENDERER = Renderer.ONLINE_JPG
# Line 18  xc=[0.3,0.3,1.] Line 19  xc=[0.3,0.3,1.]
19  beta=8.  beta=8.
20  T_ref=0.  T_ref=0.
21  T_0=1.  T_0=1.
22    
23  #... generate domain ...  #... generate domain ...
24  mydomain = Brick(l0=1.,l1=1., l2=1.,n0=10, n1=10, n2=10)  mydomain = Brick(l0=1.,l1=1., l2=1.,n0=10, n1=10, n2=10)
25  x=mydomain.getX()  x=mydomain.getX()
# Line 26  T=T_0*exp(-beta*length(x-xc)) Line 28  T=T_0*exp(-beta*length(x-xc))
28  #... open symmetric PDE ...  #... open symmetric PDE ...
29  mypde=LinearPDE(mydomain)  mypde=LinearPDE(mydomain)
30  mypde.setSymmetryOn()  mypde.setSymmetryOn()
31    
32  #... set coefficients ...  #... set coefficients ...
33  C=Tensor4(0.,Function(mydomain))  C=Tensor4(0.,Function(mydomain))
34  for i in range(mydomain.getDim()):  for i in range(mydomain.getDim()):
# Line 38  msk=whereZero(x[0])*[1.,0.,0.] \ Line 41  msk=whereZero(x[0])*[1.,0.,0.] \
41     +whereZero(x[2])*[0.,0.,1.]     +whereZero(x[2])*[0.,0.,1.]
42  sigma0=(lam+2./3.*mu)*alpha*(T-T_ref)*kronecker(mydomain)  sigma0=(lam+2./3.*mu)*alpha*(T-T_ref)*kronecker(mydomain)
43  mypde.setValue(A=C,X=sigma0,q=msk)  mypde.setValue(A=C,X=sigma0,q=msk)
44    
45  #... solve pde ...  #... solve pde ...
46  u=mypde.getSolution()  u=mypde.getSolution()
47  #... calculate von-Misses  #... calculate von-Misses
# Line 52  s = Scene(renderer = JPG_RENDERER, x_siz Line 56  s = Scene(renderer = JPG_RENDERER, x_siz
56    
57  # Create a DataCollector reading directly from an escript object.  # Create a DataCollector reading directly from an escript object.
58  dc = DataCollector(source = Source.ESCRIPT)  dc = DataCollector(source = Source.ESCRIPT)
59  dc.setData(disp = u,stress = sigma_mises)  dc.setData(disp = u, stress = sigma_mises)
60    
61  # Create a Velocity.  # Create a Velocity.
62  v = Velocity(scene = s, data_collector = dc, viewport = Viewport.SOUTH_WEST,  v = Velocity(scene = s, data_collector = dc, viewport = Viewport.SOUTH_WEST,
# Line 61  v = Velocity(scene = s, data_collector = Line 65  v = Velocity(scene = s, data_collector =
65  v.setScaleFactor(scale_factor = 0.3)  v.setScaleFactor(scale_factor = 0.3)
66    
67  # Create a Camera.  # Create a Camera.
68  c = Camera(scene = s, data_collector = dc, viewport = Viewport.SOUTH_WEST)  c = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
69  c.isometricView()  c.isometricView()
70    
71  # Render the object.  # Render the object.
72  s.render(image_name = PYVISI_EXAMPLE_IMAGES_PATH + "heatedblock.jpg")  s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH,\
73            "heatedblock.jpg"))

Legend:
Removed from v.1147  
changed lines
  Added in v.1153

  ViewVC Help
Powered by ViewVC 1.1.26