1 | ########## |
---|
2 | # Demonstration of the VTK sww Visualiser |
---|
3 | # Jack Kelly |
---|
4 | # September 2006 |
---|
5 | ########## |
---|
6 | |
---|
7 | # Import the offline visualiser |
---|
8 | from anuga.visualiser import OfflineVisualiser |
---|
9 | |
---|
10 | # The argument to OfflineVisualiser is the path to a sww file |
---|
11 | o = OfflineVisualiser("../../swollen_viewer/tests/cylinders.sww") |
---|
12 | #o = OfflineVisualiser("../../../../anuga_validation/analytical solutions/circular_second_order.sww") |
---|
13 | |
---|
14 | # Specify the height-based-quantities to render. |
---|
15 | # Remember to set dynamic=True for time-varying quantities |
---|
16 | o.render_quantity_height("elevation", dynamic=False) |
---|
17 | o.render_quantity_height("stage", dynamic=True) |
---|
18 | |
---|
19 | # Colour the stage: |
---|
20 | # Either with an RGB value as a 3-tuple of Floats, |
---|
21 | #o.colour_height_quantity('stage', (0.0, 0.0, 0.8)) |
---|
22 | # Or with a function of the quantities at that point, such as the stage height: |
---|
23 | # 0 and 10 are the minimum and maximum values of the stage. |
---|
24 | o.colour_height_quantity('stage', (lambda q:q['stage'], 0, 10)) |
---|
25 | # Or with the magnitude of the momentum at that point: |
---|
26 | # Needs the sqrt function from Numeric. Again, 0 and 10 define the colour range. |
---|
27 | #o.colour_height_quantity('stage', (lambda q:sqrt((q['xmomentum'] ** 2) + |
---|
28 | # (q['ymomentum'] ** 2)), 0, 10)) |
---|
29 | |
---|
30 | # Draw some axes on the visualiser so we can see how big the wave is |
---|
31 | o.render_axes() |
---|
32 | |
---|
33 | # Precaching the height-based quantities reduces the time taken to draw each |
---|
34 | # frame, but increases the time taken when the visualiser starts. |
---|
35 | o.precache_height_quantities() |
---|
36 | |
---|
37 | # Start the visualiser (in its own thread). |
---|
38 | o.run() |
---|