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

Annotation of /trunk/bruce/test/python/run_bruce.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 798 - (hide annotations)
Fri Aug 4 01:05:36 2006 UTC (15 years, 4 months ago) by gross
File MIME type: text/x-python
File size: 3429 byte(s)
Reimplementation of the assemblage with persistent jacobeans.
There are also a few changes to the tests which has now
dramatically reduced the memory demand.


1 gross 700 # $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 gross 798 try:
19     BRUCE_WORKDIR=os.environ['BRUCE_WORKDIR']
20     except KeyError:
21     BRUCE_WORKDIR='.'
22    
23 gross 700 from esys.escript import *
24     from esys.bruce import *
25    
26     class bruceTestCase(unittest.TestCase):
27    
28     def setUp(self):
29     self.b = Rectangle(11,11,10,10)
30    
31     def tearDown(self):
32     del self.b
33    
34     def testGetDescription(self):
35     assert (self.b.getDescription()=="Bruce")
36    
37     def testValidFunctionSpace(self):
38     assert (self.b.isValidFunctionSpaceType(0))
39     assert (self.b.isValidFunctionSpaceType(1))
40     assert (not(self.b.isValidFunctionSpaceType(2)))
41    
42     def testFunctionCode(self):
43     assert (self.b.getContinuousFunctionCode()==0)
44     assert (self.b.getFunctionCode()==1)
45    
46     def testFunctionSpaceTypeAsString(self):
47     assert (self.b.functionSpaceTypeAsString(0) == "Bruce_ContinuousFunction")
48     assert (self.b.functionSpaceTypeAsString(1) == "Bruce_Function")
49    
50     def testGetDim(self):
51     assert (self.b.getDim()==2)
52    
53     def testGetNumSamples(self):
54     numSamples = self.b.getNumSamples(0)
55     assert (numSamples == 121)
56     numSamples = self.b.getNumSamples(1)
57     assert (numSamples == 100)
58    
59     def testGetNumDataPointsPerSample(self):
60     numDataPointsPerSample = self.b.getNumDataPointsPerSample(0)
61     assert (numDataPointsPerSample == 1)
62     numDataPointsPerSample = self.b.getNumDataPointsPerSample(1)
63     assert (numDataPointsPerSample == 1)
64    
65     def testGetReferenceNoFromSampleNo(self):
66     numSamples = self.b.getNumSamples(0)
67     for sampleNo in range(numSamples):
68     assert (sampleNo == self.b.getReferenceNoFromSampleNo(0,sampleNo))
69     numSamples = self.b.getNumSamples(1)
70     for sampleNo in range(numSamples):
71     assert (sampleNo == self.b.getReferenceNoFromSampleNo(1,sampleNo))
72    
73     def testTagFromSampleNo(self):
74     numSamples = self.b.getNumSamples(0)
75     for sampleNo in range(numSamples):
76     assert (0 == self.b.getTagFromSampleNo(0,sampleNo))
77     numSamples = self.b.getNumSamples(1)
78     for sampleNo in range(numSamples):
79     assert (0 == self.b.getTagFromSampleNo(1,sampleNo))
80    
81     def testBrick(self):
82     brick = Brick(11,11,11,10,10,10)
83     assert (brick.getDim()==3)
84    
85     def testRectangle(self):
86     rectangle = Rectangle(11,11,10,10)
87     assert (rectangle.getDim()==2)
88    
89     def testSaveVTK(self):
90 gross 798 filename = BRUCE_WORKDIR+"/testVTK.xml"
91 gross 700 fs1 = ContinuousFunction(self.b)
92     fs2 = Function(self.b)
93     testData1 = Scalar(1.0, fs1)
94 gross 706 testData2 = Scalar(2.0, fs2)
95     testData3 = Vector(3.0, fs1)
96     testData4 = Vector(4.0, fs2)
97     testData5 = Tensor(5.0, fs1)
98     testData6 = Tensor(6.0, fs2)
99 gross 700 dict = {'testData1':testData1,
100     'testData2':testData2,
101     # 'testData3':testData3,
102     'testData4':testData4,
103     'testData5':testData5,
104     'testData6':testData6}
105     self.b.saveVTK(filename, dict)
106    
107     if __name__ == '__main__':
108     suite=unittest.TestSuite()
109     suite.addTest(unittest.makeSuite(bruceTestCase))
110     s=unittest.TextTestRunner(verbosity=2).run(suite)
111     if s.wasSuccessful():
112     sys.exit(0)
113     else:
114     sys.exit(1)

  ViewVC Help
Powered by ViewVC 1.1.26