source: inundation/pyvolution/test_general_mesh.py @ 1812

Last change on this file since 1812 was 1751, checked in by ole, 19 years ago

Changed misspelled 'indexes' to 'indices'

File size: 2.2 KB
Line 
1#!/usr/bin/env python
2
3import unittest
4from math import sqrt, pi
5
6
7from quantity import *
8from config import epsilon
9from Numeric import allclose, array, ones, Float
10
11
12class 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]
32        #indexes = [1]  #FIXME (Ole): Should this be used
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#-------------------------------------------------------------
70if __name__ == "__main__":
71    suite = unittest.makeSuite(Test_General_Mesh,'test')
72    runner = unittest.TextTestRunner()
73    runner.run(suite)
74
Note: See TracBrowser for help on using the repository browser.