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

Annotation of /trunk/dudley/test/python/OutTest.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3774 - (hide annotations)
Wed Jan 18 06:29:34 2012 UTC (7 years, 10 months ago) by jfenwick
File MIME type: text/x-python
File size: 2659 byte(s)
dudley, pasowrap, pycad

1 ksteube 1809
2     ########################################################
3 ksteube 1312 #
4 jfenwick 2881 # Copyright (c) 2003-2010 by University of Queensland
5 ksteube 1809 # Earth Systems Science Computational Center (ESSCC)
6     # http://www.uq.edu.au/esscc
7 ksteube 1312 #
8 ksteube 1809 # 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 ksteube 1312 #
12 ksteube 1809 ########################################################
13 ksteube 1312
14 jfenwick 2881 __copyright__="""Copyright (c) 2003-2010 by University of Queensland
15 ksteube 1809 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 jfenwick 2344 __url__="https://launchpad.net/escript-finley"
21 ksteube 1809
22 jgs 115 """
23     Test writing data object to various file formats
24    
25     by Lutz Gross, ACcESS, University of Queensland, Australia, 2005.
26     """
27    
28 jgs 149 from esys.escript import *
29 jfenwick 3087 from esys.dudley import Rectangle,Brick
30 jgs 115
31    
32 jgs 147 ne=1
33 jgs 150 work_dir="."
34 jgs 115
35     def writeInFormat(fs,format,filetype):
36     d=fs.getDim()
37     x=length(fs.getX())
38     # generate scalar data:
39     filename="%s/scalar.%s.%s"%(work_dir,filetype,format)
40 jfenwick 3774 print("file ",filename," is generated")
41 jgs 115 try:
42 jgs 150 eval("x.save%s(\"%s\")"%(format.upper(),filename))
43 jfenwick 3774 except Exception as msg:
44     print("%% failed because of ",msg)
45 jgs 115 # generate vector data:
46 jfenwick 3774 print("file ",filename," is generated")
47 jgs 115 filename="%s/vector.%s.%s"%(work_dir,filetype,format)
48     if d==2:
49     m=[1.,2.]
50     else:
51     m=[1.,2.,3.]
52     try:
53 jgs 150 eval("(x*m).save%s(\"%s\")"%(format.upper(),filename))
54 jfenwick 3774 except Exception as msg:
55     print("%% failed because of ",msg)
56 jgs 115 # generate tensor data:
57     filename="%s/tensor.%s.%s"%(work_dir,filetype,format)
58 jfenwick 3774 print("file ",filename," is generated")
59 jgs 115 if d==2:
60     m=[[11.,12.],[21.,22.]]
61     else:
62     m=[[11.,12.,13.],[21.,22.,23.],[31.,32.,33.]]
63     try:
64 jgs 150 eval("(x*m).save%s(\"%s\")"%(format.upper(),filename))
65 jfenwick 3774 except Exception as msg:
66     print("%% failed because of ",msg)
67 jgs 115
68 jgs 150 for format in ["vtk","dx"]:
69 jgs 115 for d in [2,3]:
70     for order in [1,2]:
71     if (d == 2):
72     mesh = Rectangle(ne, ne,order,l0=order*ne,l1=order*ne)
73     elif (d == 3):
74     mesh = Brick(ne,ne,ne,order,l0=order*ne,l1=order*ne,l2=order*ne)
75 jgs 150 for fs in ["ContinuousFunction","Function","FunctionOnBoundary","Solution","ReducedSolution","FunctionOnContact"]:
76 jgs 115 filetype="%s.o%d.d%d"%(fs,order,d)
77     writeInFormat(eval("%s(mesh)"%fs),format,filetype)
78    

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26