/[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 1203 by jongui, Thu Jun 21 23:17:16 2007 UTC
# Line 1  Line 1 
1    """
2    Author: Lutz Gross, l.gross@uq.edu.au
3    Author: John Ngui, john.ngui@uq.edu.au
4    """
5    
6  # Import the necessary modules.  # Import the necessary modules.
7  from esys.escript import *  from esys.escript import *
8  from esys.escript.linearPDEs import LinearPDE  from esys.escript.linearPDEs import LinearPDE
9  from esys.finley import Brick  from esys.finley import Brick
10  from esys.pyvisi import Scene, DataCollector, Velocity, Camera  from esys.pyvisi import Scene, DataCollector, Velocity, Camera
11  from esys.pyvisi.constant import *  from esys.pyvisi.constant import *
12    import os
13    
14  PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images/"  PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
15  X_SIZE = 400  X_SIZE = 400
16  Y_SIZE = 400  Y_SIZE = 400
17  JPG_RENDERER = Renderer.ONLINE_JPG  JPG_RENDERER = Renderer.ONLINE_JPG
# Line 18  xc=[0.3,0.3,1.] Line 24  xc=[0.3,0.3,1.]
24  beta=8.  beta=8.
25  T_ref=0.  T_ref=0.
26  T_0=1.  T_0=1.
27    
28  #... generate domain ...  #... generate domain ...
29  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)
30  x=mydomain.getX()  x=mydomain.getX()
# Line 26  T=T_0*exp(-beta*length(x-xc)) Line 33  T=T_0*exp(-beta*length(x-xc))
33  #... open symmetric PDE ...  #... open symmetric PDE ...
34  mypde=LinearPDE(mydomain)  mypde=LinearPDE(mydomain)
35  mypde.setSymmetryOn()  mypde.setSymmetryOn()
36    
37  #... set coefficients ...  #... set coefficients ...
38  C=Tensor4(0.,Function(mydomain))  C=Tensor4(0.,Function(mydomain))
39  for i in range(mydomain.getDim()):  for i in range(mydomain.getDim()):
# Line 38  msk=whereZero(x[0])*[1.,0.,0.] \ Line 46  msk=whereZero(x[0])*[1.,0.,0.] \
46     +whereZero(x[2])*[0.,0.,1.]     +whereZero(x[2])*[0.,0.,1.]
47  sigma0=(lam+2./3.*mu)*alpha*(T-T_ref)*kronecker(mydomain)  sigma0=(lam+2./3.*mu)*alpha*(T-T_ref)*kronecker(mydomain)
48  mypde.setValue(A=C,X=sigma0,q=msk)  mypde.setValue(A=C,X=sigma0,q=msk)
49    
50  #... solve pde ...  #... solve pde ...
51  u=mypde.getSolution()  u=mypde.getSolution()
52  #... calculate von-Misses  #... calculate von-Misses
# Line 52  s = Scene(renderer = JPG_RENDERER, x_siz Line 61  s = Scene(renderer = JPG_RENDERER, x_siz
61    
62  # Create a DataCollector reading directly from an escript object.  # Create a DataCollector reading directly from an escript object.
63  dc = DataCollector(source = Source.ESCRIPT)  dc = DataCollector(source = Source.ESCRIPT)
64  dc.setData(disp = u,stress = sigma_mises)  dc.setData(disp = u, stress = sigma_mises)
65    
66  # Create a Velocity.  # Create a Velocity.
67  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 70  v = Velocity(scene = s, data_collector =
70  v.setScaleFactor(scale_factor = 0.3)  v.setScaleFactor(scale_factor = 0.3)
71    
72  # Create a Camera.  # Create a Camera.
73  c = Camera(scene = s, data_collector = dc, viewport = Viewport.SOUTH_WEST)  c = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
74  c.isometricView()  c.isometricView()
75    
76  # Render the object.  # Render the object.
77  s.render(image_name = PYVISI_EXAMPLE_IMAGES_PATH + "heatedblock.jpg")  s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH,\
78            "heatedblock.jpg"))

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

  ViewVC Help
Powered by ViewVC 1.1.26