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

Contents of /trunk/bruce/test/python/BruceTest.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 627 - (show annotations)
Thu Mar 23 02:22:46 2006 UTC (14 years, 6 months ago) by elspeth
File MIME type: text/x-python
File size: 3218 byte(s)
Copyright information added.

1 # $Id$
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 = "testVTK.vts"
86 fs1 = ContinuousFunction(self.b)
87 fs2 = Function(self.b)
88 testData1 = Scalar(1.0, fs1)
89 testData2 = Scalar(1.0, fs2)
90 testData3 = Vector(1.0, fs1)
91 testData4 = Vector(1.0, fs2)
92 testData5 = Tensor(1.0, fs1)
93 testData6 = Tensor(1.0, fs2)
94 dict = {'testData1':testData1,
95 'testData2':testData2,
96 # 'testData3':testData3,
97 'testData4':testData4,
98 'testData5':testData5,
99 'testData6':testData6}
100 self.b.saveVTK(filename, dict)
101
102 if __name__ == '__main__':
103 suite=unittest.TestSuite()
104 suite.addTest(unittest.makeSuite(bruceTestCase))
105 unittest.TextTestRunner(verbosity=2).run(suite)
106
107 sys.exit(0)

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26