source: anuga_work/development/2010-projects/anuga_1d/base/test_generic_domain.py @ 7855

Last change on this file since 7855 was 7855, checked in by steve, 14 years ago

Changing for loop to numpy.where

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