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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1312 - (show annotations)
Mon Sep 24 06:18:44 2007 UTC (11 years, 11 months ago) by ksteube
File MIME type: text/x-python
File size: 3736 byte(s)
The MPI branch is hereby closed. All future work should be in trunk.

Previously in revision 1295 I merged the latest changes to trunk into trunk-mpi-branch.
In this revision I copied all files from trunk-mpi-branch over the corresponding
trunk files. I did not use 'svn merge', it was a copy.

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

  ViewVC Help
Powered by ViewVC 1.1.26