source: anuga_work/development/2010-projects/anuga_1d/generic/test_generic_domain.py @ 7839

Last change on this file since 7839 was 7839, checked in by steve, 13 years ago

Changing name of 1d projects so that it will be easy to moveto the trunk

File size: 1.5 KB
Line 
1#!/usr/bin/env python
2
3import unittest
4from math import sqrt, pi
5
6
7from flow_1d.generic_1d.generic_domain import *
8import numpy
9
10
11class 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#-------------------------------------------------------------
50if __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)
Note: See TracBrowser for help on using the repository browser.