/[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 155 - (show annotations)
Wed Nov 9 02:02:19 2005 UTC (15 years ago) by jgs
File MIME type: text/x-python
File size: 2930 byte(s)
move all directories from trunk/esys2 into trunk and remove esys2

1 # $Id$
2
3 import os
4 import sys
5 import unittest
6
7 from esys.escript import *
8 from esys.bruce import *
9
10 """
11
12 Some simple tests of Bruce.
13
14 """
15
16 class bruceTestCase(unittest.TestCase):
17
18 def setUp(self):
19 self.b = Rectangle(11,11,10,10)
20
21 def tearDown(self):
22 del self.b
23
24 def testGetDescription(self):
25 assert (self.b.getDescription()=="Bruce")
26
27 def testValidFunctionSpace(self):
28 assert (self.b.isValidFunctionSpaceType(0))
29 assert (self.b.isValidFunctionSpaceType(1))
30 assert (not(self.b.isValidFunctionSpaceType(2)))
31
32 def testFunctionCode(self):
33 assert (self.b.getContinuousFunctionCode()==0)
34 assert (self.b.getFunctionCode()==1)
35
36 def testFunctionSpaceTypeAsString(self):
37 assert (self.b.functionSpaceTypeAsString(0) == "Bruce_ContinuousFunction")
38 assert (self.b.functionSpaceTypeAsString(1) == "Bruce_Function")
39
40 def testGetDim(self):
41 assert (self.b.getDim()==2)
42
43 def testGetNumSamples(self):
44 numSamples = self.b.getNumSamples(0)
45 assert (numSamples == 121)
46 numSamples = self.b.getNumSamples(1)
47 assert (numSamples == 100)
48
49 def testGetNumDataPointsPerSample(self):
50 numDataPointsPerSample = self.b.getNumDataPointsPerSample(0)
51 assert (numDataPointsPerSample == 1)
52 numDataPointsPerSample = self.b.getNumDataPointsPerSample(1)
53 assert (numDataPointsPerSample == 1)
54
55 def testGetReferenceNoFromSampleNo(self):
56 numSamples = self.b.getNumSamples(0)
57 for sampleNo in range(numSamples):
58 assert (sampleNo == self.b.getReferenceNoFromSampleNo(0,sampleNo))
59 numSamples = self.b.getNumSamples(1)
60 for sampleNo in range(numSamples):
61 assert (sampleNo == self.b.getReferenceNoFromSampleNo(1,sampleNo))
62
63 def testTagFromSampleNo(self):
64 numSamples = self.b.getNumSamples(0)
65 for sampleNo in range(numSamples):
66 assert (0 == self.b.getTagFromSampleNo(0,sampleNo))
67 numSamples = self.b.getNumSamples(1)
68 for sampleNo in range(numSamples):
69 assert (0 == self.b.getTagFromSampleNo(1,sampleNo))
70
71 def testBrick(self):
72 brick = Brick(11,11,11,10,10,10)
73 assert (brick.getDim()==3)
74
75 def testRectangle(self):
76 rectangle = Rectangle(11,11,10,10)
77 assert (rectangle.getDim()==2)
78
79 def testSaveVTK(self):
80 filename = "testVTK.vts"
81 fs1 = ContinuousFunction(self.b)
82 fs2 = Function(self.b)
83 testData1 = Scalar(1.0, fs1)
84 testData2 = Scalar(1.0, fs2)
85 testData3 = Vector(1.0, fs1)
86 testData4 = Vector(1.0, fs2)
87 testData5 = Tensor(1.0, fs1)
88 testData6 = Tensor(1.0, fs2)
89 dict = {'testData1':testData1,
90 'testData2':testData2,
91 # 'testData3':testData3,
92 'testData4':testData4,
93 'testData5':testData5,
94 'testData6':testData6}
95 self.b.saveVTK(filename, dict)
96
97 if __name__ == '__main__':
98 suite=unittest.TestSuite()
99 suite.addTest(unittest.makeSuite(bruceTestCase))
100 unittest.TextTestRunner(verbosity=2).run(suite)
101
102 sys.exit(0)

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26