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

Contents of /trunk/doc/examples/pyvisi/heatedblock_with_pyvisi.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1811 - (show annotations)
Thu Sep 25 23:11:13 2008 UTC (10 years, 3 months ago) by ksteube
File MIME type: text/x-python
File size: 2965 byte(s)
Copyright updated in all files

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

  ViewVC Help
Powered by ViewVC 1.1.26