source: inundation/pyvolution/shallow_water_vtk.py @ 2267

Last change on this file since 2267 was 2220, checked in by steve, 19 years ago

Moving visualisation

File size: 3.8 KB
Line 
1"""
2Shallow water domain with VTK viewer. We are just over
3
4Ole Nielsen, Duncan Gray
5Geoscience Australia, 2006
6
7Stephen Roberts,  Jack Kelly
8ANU 2006
9"""
10
11#Subversion keywords:
12#
13#$LastChangedDate: 2006-01-13 12:33:38 +1100 (Fri, 13 Jan 2006) $
14#$LastChangedRevision: 2205 $
15#$LastChangedBy: steve $
16
17
18from shallow_water import *
19Shallow_Water_Domain = Domain #Rename
20
21#Shallow water domain with VTK viewer
22class Domain(Shallow_Water_Domain):
23
24    def __init__(self, coordinates, vertices, boundary = None,
25                 tagged_elements = None, geo_reference = None,
26                 use_inscribed_circle=False):
27
28        Shallow_Water_Domain.__init__(self, coordinates, vertices, boundary,
29                                tagged_elements, geo_reference, use_inscribed_circle)
30
31
32
33    def initialise_visualiser(self,scale_z=1.0,rect=None):
34        #Realtime visualisation
35        if self.visualiser is None:
36            from vtk_realtime_visualiser import Visualiser
37            self.visualiser = Visualiser(self,scale_z,rect)
38            self.visualiser.setup['elevation']=True
39            self.visualiser.updating['stage']=True
40            self.visualiser.qcolor['stage'] = (0.1,0.4,0.99)
41        self.visualise = True
42        if self.visualise_color_stage == True:
43            self.visualiser.coloring['stage'] = True
44
45
46
47    def evolve(self, yieldstep = None, finaltime = None,
48               skip_initial_step = False):
49        """Specialisation of basic evolve method from parent class
50        """
51
52        import time
53        first = True
54        #Call check integrity here rather than from user scripts
55        #self.check_integrity()
56
57        msg = 'Parameter beta_h must be in the interval [0, 1['
58        assert 0 <= self.beta_h < 1.0, msg
59        msg = 'Parameter beta_w must be in the interval [0, 1['
60        assert 0 <= self.beta_w < 1.0, msg
61
62        self.distribute_to_vertices_and_edges()
63
64        #Initialise real time viz if requested
65        if self.visualise is True and self.time == 0.0 and self.visualiser is None:
66            self.initialise_visualiser()
67            #self.visualiser.update_timer()
68            print "Warning: Enabling the visualiser with domain.visualise is not"
69            print "recommended. Controlling the visualiser manually allows for much better"
70            print "control over visualiser parameters."
71
72        if self.visualise is True:
73            self.visualiser.start()
74            # Things go haywire if we start evolving before the vis is ready
75            self.visualiser.idle.wait()
76            self.visualiser.idle.clear()
77
78        #Store model data, e.g. for visualisation
79        if self.store is True and self.time == 0.0:
80            self.initialise_storage()
81            #print 'Storing results in ' + self.writer.filename
82        else:
83            pass
84
85        #Call basic machinery from parent class
86        for t in Generic_Domain.evolve(self, yieldstep, finaltime,
87                                       skip_initial_step):
88            #Real time viz
89            if self.visualise is True:
90                self.visualiser.redraw_ready.set()
91                self.visualiser.idle.wait()
92                self.visualiser.idle.clear()
93
94            #Store model data, e.g. for subsequent visualisation
95            if self.store is True:
96                self.store_timestep(self.quantities_to_be_stored)
97
98            #FIXME: Could maybe be taken from specified list
99            #of 'store every step' quantities
100
101            #Pass control on to outer loop for more specific actions
102            yield(t)
103
104#==================================== End of Updated Shallow Water VTK domain =============
105if __name__ == "__main__":
106    pass
107
108# Profiling stuff
109import profile
110profiler = profile.Profile()
Note: See TracBrowser for help on using the repository browser.