source: inundation/ga/storm_surge/pyvolution/test_generic_boundary_conditions.py @ 303

Last change on this file since 303 was 195, checked in by ole, 21 years ago
File size: 2.5 KB
Line 
1#!/usr/bin/env python
2
3import unittest
4from math import sqrt, pi
5
6from generic_boundary_conditions import *
7from config import epsilon
8from Numeric import allclose, array
9
10       
11class TestCase(unittest.TestCase):
12    def setUp(self):
13        pass
14        #print "  Setting up"
15       
16    def tearDown(self):
17        pass
18        #print "  Tearing down"
19
20
21    def test_generic(self):
22        b = Boundary()
23
24        try:
25            b.evaluate()
26        except:
27            pass
28        else:
29            raise 'Should have raised exception'
30       
31
32    def test_dirichlet_empty(self):
33
34        try:
35            Bd = Dirichlet_boundary()
36        except:
37            pass
38        else:
39            raise 'Should have raised exception'
40
41    def test_dirichlet(self):
42        x = [3.14,0,0.1]
43        Bd = Dirichlet_boundary(x)
44
45        q = Bd.evaluate()
46        assert allclose(q, x)
47
48
49    def test_transmissive(self):
50        from domain import Domain
51        from quantity import Quantity
52       
53        a = [0.0, 0.0]
54        b = [0.0, 2.0]
55        c = [2.0,0.0]
56        d = [0.0, 4.0]
57        e = [2.0, 2.0]
58        f = [4.0,0.0]
59
60        points = [a, b, c, d, e, f]
61
62        #bac, bce, ecf, dbe
63        elements = [ [1,0,2], [1,2,4], [4,2,5], [3,1,4] ]
64       
65        domain = Domain(points, elements)
66        domain.check_integrity()
67
68       
69        domain.quantities['level'] =\
70                                   Quantity(domain, [[1,2,3], [5,5,5],
71                                                     [0,0,9], [-6, 3, 3]])
72
73        domain.quantities['ymomentum'] =\
74                                   Quantity(domain, [[1,2,3], [5,5,5],
75                                                     [0,0,9], [-6, 3, 3]])
76
77
78        domain.check_integrity()
79
80        #Test transmissve bdry
81        try:
82            T = Transmissive_boundary()
83        except:
84            pass
85        else:
86            raise 'Should have raised exception'
87
88        T = Transmissive_boundary(domain)
89
90        from config import default_boundary_tag
91        domain.set_boundary( {default_boundary_tag: T} )
92
93        assert len(domain.boundary) == len(domain.boundary_segments)
94        assert len(domain.boundary_objects) == len(domain.boundary_segments)       
95
96       
97#-------------------------------------------------------------
98if __name__ == "__main__":
99    suite = unittest.makeSuite(TestCase,'test')
100    runner = unittest.TextTestRunner()
101    runner.run(suite)
102
103
104       
Note: See TracBrowser for help on using the repository browser.