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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 150 - (show annotations)
Thu Sep 15 03:44:45 2005 UTC (14 years, 2 months ago) by jgs
File MIME type: text/x-python
File size: 1906 byte(s)
Merge of development branch dev-02 back to main trunk on 2005-09-15

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 from esys.escript import *
9 from esys.finley import Rectangle,Brick
10
11
12 ne=1
13 work_dir="."
14
15 def writeInFormat(fs,format,filetype):
16 d=fs.getDim()
17 x=length(fs.getX())
18 # generate scalar data:
19 filename="%s/scalar.%s.%s"%(work_dir,filetype,format)
20 print "file ",filename," is generated"
21 try:
22 eval("x.save%s(\"%s\")"%(format.upper(),filename))
23 except StandardError, msg:
24 print "%% failed because of ",msg
25 # generate vector data:
26 print "file ",filename," is generated"
27 filename="%s/vector.%s.%s"%(work_dir,filetype,format)
28 if d==2:
29 m=[1.,2.]
30 else:
31 m=[1.,2.,3.]
32 try:
33 eval("(x*m).save%s(\"%s\")"%(format.upper(),filename))
34 except StandardError, msg:
35 print "%% failed because of ",msg
36 # generate tensor data:
37 filename="%s/tensor.%s.%s"%(work_dir,filetype,format)
38 print "file ",filename," is generated"
39 if d==2:
40 m=[[11.,12.],[21.,22.]]
41 else:
42 m=[[11.,12.,13.],[21.,22.,23.],[31.,32.,33.]]
43 try:
44 eval("(x*m).save%s(\"%s\")"%(format.upper(),filename))
45 except StandardError, msg:
46 print "%% failed because of ",msg
47
48 for format in ["vtk","dx"]:
49 for d in [2,3]:
50 for order in [1,2]:
51 if (d == 2):
52 mesh = Rectangle(ne, ne,order,l0=order*ne,l1=order*ne)
53 elif (d == 3):
54 mesh = Brick(ne,ne,ne,order,l0=order*ne,l1=order*ne,l2=order*ne)
55 for fs in ["ContinuousFunction","Function","FunctionOnBoundary","Solution","ReducedSolution","FunctionOnContact"]:
56 filetype="%s.o%d.d%d"%(fs,order,d)
57 writeInFormat(eval("%s(mesh)"%fs),format,filetype)
58

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26