[2528] | 1 | #!/usr/bin/env python |
---|
| 2 | |
---|
| 3 | #FIXME (Ole): Maxe this test independent of anything that inherits from General_mesh (namely shallow_water) |
---|
| 4 | |
---|
| 5 | |
---|
| 6 | import unittest |
---|
| 7 | from math import sqrt, pi |
---|
| 8 | |
---|
| 9 | |
---|
| 10 | from quantity import * |
---|
| 11 | from config import epsilon |
---|
| 12 | from Numeric import allclose, array, ones, Float |
---|
| 13 | |
---|
| 14 | |
---|
| 15 | class Test_General_Mesh(unittest.TestCase): |
---|
| 16 | def setUp(self): |
---|
| 17 | pass |
---|
| 18 | |
---|
| 19 | def tearDown(self): |
---|
| 20 | pass |
---|
| 21 | |
---|
| 22 | def test_get_vertex_values(self): |
---|
| 23 | """ |
---|
| 24 | get connectivity based on triangle lists. |
---|
| 25 | """ |
---|
| 26 | from mesh_factory import rectangular |
---|
| 27 | from shallow_water import Domain |
---|
| 28 | from Numeric import zeros, Float |
---|
| 29 | |
---|
| 30 | #Create basic mesh |
---|
| 31 | points, vertices, boundary = rectangular(1, 3) |
---|
| 32 | domain = Domain(points, vertices, boundary) |
---|
| 33 | |
---|
| 34 | value = [7] |
---|
| 35 | #indexes = [1] #FIXME (Ole): Should this be used |
---|
| 36 | assert domain.get_vertices() == domain.triangles |
---|
| 37 | assert domain.get_vertices([0,4]) == [domain.triangles[0], |
---|
| 38 | domain.triangles[4]] |
---|
| 39 | def test_areas(self): |
---|
| 40 | from mesh_factory import rectangular |
---|
| 41 | from shallow_water import Domain |
---|
| 42 | from Numeric import zeros, Float |
---|
| 43 | |
---|
| 44 | #Create basic mesh |
---|
| 45 | points, vertices, boundary = rectangular(1, 3) |
---|
| 46 | domain = Domain(points, vertices, boundary) |
---|
| 47 | |
---|
| 48 | assert domain.get_area() == 1.0 |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | def test_get_unique_vertex_values(self): |
---|
| 52 | """ |
---|
| 53 | get unique_vertex based on triangle lists. |
---|
| 54 | """ |
---|
| 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 = Domain(points, vertices, boundary) |
---|
| 62 | |
---|
| 63 | assert domain.get_unique_vertices() == [0,1,2,3,4,5,6,7] |
---|
| 64 | unique_vertices = domain.get_unique_vertices([0,1,4]) |
---|
| 65 | unique_vertices.sort() |
---|
| 66 | assert unique_vertices == [0,1,2,4,5,6,7] |
---|
| 67 | |
---|
| 68 | unique_vertices = domain.get_unique_vertices([0,4]) |
---|
| 69 | unique_vertices.sort() |
---|
| 70 | assert unique_vertices == [0,2,4,5,6,7] |
---|
| 71 | |
---|
| 72 | #------------------------------------------------------------- |
---|
| 73 | if __name__ == "__main__": |
---|
| 74 | suite = unittest.makeSuite(Test_General_Mesh,'test') |
---|
| 75 | runner = unittest.TextTestRunner() |
---|
| 76 | runner.run(suite) |
---|
| 77 | |
---|