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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1771 - (hide annotations)
Mon Sep 8 22:47:55 2008 UTC (10 years, 7 months ago) by ksteube
Original Path: trunk/finley/test/python/run_inputOutput.py
File MIME type: text/x-python
File size: 5084 byte(s)
Removed failing test until we fix a bug.
Fixed several compiler warnings.

1 ksteube 1754 #
2     # $Id$
3     #
4     #######################################################
5     #
6     # Copyright 2003-2007 by ACceSS MNRF
7     # Copyright 2007 by University of Queensland
8     #
9     # http://esscc.uq.edu.au
10     # Primary Business: Queensland, Australia
11     # Licensed under the Open Software License version 3.0
12     # http://www.opensource.org/licenses/osl-3.0.php
13     #
14     #######################################################
15     #
16    
17     """
18     Test suite for input and output of meshes and data objects
19    
20     @remark:
21    
22     @var __author__: name of author
23     @var __licence__: licence agreement
24     @var __url__: url entry point on documentation
25     @var __version__: version
26     @var __date__: date of the version
27     """
28    
29     __copyright__=""" Copyright (c) 2006 by ACcESS MNRF
30     http://www.access.edu.au
31     Primary Business: Queensland, Australia"""
32     __license__="""Licensed under the Open Software License version 3.0
33     http://www.opensource.org/licenses/osl-3.0.php"""
34     __author__="Ken Steube, k.steube@uq.edu.au"
35     __url__="http://www.iservo.edu.au/esys/escript"
36     __version__="$Revision: 859 $"
37     __date__="$Date: 2006-09-26 12:19:18 +1000 (Tue, 26 Sep 2006) $"
38    
39     import unittest, sys
40    
41     from esys.escript import *
42     from esys.finley import Rectangle, Brick, LoadMesh, ReadMesh, ReadMeshMPI
43    
44     try:
45     FINLEY_TEST_DATA=os.environ['FINLEY_TEST_DATA']
46     except KeyError:
47     FINLEY_TEST_DATA='.'
48    
49     FINLEY_TEST_MESH_PATH=FINLEY_TEST_DATA+"/data_meshes/"
50    
51     SOLVER_TOL=1.e-8
52     REL_TOL=1.e-6
53    
54     def domainsEqual(m1, m2, nft=10):
55     if m1.getDim() != m2.getDim():
56     print "domainsEqual: different dimensions %d, %d" % (m1.getDim(), m2.getDim())
57     return False
58     if m1.getNumDataPointsGlobal() != m2.getNumDataPointsGlobal():
59     print "domainsEqual: different num data points: %d, %d" % (m1.getNumDataPointsGlobal(), m2.getNumDataPointsGlobal())
60     return False
61     for tagName in m1.showTagNames().split(", "):
62     if not m2.isValidTagName(tagName):
63     print "domainsEqual: m1 has a tag '%s' not present in m2" % tagName
64     return False
65     for tagName in m2.showTagNames().split(", "):
66     if not m1.isValidTagName(tagName):
67     print "domainsEqual: m2 has a tag '%s' not present in m1" % tagName
68     return False
69     if m1.getTag(tagName) != m2.getTag(tagName):
70     print "domainsEqual: values of tag '%s' differ" % tagName
71     return False
72     for fs in ["Solution", "ReducedSolution", "Function", "ReducedFunction", "FunctionOnBoundary", "ReducedFunctionOnBoundary", "ContinuousFunction", "ReducedContinuousFunction"]:
73     fs1 = eval("%s(m1)" % fs)
74     fs2 = eval("%s(m2)" % fs)
75     x1 = fs1.getX()
76     x2 = fs2.getX()
77     for n in range(1, nft+1):
78     integ1 = integrate(sin(n*x1))
79     integ2 = integrate(sin(n*x2))
80     if Lsup(abs(integ1-integ2)) > REL_TOL:
81     print "domainsEqual: integrals for n=%d differ" % n
82     return False
83     return True
84    
85     class InputOutput(unittest.TestCase):
86    
87     # Does optimize=True change Rectangle for order=1?
88     def test_Rectangle_optimize_order1(self):
89     mydomain1 = Rectangle(n0=7, n1=11, order=1, l0=1., l1=1., optimize=False)
90     mydomain2 = Rectangle(n0=7, n1=11, order=1, l0=1., l1=1., optimize=True)
91     self.failUnless(domainsEqual(mydomain1, mydomain2), "Domains differ")
92    
93     # Does optimize=True change Rectangle for order=2?
94     def test_Rectangle_optimize_order2(self):
95     mydomain1 = Rectangle(n0=7, n1=11, order=2, l0=1., l1=1., optimize=False)
96     mydomain2 = Rectangle(n0=7, n1=11, order=2, l0=1., l1=1., optimize=True)
97     self.failUnless(domainsEqual(mydomain1, mydomain2), "Domains differ")
98    
99     # Does optimize=True change Brick for order=1?
100     def test_Brick_optimize_order1(self):
101     mydomain1 = Brick(n0=7, n1=11, n2=5, order=1, l0=1., l1=1., l2=1., optimize=False)
102     mydomain2 = Brick(n0=7, n1=11, n2=5, order=1, l0=1., l1=1., l2=1., optimize=True)
103     self.failUnless(domainsEqual(mydomain1, mydomain2), "Domains differ")
104    
105     # Does optimize=True change Brick for order=2?
106     def test_Brick_optimize_order2(self):
107     mydomain1 = Brick(n0=7, n1=11, n2=5, order=2, l0=1., l1=1., l2=1., optimize=False)
108     mydomain2 = Brick(n0=7, n1=11, n2=5, order=2, l0=1., l1=1., l2=1., optimize=True)
109     self.failUnless(domainsEqual(mydomain1, mydomain2), "Domains differ")
110    
111 ksteube 1755 def test_mesh_dump_to_NetCDF_rectangle(self):
112 ksteube 1754 if loadIsConfigured():
113 ksteube 1755 mydomain1 = Rectangle(n0=17, n1=111, order=1, l0=1., l1=1., optimize=False)
114 ksteube 1754 mydomain1.dump("tt.mesh.nc")
115     mydomain2=LoadMesh("tt.mesh.nc")
116     self.failUnless(domainsEqual(mydomain1, mydomain2), "Domains differ")
117    
118 ksteube 1771 def DISABLED_test_mesh_dump_to_NetCDF_brick(self):
119 ksteube 1755 if loadIsConfigured():
120     mydomain1 = Brick(n0=7, n1=11, n2=5, order=2, l0=1., l1=1., l2=1., optimize=False)
121     mydomain1.dump("tt.mesh.nc")
122     mydomain2=LoadMesh("tt.mesh.nc")
123     self.failUnless(domainsEqual(mydomain1, mydomain2), "Domains differ")
124    
125 ksteube 1754 if __name__ == '__main__':
126     suite = unittest.TestSuite()
127     suite.addTest(unittest.makeSuite(InputOutput))
128     s=unittest.TextTestRunner(verbosity=2).run(suite)
129     if not s.wasSuccessful(): sys.exit(1)
130    

  ViewVC Help
Powered by ViewVC 1.1.26