1 | |
---|
2 | |
---|
3 | import numpy as num |
---|
4 | from swb_domain import * |
---|
5 | |
---|
6 | |
---|
7 | """test_boundary_condition_time |
---|
8 | |
---|
9 | This tests that boundary conditions are evaluated |
---|
10 | using the right time from domain. |
---|
11 | """ |
---|
12 | |
---|
13 | # Setup computational domain |
---|
14 | from anuga.abstract_2d_finite_volumes.mesh_factory \ |
---|
15 | import rectangular_cross |
---|
16 | |
---|
17 | #-------------------------------------------------------------- |
---|
18 | # Setup computational domain |
---|
19 | #-------------------------------------------------------------- |
---|
20 | N = 20 |
---|
21 | points, vertices, boundary = rectangular_cross(N, N) |
---|
22 | domain = Domain(points, vertices, boundary) |
---|
23 | |
---|
24 | #-------------------------------------------------------------- |
---|
25 | # Setup initial conditions |
---|
26 | #-------------------------------------------------------------- |
---|
27 | domain.set_quantity('elevation', 0.0) |
---|
28 | domain.set_quantity('friction', 0.0) |
---|
29 | domain.set_quantity('stage', 0.0) |
---|
30 | |
---|
31 | #-------------------------------------------------------------- |
---|
32 | # Setup boundary conditions |
---|
33 | #-------------------------------------------------------------- |
---|
34 | # Time dependent boundary |
---|
35 | Bt = Time_boundary(domain=domain, f=lambda t: [t, 0.0, 0.0]) |
---|
36 | |
---|
37 | Br = Reflective_boundary(domain) # Reflective wall |
---|
38 | |
---|
39 | domain.set_boundary({'left': Bt, 'right': Br, 'top': Br, 'bottom': Br}) |
---|
40 | |
---|
41 | |
---|
42 | |
---|
43 | interactive_visualisation = True |
---|
44 | |
---|
45 | #=============================================================================== |
---|
46 | if 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 | |
---|
57 | for 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 | |
---|
70 | if interactive_visualisation: |
---|
71 | vis.evolveFinished() |
---|
72 | |
---|