1 | #!/usr/bin/env python |
---|
2 | |
---|
3 | import unittest |
---|
4 | from math import sqrt, pi |
---|
5 | |
---|
6 | |
---|
7 | from flow_1d.generic_1d.generic_domain import * |
---|
8 | import numpy |
---|
9 | |
---|
10 | |
---|
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 | |
---|
49 | #------------------------------------------------------------- |
---|
50 | if __name__ == "__main__": |
---|
51 | suite = unittest.makeSuite(Test_Generic_Domain, 'test') |
---|
52 | #suite = unittest.makeSuite(Test_Shallow_Water, 'test_evolve_first_order') |
---|
53 | |
---|
54 | |
---|
55 | runner = unittest.TextTestRunner() |
---|
56 | runner.run(suite) |
---|