/[escript]/branches/intelc_win32/bruce/test/python/run_bruce.py
ViewVC logotype

Contents of /branches/intelc_win32/bruce/test/python/run_bruce.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 742 - (show annotations)
Sat Jun 24 11:27:16 2006 UTC (13 years, 3 months ago) by woo409
File MIME type: text/x-python
File size: 3413 byte(s)
+ Initial commit of win32 port using intel c++ compiler 9.1.x for Windows
+ This version is failing some file handling tests in python
1 # $Id: BruceTest.py 627 2006-03-23 02:22:46Z elspeth $
2 """
3
4 Some simple tests of Bruce.
5
6 """
7
8 __copyright__=""" Copyright (c) 2006 by ACcESS MNRF
9 http://www.access.edu.au
10 Primary Business: Queensland, Australia"""
11 __license__="""Licensed under the Open Software License version 3.0
12 http://www.opensource.org/licenses/osl-3.0.php"""
13
14 import os
15 import sys
16 import unittest
17
18 from esys.escript import *
19 from esys.bruce import *
20
21 class bruceTestCase(unittest.TestCase):
22
23 def setUp(self):
24 self.b = Rectangle(11,11,10,10)
25
26 def tearDown(self):
27 del self.b
28
29 def testGetDescription(self):
30 assert (self.b.getDescription()=="Bruce")
31
32 def testValidFunctionSpace(self):
33 assert (self.b.isValidFunctionSpaceType(0))
34 assert (self.b.isValidFunctionSpaceType(1))
35 assert (not(self.b.isValidFunctionSpaceType(2)))
36
37 def testFunctionCode(self):
38 assert (self.b.getContinuousFunctionCode()==0)
39 assert (self.b.getFunctionCode()==1)
40
41 def testFunctionSpaceTypeAsString(self):
42 assert (self.b.functionSpaceTypeAsString(0) == "Bruce_ContinuousFunction")
43 assert (self.b.functionSpaceTypeAsString(1) == "Bruce_Function")
44
45 def testGetDim(self):
46 assert (self.b.getDim()==2)
47
48 def testGetNumSamples(self):
49 numSamples = self.b.getNumSamples(0)
50 assert (numSamples == 121)
51 numSamples = self.b.getNumSamples(1)
52 assert (numSamples == 100)
53
54 def testGetNumDataPointsPerSample(self):
55 numDataPointsPerSample = self.b.getNumDataPointsPerSample(0)
56 assert (numDataPointsPerSample == 1)
57 numDataPointsPerSample = self.b.getNumDataPointsPerSample(1)
58 assert (numDataPointsPerSample == 1)
59
60 def testGetReferenceNoFromSampleNo(self):
61 numSamples = self.b.getNumSamples(0)
62 for sampleNo in range(numSamples):
63 assert (sampleNo == self.b.getReferenceNoFromSampleNo(0,sampleNo))
64 numSamples = self.b.getNumSamples(1)
65 for sampleNo in range(numSamples):
66 assert (sampleNo == self.b.getReferenceNoFromSampleNo(1,sampleNo))
67
68 def testTagFromSampleNo(self):
69 numSamples = self.b.getNumSamples(0)
70 for sampleNo in range(numSamples):
71 assert (0 == self.b.getTagFromSampleNo(0,sampleNo))
72 numSamples = self.b.getNumSamples(1)
73 for sampleNo in range(numSamples):
74 assert (0 == self.b.getTagFromSampleNo(1,sampleNo))
75
76 def testBrick(self):
77 brick = Brick(11,11,11,10,10,10)
78 assert (brick.getDim()==3)
79
80 def testRectangle(self):
81 rectangle = Rectangle(11,11,10,10)
82 assert (rectangle.getDim()==2)
83
84 def testSaveVTK(self):
85 filename = os.environ['BRUCE_WORKDIR']+"/testVTK.xml"
86 fs1 = ContinuousFunction(self.b)
87 fs2 = Function(self.b)
88 testData1 = Scalar(1.0, fs1)
89 testData2 = Scalar(2.0, fs2)
90 testData3 = Vector(3.0, fs1)
91 testData4 = Vector(4.0, fs2)
92 testData5 = Tensor(5.0, fs1)
93 testData6 = Tensor(6.0, fs2)
94 dict = {'testData1':testData1,
95 'testData2':testData2,
96 # 'testData3':testData3,
97 'testData4':testData4,
98 'testData5':testData5,
99 'testData6':testData6}
100 print "before saveVTK call"
101 self.b.saveVTK(filename, dict)
102 print "after saveVTK call"
103
104 if __name__ == '__main__':
105 suite=unittest.TestSuite()
106 suite.addTest(unittest.makeSuite(bruceTestCase))
107 s=unittest.TextTestRunner(verbosity=2).run(suite)
108 if s.wasSuccessful():
109 sys.exit(0)
110 else:
111 sys.exit(1)

  ViewVC Help
Powered by ViewVC 1.1.26