source: anuga_work/development/sudi/sw_2d/run_boundary_condition_time.py @ 7837

Last change on this file since 7837 was 7738, checked in by steve, 15 years ago

Adding a directory for Sudi to work on.

File size: 2.1 KB
Line 
1
2
3import numpy as num
4from swb_domain import *
5
6
7"""test_boundary_condition_time
8
9This tests that boundary conditions are evaluated
10using the right time from domain.
11"""
12
13# Setup computational domain
14from anuga.abstract_2d_finite_volumes.mesh_factory \
15     import rectangular_cross
16
17#--------------------------------------------------------------
18# Setup computational domain
19#--------------------------------------------------------------
20N = 20
21points, vertices, boundary = rectangular_cross(N, N)
22domain = Domain(points, vertices, boundary)
23
24#--------------------------------------------------------------
25# Setup initial conditions
26#--------------------------------------------------------------
27domain.set_quantity('elevation', 0.0)
28domain.set_quantity('friction', 0.0)
29domain.set_quantity('stage', 0.0)
30
31#--------------------------------------------------------------
32# Setup boundary conditions
33#--------------------------------------------------------------
34# Time dependent boundary
35Bt = Time_boundary(domain=domain, f=lambda t: [t, 0.0, 0.0])
36
37Br = Reflective_boundary(domain)              # Reflective wall
38
39domain.set_boundary({'left': Bt, 'right': Br, 'top': Br, 'bottom': Br})
40
41
42
43interactive_visualisation = True
44
45#===============================================================================
46if interactive_visualisation:
47    from anuga.visualiser import RealtimeVisualiser
48    vis = RealtimeVisualiser(domain)
49    vis.render_quantity_height("elevation", zScale =1.0, dynamic=True)   
50    vis.render_quantity_height("stage", zScale =1.0, dynamic=True)
51    vis.colour_height_quantity('stage', (1.0, 0.5, 0.5))
52    vis.start()
53#===============================================================================
54
55
56
57for t in domain.evolve(yieldstep = 0.02, finaltime = 20.0):
58    #print domain.get_time()
59    #q = Bt.evaluate()
60   
61    # FIXME (Ole): This test would not have passed in
62    # changeset:5846.
63    #msg = 'Time boundary not evaluated correctly'
64    #assert num.allclose(t, q[0]), msg
65
66    domain.write_time()
67    if interactive_visualisation:
68        vis.update()
69
70if interactive_visualisation:
71    vis.evolveFinished()   
72   
Note: See TracBrowser for help on using the repository browser.