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.escript.pdetools import Projector |
13 |
from esys import finley |
14 |
# |
15 |
# |
16 |
# |
17 |
DIM=2 |
18 |
L0=3 |
19 |
L1=3. |
20 |
L2=1. |
21 |
NE0=15 |
22 |
NE1=int(NE0/L0*L1) |
23 |
NE2=int(NE0/L0*L2) |
24 |
# |
25 |
# generate domains: |
26 |
# |
27 |
for DIM in [2,3]: |
28 |
if DIM == 2: |
29 |
domain=finley.Rectangle(NE0,NE1,1,l0=L0,l1=L1) |
30 |
trafo=numarray.array([[0.,1.],[-1.,0.]]) |
31 |
cen=numarray.array([L0/2.,L1/2.]) |
32 |
else: |
33 |
domain=finley.Brick(NE0,NE1,NE2,1,l0=L0,l1=L1,l2=L2) |
34 |
trafo=numarray.array([[0.,1.,0.],[-1.,0.,0.],[0.,0.,1.]]) |
35 |
cen=numarray.array([L0/2.,L1/2.,L2/2.]) |
36 |
pp=Projector(domain) |
37 |
# |
38 |
# get function spaces: |
39 |
# |
40 |
c=ContinuousFunction(domain) |
41 |
f=Function(domain) |
42 |
b=FunctionOnBoundary(domain) |
43 |
# |
44 |
# get coordinates |
45 |
# |
46 |
c_x=c.getX()-cen |
47 |
c_r=length(c_x) |
48 |
c_t=matrix_mult(trafo,c_x/(c_r+1.e-15)) |
49 |
|
50 |
f_x=f.getX()-cen |
51 |
f_r=length(f_x) |
52 |
|
53 |
b_x=b.getX()-cen |
54 |
b_r=length(b_x) |
55 |
# |
56 |
# |
57 |
# |
58 |
saveVTK("interior_%dD.xml"%DIM,temperature=sin(2*c_r),temperature_cell=sin(2*f_r), \ |
59 |
velocity=matrix_mult(trafo,c_x/(c_r+1.e-15)), velocity_cell=matrix_mult(trafo,f_x/f_r), \ |
60 |
stress=pp(grad(c_t)), \ |
61 |
stress_cell=grad(c_t)) |
62 |
saveVTK("boundary_%dD.xml"%DIM,temperature=sin(b_r),velocity=matrix_mult(trafo,b_x/(b_r+1.e-15)), \ |
63 |
stress=grad(c_t,b)) |