2 |
|
|
3 |
import os |
import os |
4 |
import sys |
import sys |
5 |
|
import unittest |
6 |
|
|
7 |
from esys.escript import * |
from esys.escript import * |
8 |
from esys.bruce import * |
from esys.bruce import * |
13 |
|
|
14 |
""" |
""" |
15 |
|
|
16 |
b = Bruce() |
class bruceTestCase(unittest.TestCase): |
17 |
|
|
18 |
assert (b.getDescription()=="Bruce") |
def setUp(self): |
19 |
|
self.b = Rectangle(11,11,10,10) |
20 |
|
|
21 |
assert (b.isValidFunctionSpaceType(0)) |
def tearDown(self): |
22 |
assert (b.isValidFunctionSpaceType(1)) |
del self.b |
|
assert ( not (b.isValidFunctionSpaceType(2))) |
|
23 |
|
|
24 |
assert (b.getContinuousFunctionCode()==0) |
def testGetDescription(self): |
25 |
assert (b.getFunctionCode()==1) |
assert (self.b.getDescription()=="Bruce") |
26 |
|
|
27 |
assert (b.getDim()==0) |
def testValidFunctionSpace(self): |
28 |
|
assert (self.b.isValidFunctionSpaceType(0)) |
29 |
brick = Brick(11,11,11,10,10,10) |
assert (self.b.isValidFunctionSpaceType(1)) |
30 |
|
assert (not(self.b.isValidFunctionSpaceType(2))) |
31 |
assert (brick.getDim()==3) |
|
32 |
|
def testFunctionCode(self): |
33 |
brick.getX() |
assert (self.b.getContinuousFunctionCode()==0) |
34 |
brick.getSize() |
assert (self.b.getFunctionCode()==1) |
35 |
|
|
36 |
rectangle = Rectangle(11,11,10,10) |
def testFunctionSpaceTypeAsString(self): |
37 |
|
assert (self.b.functionSpaceTypeAsString(0) == "Bruce_ContinuousFunction") |
38 |
assert (rectangle.getDim()==2) |
assert (self.b.functionSpaceTypeAsString(1) == "Bruce_Function") |
39 |
|
|
40 |
rectangle.getX() |
def testGetDim(self): |
41 |
rectangle.getSize() |
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) |
sys.exit(0) |