source: inundation-numpy-branch/pyvolution/test_general_mesh.py @ 2608

Last change on this file since 2608 was 2608, checked in by ole, 18 years ago

Played with custom exceptions for ANUGA

File size: 2.1 KB
Line 
1#!/usr/bin/env python
2
3#FIXME (Ole): Maxe this test independent of anything that inherits from General_mesh (namely shallow_water)
4
5
6import unittest
7from math import sqrt, pi
8from numpy import allclose, array, zeros, ones, Float
9
10
11from quantity import *
12from config import epsilon
13
14
15
16class Test_General_Mesh(unittest.TestCase):
17    def setUp(self):
18        pass
19
20    def tearDown(self):
21        pass
22
23    def test_get_vertex_values(self):
24        """
25        get connectivity based on triangle lists.
26        """
27        from mesh_factory import rectangular
28        from shallow_water import Domain
29
30        #Create basic mesh
31        points, vertices, boundary = rectangular(1, 3)
32        domain = Domain(points, vertices, boundary)
33
34        value = [7]
35        #indexes = [1]  #FIXME (Ole): Should this be used
36        assert  domain.get_vertices() == domain.triangles
37        assert domain.get_vertices([0,4]) == [domain.triangles[0],
38                                              domain.triangles[4]]
39    def test_areas(self):
40        from mesh_factory import rectangular
41        from shallow_water import Domain
42
43        #Create basic mesh
44        points, vertices, boundary = rectangular(1, 3)
45        domain = Domain(points, vertices, boundary)
46
47        assert domain.get_area() == 1.0
48
49
50    def test_get_unique_vertex_values(self):
51        """
52        get unique_vertex based on triangle lists.
53        """
54        from mesh_factory import rectangular
55        from shallow_water import Domain
56
57        #Create basic mesh
58        points, vertices, boundary = rectangular(1, 3)
59        domain = Domain(points, vertices, boundary)
60
61        assert  domain.get_unique_vertices() == [0,1,2,3,4,5,6,7]
62        unique_vertices = domain.get_unique_vertices([0,1,4])
63        unique_vertices.sort()
64        assert unique_vertices == [0,1,2,4,5,6,7]
65
66        unique_vertices = domain.get_unique_vertices([0,4])
67        unique_vertices.sort()
68        assert unique_vertices == [0,2,4,5,6,7]
69
70#-------------------------------------------------------------
71if __name__ == "__main__":
72    suite = unittest.makeSuite(Test_General_Mesh,'test')
73    runner = unittest.TextTestRunner()
74    runner.run(suite)
75
Note: See TracBrowser for help on using the repository browser.