/[escript]/trunk/finley/test/python/OutTest.py
ViewVC logotype

Contents of /trunk/finley/test/python/OutTest.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 617 - (show annotations)
Wed Mar 22 02:58:17 2006 UTC (13 years, 8 months ago) by elspeth
File MIME type: text/x-python
File size: 2194 byte(s)
More copyright.

1 # $Id$
2 """
3 Test writing data object to various file formats
4
5 by Lutz Gross, ACcESS, University of Queensland, Australia, 2005.
6 """
7
8 __copyright__=""" Copyright (c) 2006 by ACcESS MNRF
9 http://www.access.edu.au
10 Primary Business: Queensland, Australia"""
11 __license__="""Licensed under the Open Software License version 3.0
12 http://www.opensource.org/licenses/osl-3.0.php"""
13 from esys.escript import *
14 from esys.finley import Rectangle,Brick
15
16
17 ne=1
18 work_dir="."
19
20 def writeInFormat(fs,format,filetype):
21 d=fs.getDim()
22 x=length(fs.getX())
23 # generate scalar data:
24 filename="%s/scalar.%s.%s"%(work_dir,filetype,format)
25 print "file ",filename," is generated"
26 try:
27 eval("x.save%s(\"%s\")"%(format.upper(),filename))
28 except StandardError, msg:
29 print "%% failed because of ",msg
30 # generate vector data:
31 print "file ",filename," is generated"
32 filename="%s/vector.%s.%s"%(work_dir,filetype,format)
33 if d==2:
34 m=[1.,2.]
35 else:
36 m=[1.,2.,3.]
37 try:
38 eval("(x*m).save%s(\"%s\")"%(format.upper(),filename))
39 except StandardError, msg:
40 print "%% failed because of ",msg
41 # generate tensor data:
42 filename="%s/tensor.%s.%s"%(work_dir,filetype,format)
43 print "file ",filename," is generated"
44 if d==2:
45 m=[[11.,12.],[21.,22.]]
46 else:
47 m=[[11.,12.,13.],[21.,22.,23.],[31.,32.,33.]]
48 try:
49 eval("(x*m).save%s(\"%s\")"%(format.upper(),filename))
50 except StandardError, msg:
51 print "%% failed because of ",msg
52
53 for format in ["vtk","dx"]:
54 for d in [2,3]:
55 for order in [1,2]:
56 if (d == 2):
57 mesh = Rectangle(ne, ne,order,l0=order*ne,l1=order*ne)
58 elif (d == 3):
59 mesh = Brick(ne,ne,ne,order,l0=order*ne,l1=order*ne,l2=order*ne)
60 for fs in ["ContinuousFunction","Function","FunctionOnBoundary","Solution","ReducedSolution","FunctionOnContact"]:
61 filetype="%s.o%d.d%d"%(fs,order,d)
62 writeInFormat(eval("%s(mesh)"%fs),format,filetype)
63

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26