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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1777 - (show annotations)
Tue Sep 9 06:39:37 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: 5212 byte(s)
Implemented Lutz fix for MPI mesh dump/load using NetCDF

1 #
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 class InputOutput(unittest.TestCase):
55
56 def domainsEqual(self, m1, m2, nft=20):
57 self.failUnless(m1.getDim() == m2.getDim(), "Dimensions differ")
58 self.failUnless(m1.getNumDataPointsGlobal() == m2.getNumDataPointsGlobal(), "Num data points differ")
59 for tagName in m1.showTagNames().split(", "):
60 self.failUnless(m2.isValidTagName(tagName), "m1 has a tag '%s' not present in m2" % tagName)
61 for tagName in m2.showTagNames().split(", "):
62 self.failUnless(m1.isValidTagName(tagName), "m2 has a tag '%s' not present in m1" % tagName)
63 self.failUnless(m1.getTag(tagName) == m2.getTag(tagName), "values of tag '%s' differ" % tagName)
64 for fs in ["Solution", "ReducedSolution", "Function", "ReducedFunction", "FunctionOnBoundary", "ReducedFunctionOnBoundary", "ContinuousFunction", "ReducedContinuousFunction"]:
65 fs1 = eval("%s(m1)" % fs)
66 fs2 = eval("%s(m2)" % fs)
67 x1 = fs1.getX()
68 x2 = fs2.getX()
69 for n in range(1, nft+1):
70 integ1 = integrate(sin(n*x1))
71 integ2 = integrate(sin(n*x2))
72 self.failUnless(Lsup(abs(integ1-integ2)) <= REL_TOL, "integrals for n=%d differ" % n)
73 return True
74
75 # Does optimize=True change Rectangle for order=1?
76 def test_Rectangle_optimize_order1(self):
77 mydomain1 = Rectangle(n0=7, n1=11, order=1, l0=1., l1=1., optimize=False)
78 mydomain2 = Rectangle(n0=7, n1=11, order=1, l0=1., l1=1., optimize=True)
79 self.domainsEqual(mydomain1, mydomain2)
80
81 # Does optimize=True change Rectangle for order=2?
82 def test_Rectangle_optimize_order2(self):
83 mydomain1 = Rectangle(n0=7, n1=11, order=2, l0=1., l1=1., optimize=False)
84 mydomain2 = Rectangle(n0=7, n1=11, order=2, l0=1., l1=1., optimize=True)
85 self.domainsEqual(mydomain1, mydomain2)
86
87 # Does optimize=True change Brick for order=1?
88 def test_Brick_optimize_order1(self):
89 mydomain1 = Brick(n0=7, n1=11, n2=5, order=1, l0=1., l1=1., l2=1., optimize=False)
90 mydomain2 = Brick(n0=7, n1=11, n2=5, order=1, l0=1., l1=1., l2=1., optimize=True)
91 self.domainsEqual(mydomain1, mydomain2)
92
93 # Does optimize=True change Brick for order=2?
94 def test_Brick_optimize_order2(self):
95 mydomain1 = Brick(n0=7, n1=11, n2=5, order=2, l0=1., l1=1., l2=1., optimize=False)
96 mydomain2 = Brick(n0=7, n1=11, n2=5, order=2, l0=1., l1=1., l2=1., optimize=True)
97 self.domainsEqual(mydomain1, mydomain2)
98
99 def test_mesh_dump_to_NetCDF_rectangle(self):
100 if loadIsConfigured():
101 mydomain1 = Rectangle(n0=7, n1=11, order=1, l0=1., l1=1., optimize=False)
102 mydomain1.dump("tt.mesh.nc")
103 mydomain2=LoadMesh("tt.mesh.nc")
104 self.domainsEqual(mydomain1, mydomain2)
105
106 def test_mesh_dump_to_NetCDF_brick(self):
107 if loadIsConfigured():
108 mydomain1 = Brick(n0=7, n1=11, n2=5, order=2, l0=1., l1=1., l2=1., optimize=False)
109 mydomain1.dump("tt.mesh.nc")
110 mydomain2=LoadMesh("tt.mesh.nc")
111 self.domainsEqual(mydomain1, mydomain2)
112
113 def test_mesh_read_rectangle_from_finley_file(self):
114 mydomain1 = Rectangle(n0=8, n1=10, order=1, l0=1., l1=1., optimize=False)
115 mydomain2 = ReadMeshMPI(FINLEY_TEST_MESH_PATH+"rectangle_8x10.fly")
116 self.domainsEqual(mydomain1, mydomain2)
117
118 def test_mesh_read_brick_from_finley_file(self):
119 mydomain1 = Brick(n0=8, n1=10, n2=12, order=1, l0=1., l1=1., l2=1., optimize=False)
120 mydomain2 = ReadMeshMPI(FINLEY_TEST_MESH_PATH+"brick_8x10x12.fly")
121 self.domainsEqual(mydomain1, mydomain2)
122
123 if __name__ == '__main__':
124 suite = unittest.TestSuite()
125 suite.addTest(unittest.makeSuite(InputOutput))
126 s=unittest.TextTestRunner(verbosity=2).run(suite)
127 if not s.wasSuccessful(): sys.exit(1)
128

  ViewVC Help
Powered by ViewVC 1.1.26