/[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 4657 - (show annotations)
Thu Feb 6 06:12:20 2014 UTC (5 years, 4 months ago) by jfenwick
File MIME type: text/x-python
File size: 2789 byte(s)
I changed some files.
Updated copyright notices, added GeoComp.



1
2 ##############################################################################
3 #
4 # Copyright (c) 2003-2014 by University of Queensland
5 # http://www.uq.edu.au
6 #
7 # Primary Business: Queensland, Australia
8 # Licensed under the Open Software License version 3.0
9 # http://www.opensource.org/licenses/osl-3.0.php
10 #
11 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 # Development 2012-2013 by School of Earth Sciences
13 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 #
15 ##############################################################################
16
17 __copyright__="""Copyright (c) 2003-2014 by University of Queensland
18 http://www.uq.edu.au
19 Primary Business: Queensland, Australia"""
20 __license__="""Licensed under the Open Software License version 3.0
21 http://www.opensource.org/licenses/osl-3.0.php"""
22 __url__="https://launchpad.net/escript-finley"
23
24 """
25 Test writing data object to various file formats
26
27 by Lutz Gross, ACcESS, University of Queensland, Australia, 2005.
28 """
29
30 from esys.escript import *
31 from esys.finley import Rectangle,Brick
32
33
34 ne=1
35 work_dir="."
36
37 def writeInFormat(fs,format,filetype):
38 d=fs.getDim()
39 x=length(fs.getX())
40 # generate scalar data:
41 filename="%s/scalar.%s.%s"%(work_dir,filetype,format)
42 print("file ",filename," is generated")
43 try:
44 eval("x.save%s(\"%s\")"%(format.upper(),filename))
45 except Exception as msg:
46 print("%% failed because of ",msg)
47 # generate vector data:
48 print("file ",filename," is generated")
49 filename="%s/vector.%s.%s"%(work_dir,filetype,format)
50 if d==2:
51 m=[1.,2.]
52 else:
53 m=[1.,2.,3.]
54 try:
55 eval("(x*m).save%s(\"%s\")"%(format.upper(),filename))
56 except Exception as msg:
57 print("%% failed because of ",msg)
58 # generate tensor data:
59 filename="%s/tensor.%s.%s"%(work_dir,filetype,format)
60 print("file ",filename," is generated")
61 if d==2:
62 m=[[11.,12.],[21.,22.]]
63 else:
64 m=[[11.,12.,13.],[21.,22.,23.],[31.,32.,33.]]
65 try:
66 eval("(x*m).save%s(\"%s\")"%(format.upper(),filename))
67 except Exception as msg:
68 print("%% failed because of ",msg)
69
70 for format in ["vtk","dx"]:
71 for d in [2,3]:
72 for order in [1,2]:
73 if (d == 2):
74 mesh = Rectangle(ne, ne,order,l0=order*ne,l1=order*ne)
75 elif (d == 3):
76 mesh = Brick(ne,ne,ne,order,l0=order*ne,l1=order*ne,l2=order*ne)
77 for fs in ["ContinuousFunction","Function","FunctionOnBoundary","Solution","ReducedSolution","FunctionOnContact"]:
78 filetype="%s.o%d.d%d"%(fs,order,d)
79 writeInFormat(eval("%s(mesh)"%fs),format,filetype)
80

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26