source: anuga_core/source/anuga/abstract_2d_finite_volumes/test_general_mesh.py @ 3945

Last change on this file since 3945 was 3945, checked in by ole, 17 years ago

One large step towards major cleanup. This has mainly to do with
the way vertex coordinates are handled internally.

File size: 2.7 KB
Line 
1#!/usr/bin/env python
2
3
4import unittest
5from math import sqrt, pi
6
7
8from anuga.config import epsilon
9from Numeric import allclose, array, ones, Float
10from general_mesh import General_mesh
11
12
13
14class Test_General_Mesh(unittest.TestCase):
15    def setUp(self):
16        pass
17
18    def tearDown(self):
19        pass
20
21
22    def test_get_vertex_coordinates(self):
23        from mesh_factory import rectangular
24        from Numeric import zeros, Float
25
26        #Create basic mesh
27        points, vertices, boundary = rectangular(1, 3)
28        domain = General_mesh(points, vertices)
29
30
31        assert allclose(domain.get_vertex_coordinates(unique=True),
32                        domain.nodes)
33
34        #assert allclose(domain.get_vertex_coordinates(), ...TODO
35        #assert allclose(domain.get_vertex_coordinates(absolute=True), ...TODO
36       
37       
38
39    def test_get_vertex_values(self):
40        """Get connectivity based on triangle lists.
41        """
42        from mesh_factory import rectangular
43        from Numeric import zeros, Float
44
45        #Create basic mesh
46        points, vertices, boundary = rectangular(1, 3)
47        domain = General_mesh(points, vertices)
48
49        value = [7]
50        #indexes = [1]  #FIXME (Ole): Should this be used
51        assert  domain.get_vertices() == domain.triangles
52        assert domain.get_vertices([0,4]) == [domain.triangles[0],
53                                              domain.triangles[4]]
54       
55    def test_areas(self):
56        from mesh_factory import rectangular
57        from shallow_water import Domain
58        from Numeric import zeros, Float
59
60        #Create basic mesh
61        points, vertices, boundary = rectangular(1, 3)
62        domain = General_mesh(points, vertices)       
63
64        assert domain.get_area() == 1.0
65
66
67    def test_get_unique_vertex_values(self):
68        """
69        get unique_vertex based on triangle lists.
70        """
71        from mesh_factory import rectangular
72        from shallow_water import Domain
73        from Numeric import zeros, Float
74
75        #Create basic mesh
76        points, vertices, boundary = rectangular(1, 3)
77        domain = General_mesh(points, vertices)               
78
79        assert  domain.get_unique_vertices() == [0,1,2,3,4,5,6,7]
80        unique_vertices = domain.get_unique_vertices([0,1,4])
81        unique_vertices.sort()
82        assert unique_vertices == [0,1,2,4,5,6,7]
83
84        unique_vertices = domain.get_unique_vertices([0,4])
85        unique_vertices.sort()
86        assert unique_vertices == [0,2,4,5,6,7]
87
88
89       
90
91#-------------------------------------------------------------
92if __name__ == "__main__":
93    suite = unittest.makeSuite(Test_General_Mesh,'test')
94    runner = unittest.TextTestRunner()
95    runner.run(suite)
96
Note: See TracBrowser for help on using the repository browser.