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