1 |
# $Id:$ |
2 |
# |
3 |
# simple script to generate some test data for pyvisi |
4 |
# |
5 |
|
6 |
__copyright__=""" Copyright (c) 2006 by ACcESS MNRF |
7 |
http://www.access.edu.au |
8 |
Primary Business: Queensland, Australia""" |
9 |
__license__="""Licensed under the Open Software License version 3.0 |
10 |
http://www.opensource.org/licenses/osl-3.0.php""" |
11 |
from esys.escript import * |
12 |
from esys import finley |
13 |
# |
14 |
# |
15 |
# |
16 |
DIM=2 |
17 |
L0=3 |
18 |
L1=3. |
19 |
L2=1. |
20 |
NE0=15 |
21 |
NE1=int(NE0/L0*L1) |
22 |
NE2=int(NE0/L0*L2) |
23 |
# |
24 |
# generate domains: |
25 |
# |
26 |
if DIM == 2: |
27 |
domain=finley.Rectangle(NE0,NE1,1,l0=L0,l1=L1) |
28 |
trafo=numarray.array([[0.,1.],[-1.,0.]]) |
29 |
cen=numarray.array([L0/2.,L1/2.]) |
30 |
else: |
31 |
domain=finley.Brick(NE0,NE1,NE2,1,l0=L0,l1=L1,l2=L2) |
32 |
trafo=numarray.array([[0.,1.,0.],[-1.,0.,0.],[0.,0.,1.]]) |
33 |
cen=numarray.array([L0/2.,L1/2.,L2/2.]) |
34 |
# |
35 |
# get function spaces: |
36 |
# |
37 |
c=ContinuousFunction(domain) |
38 |
f=Function(domain) |
39 |
b=FunctionOnBoundary(domain) |
40 |
# |
41 |
# get coordinates |
42 |
# |
43 |
c_x=c.getX()-cen |
44 |
c_r=length(c_x) |
45 |
|
46 |
f_x=f.getX()-cen |
47 |
f_r=length(f_x) |
48 |
|
49 |
b_x=b.getX()-cen |
50 |
b_r=length(b_x) |
51 |
# |
52 |
# |
53 |
# |
54 |
saveVTK("interior_%dD.xml"%DIM,temperature=sin(2*c_r),temperature_cell=sin(2*f_r), \ |
55 |
velocity=matrix_mult(trafo,c_x/(c_r+1.e-15)), velocity_cell=matrix_mult(trafo,f_x/f_r)) |
56 |
saveVTK("boundary_%dD.xml"%DIM,temperature=sin(b_r),velocity=matrix_mult(trafo,b_x/(b_r+1.e-15))) |