1 | #!/usr/bin/env python |
---|
2 | |
---|
3 | |
---|
4 | import unittest |
---|
5 | from math import sqrt, pi |
---|
6 | |
---|
7 | |
---|
8 | from anuga.config import epsilon |
---|
9 | from Numeric import allclose, array, ones, Float |
---|
10 | from general_mesh import General_mesh |
---|
11 | |
---|
12 | |
---|
13 | |
---|
14 | class Test_General_Mesh(unittest.TestCase): |
---|
15 | def setUp(self): |
---|
16 | pass |
---|
17 | |
---|
18 | def tearDown(self): |
---|
19 | pass |
---|
20 | |
---|
21 | |
---|
22 | def test_get_vertex_coordinates(self): |
---|
23 | from mesh_factory import rectangular |
---|
24 | from Numeric import zeros, Float |
---|
25 | |
---|
26 | #Create basic mesh |
---|
27 | points, vertices, boundary = rectangular(1, 3) |
---|
28 | domain = General_mesh(points, vertices) |
---|
29 | |
---|
30 | print domain.__class__ |
---|
31 | |
---|
32 | assert allclose(domain.get_vertex_coordinates(unique=True), domain.coordinates) |
---|
33 | |
---|
34 | #assert allclose(domain.get_vertex_coordinates(), ...TODO |
---|
35 | #assert allclose(domain.get_vertex_coordinates(absolute=True), ...TODO |
---|
36 | |
---|
37 | |
---|
38 | |
---|
39 | def test_get_vertex_values(self): |
---|
40 | """Get connectivity based on triangle lists. |
---|
41 | """ |
---|
42 | from mesh_factory import rectangular |
---|
43 | from Numeric import zeros, Float |
---|
44 | |
---|
45 | #Create basic mesh |
---|
46 | points, vertices, boundary = rectangular(1, 3) |
---|
47 | domain = General_mesh(points, vertices) |
---|
48 | |
---|
49 | value = [7] |
---|
50 | #indexes = [1] #FIXME (Ole): Should this be used |
---|
51 | assert domain.get_vertices() == domain.triangles |
---|
52 | assert domain.get_vertices([0,4]) == [domain.triangles[0], |
---|
53 | domain.triangles[4]] |
---|
54 | def test_areas(self): |
---|
55 | from mesh_factory import rectangular |
---|
56 | from shallow_water import Domain |
---|
57 | from Numeric import zeros, Float |
---|
58 | |
---|
59 | #Create basic mesh |
---|
60 | points, vertices, boundary = rectangular(1, 3) |
---|
61 | domain = General_mesh(points, vertices) |
---|
62 | |
---|
63 | assert domain.get_area() == 1.0 |
---|
64 | |
---|
65 | |
---|
66 | def test_get_unique_vertex_values(self): |
---|
67 | """ |
---|
68 | get unique_vertex based on triangle lists. |
---|
69 | """ |
---|
70 | from mesh_factory import rectangular |
---|
71 | from shallow_water import Domain |
---|
72 | from Numeric import zeros, Float |
---|
73 | |
---|
74 | #Create basic mesh |
---|
75 | points, vertices, boundary = rectangular(1, 3) |
---|
76 | domain = General_mesh(points, vertices) |
---|
77 | |
---|
78 | assert domain.get_unique_vertices() == [0,1,2,3,4,5,6,7] |
---|
79 | unique_vertices = domain.get_unique_vertices([0,1,4]) |
---|
80 | unique_vertices.sort() |
---|
81 | assert unique_vertices == [0,1,2,4,5,6,7] |
---|
82 | |
---|
83 | unique_vertices = domain.get_unique_vertices([0,4]) |
---|
84 | unique_vertices.sort() |
---|
85 | assert unique_vertices == [0,2,4,5,6,7] |
---|
86 | |
---|
87 | |
---|
88 | |
---|
89 | |
---|
90 | #------------------------------------------------------------- |
---|
91 | if __name__ == "__main__": |
---|
92 | suite = unittest.makeSuite(Test_General_Mesh,'test') |
---|
93 | runner = unittest.TextTestRunner() |
---|
94 | runner.run(suite) |
---|
95 | |
---|