/[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 6651 - (show annotations)
Wed Feb 7 02:12:08 2018 UTC (20 months, 1 week ago) by jfenwick
File MIME type: text/x-python
File size: 2826 byte(s)
Make everyone sad by touching all the files

Copyright dates update

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26