Line | |
---|
1 | #!/usr/bin/env python |
---|
2 | from os import sep |
---|
3 | from sys import path |
---|
4 | |
---|
5 | from Numeric import array |
---|
6 | |
---|
7 | import unittest |
---|
8 | |
---|
9 | # path.append('..' + sep + 'pymetis') |
---|
10 | |
---|
11 | import metis |
---|
12 | |
---|
13 | class TestMetis(unittest.TestCase): |
---|
14 | def setUp(self): |
---|
15 | pass |
---|
16 | |
---|
17 | def testHexmesh(self): |
---|
18 | # Hexagonal mesh |
---|
19 | # |
---|
20 | # 1---2 |
---|
21 | # / \ / \ |
---|
22 | # 6---0---3 |
---|
23 | # \ / \ / |
---|
24 | # 5---4 |
---|
25 | # |
---|
26 | # Divided 3 ways |
---|
27 | # Calling order is: elements, verticies, edge list |
---|
28 | # element type, number parts |
---|
29 | edgecut, epart, npart = metis.partMeshNodal(6, 7,\ |
---|
30 | [0, 1, 2,\ |
---|
31 | 0, 2, 3,\ |
---|
32 | 0, 3, 4,\ |
---|
33 | 0, 4, 5,\ |
---|
34 | 0, 5, 6,\ |
---|
35 | 0, 6, 1],\ |
---|
36 | 1,\ |
---|
37 | 3,) |
---|
38 | #print edgecut |
---|
39 | #print epart |
---|
40 | #print npart |
---|
41 | epart_expected = array([2, 2, 0, 0, 0, 0], 'i') |
---|
42 | npart_expected = array([0, 2, 2, 2, 0, 0, 0], 'i') |
---|
43 | self.assert_(edgecut == 5) |
---|
44 | for i in range(len(epart)): |
---|
45 | self.assert_(epart[i] == epart_expected[i]) |
---|
46 | for i in range(len(npart)): |
---|
47 | self.assert_(npart[i] == npart_expected[i]) |
---|
48 | |
---|
49 | if __name__ == '__main__': |
---|
50 | unittest.main() |
---|
51 | |
---|
Note: See
TracBrowser
for help on using the repository browser.