[7839] | 1 | #!/usr/bin/env python |
---|
| 2 | |
---|
| 3 | import unittest |
---|
| 4 | from math import sqrt, pi |
---|
[7855] | 5 | import numpy |
---|
[7839] | 6 | |
---|
[7852] | 7 | from anuga_1d.base.generic_domain import * |
---|
[7839] | 8 | |
---|
| 9 | |
---|
[7855] | 10 | |
---|
[7839] | 11 | class Test_Generic_Domain(unittest.TestCase): |
---|
| 12 | def setUp(self): |
---|
| 13 | self.points = [0.0, 1.0, 2.0, 3.0] |
---|
| 14 | self.vertex_values = [[1.0,2.0],[4.0,5.0],[-1.0,2.0]] |
---|
| 15 | self.points2 = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0] |
---|
| 16 | |
---|
| 17 | def tearDown(self): |
---|
| 18 | pass |
---|
| 19 | #print " Tearing down" |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | def test_creation(self): |
---|
| 23 | domain = Generic_domain(self.points) |
---|
| 24 | |
---|
| 25 | assert numpy.allclose(domain.neighbours, \ |
---|
| 26 | [[-1 , 1],[ 0 , 2],[ 1 ,-1]]) |
---|
| 27 | |
---|
| 28 | assert numpy.allclose(domain.neighbour_vertices, \ |
---|
| 29 | [[-1 , 0],[ 1 , 0],[ 1 ,-1]]) |
---|
| 30 | |
---|
| 31 | assert numpy.allclose(domain.number_of_boundaries, \ |
---|
| 32 | [1, 0, 1]) |
---|
| 33 | |
---|
| 34 | assert numpy.allclose(domain.surrogate_neighbours, \ |
---|
| 35 | [[0, 1],[0, 2],[1, 2]]) |
---|
| 36 | |
---|
| 37 | assert numpy.allclose(domain.vertices, \ |
---|
| 38 | [[ 0., 1.],[ 1., 2.],[ 2., 3.]]) |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | assert numpy.allclose(domain.centroids, [0.5, 1.5, 2.5]) |
---|
| 42 | |
---|
| 43 | assert numpy.allclose(domain.areas, [ 1., 1., 1.]) |
---|
| 44 | |
---|
| 45 | assert numpy.allclose(domain.normals, \ |
---|
| 46 | [[-1., 1.],[-1., 1.],[-1., 1.]]) |
---|
| 47 | |
---|
| 48 | |
---|
[7855] | 49 | |
---|
[7839] | 50 | #------------------------------------------------------------- |
---|
| 51 | if __name__ == "__main__": |
---|
| 52 | suite = unittest.makeSuite(Test_Generic_Domain, 'test') |
---|
| 53 | #suite = unittest.makeSuite(Test_Shallow_Water, 'test_evolve_first_order') |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | runner = unittest.TextTestRunner() |
---|
| 57 | runner.run(suite) |
---|