/[escript]/trunk-mpi-branch/doc/examples/pyvisi/heatedblock_with_pyvisi.py
ViewVC logotype

Contents of /trunk-mpi-branch/doc/examples/pyvisi/heatedblock_with_pyvisi.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1306 - (show annotations)
Tue Sep 18 05:51:09 2007 UTC (11 years, 11 months ago) by ksteube
File MIME type: text/x-python
File size: 2628 byte(s)
New Copyright in each .c .h .cpp and .py file

1 #
2 # $Id$
3 #
4 #######################################################
5 #
6 # Copyright 2003-2007 by ACceSS MNRF
7 # Copyright 2007 by University of Queensland
8 #
9 # http://esscc.uq.edu.au
10 # Primary Business: Queensland, Australia
11 # Licensed under the Open Software License version 3.0
12 # http://www.opensource.org/licenses/osl-3.0.php
13 #
14 #######################################################
15 #
16
17 """
18 Author: Lutz Gross, l.gross@uq.edu.au
19 Author: John Ngui, john.ngui@uq.edu.au
20 """
21
22 # Import the necessary modules.
23 from esys.escript import *
24 from esys.escript.linearPDEs import LinearPDE
25 from esys.finley import Brick
26 from esys.pyvisi import Scene, DataCollector, Velocity, Camera
27 from esys.pyvisi.constant import *
28 import os
29
30 PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
31 X_SIZE = 400
32 Y_SIZE = 400
33 JPG_RENDERER = Renderer.ONLINE_JPG
34
35 #... set some parameters ...
36 lam=1.
37 mu=0.1
38 alpha=1.e-6
39 xc=[0.3,0.3,1.]
40 beta=8.
41 T_ref=0.
42 T_0=1.
43
44 #... generate domain ...
45 mydomain = Brick(l0=1.,l1=1., l2=1.,n0=10, n1=10, n2=10)
46 x=mydomain.getX()
47 #... set temperature ...
48 T=T_0*exp(-beta*length(x-xc))
49 #... open symmetric PDE ...
50 mypde=LinearPDE(mydomain)
51 mypde.setSymmetryOn()
52
53 #... set coefficients ...
54 C=Tensor4(0.,Function(mydomain))
55 for i in range(mydomain.getDim()):
56 for j in range(mydomain.getDim()):
57 C[i,i,j,j]+=lam
58 C[j,i,j,i]+=mu
59 C[j,i,i,j]+=mu
60 msk=whereZero(x[0])*[1.,0.,0.] \
61 +whereZero(x[1])*[0.,1.,0.] \
62 +whereZero(x[2])*[0.,0.,1.]
63 sigma0=(lam+2./3.*mu)*alpha*(T-T_ref)*kronecker(mydomain)
64 mypde.setValue(A=C,X=sigma0,q=msk)
65
66 #... solve pde ...
67 u=mypde.getSolution()
68 #... calculate von-Misses
69 g=grad(u)
70 sigma=mu*(g+transpose(g))+lam*trace(g)*kronecker(mydomain)-sigma0
71 sigma_mises=sqrt(((sigma[0,0]-sigma[1,1])**2+(sigma[1,1]-sigma[2,2])**2+ \
72 (sigma[2,2]-sigma[0,0])**2)/6. \
73 +sigma[0,1]**2 + sigma[1,2]**2 + sigma[2,0]**2)
74
75 # Create a Scene.
76 s = Scene(renderer = JPG_RENDERER, x_size = X_SIZE, y_size = Y_SIZE)
77
78 # Create a DataCollector reading directly from an escript object.
79 dc = DataCollector(source = Source.ESCRIPT)
80 dc.setData(disp = u, stress = sigma_mises)
81
82 # Create a Velocity.
83 v = Velocity(scene = s, data_collector = dc, viewport = Viewport.SOUTH_WEST,
84 arrow = Arrow.THREE_D, color_mode = ColorMode.SCALAR,
85 lut = Lut.COLOR, cell_to_point = True, outline = True)
86 v.setScaleFactor(scale_factor = 0.3)
87
88 # Create a Camera.
89 c = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
90 c.isometricView()
91
92 # Render the object.
93 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH,\
94 "heatedblock.jpg"))

  ViewVC Help
Powered by ViewVC 1.1.26