/[escript]/trunk/modellib/py_src/visualization.py
ViewVC logotype

Diff of /trunk/modellib/py_src/visualization.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 628 by elspeth, Thu Mar 23 02:27:57 2006 UTC revision 814 by gross, Wed Aug 23 09:31:10 2006 UTC
# Line 15  class Visualization(Model): Line 15  class Visualization(Model):
15      Generic visualization of scalar, vector and tensorial data      Generic visualization of scalar, vector and tensorial data
16      (not implemeted yet)      (not implemeted yet)
17    
18      @ivar t: current time      @ivar t: current time (in)
19      @ivar n: frame counter      @ivar n: frame counter (in)
20      @ivar scalar: scalar data set      @ivar scalar: scalar data set (in)
21      @ivar vector: vector data set      @ivar vector: vector data set (in)
22      @ivar tensor: tensor data set      @ivar tensor: tensor data set (in)
23      @ivar dt: increment for output      @ivar dt: increment for output  (in)
24      @ivar filename: name of the output file      @ivar filename: name of the output file (in)
25      """      """
26    
27      def __init__(self, debug=False):      def __init__(self, debug=False):
# Line 40  class Visualization(Model): Line 40  class Visualization(Model):
40                                filename="movie.mpg")                                filename="movie.mpg")
41    
42      def doInitialization(self):      def doInitialization(self):
43          """         """
44          Does some kind of initialisation         does some kind of initialisation
45          """         """
46          self.__last_t=self.t         self.__last_t=self.t
47    
48      def writeFrame(self):      def writeFrame(self):
49           """
50           returns True if the time stamp for writing frame is reached.
51           """
52         out=self.t>=self.__last_t+self.dt         out=self.t>=self.__last_t+self.dt
53         if out:         if out:
54              self.__last_t+=self.dt              self.__last_t+=self.dt
# Line 53  class Visualization(Model): Line 56  class Visualization(Model):
56         return out         return out
57    
58      def getFrameCounter(self):      def getFrameCounter(self):
59          return self.n-1         """
60           returns a frame counter
61           """
62           return self.n-1
63    
64      def getSafeTimeStepSize(self,dt):      def getSafeTimeStepSize(self,dt):
65             """         """
66             returns new step size         returns new step size
67                                                                                                                                                                                                        
68             @param dt: last time step size used         @param dt: last time step size used
69             @type dt: C{float}         @type dt: C{float}
70             @return: time step size that can savely be used         @return: time step size that can savely be used
71             @rtype: C{float}         @rtype: C{float}
72             """         """
73             return self.__last_t+self.dt-self.t         return self.__last_t+self.dt-self.t
74    
75      def doStepPostprocessing(self, dt):      def doStepPostprocessing(self, dt):
76          """          """
# Line 73  class Visualization(Model): Line 79  class Visualization(Model):
79          @note: to be overwritten          @note: to be overwritten
80          """          """
81          if self.writeFrame():          if self.writeFrame():
82              self.trace("%s-th frame at time %s"%(self.getFrameCounter(),self.t))              if self.debug():
83              if not self.scalar==None:                 self.trace("%s-th frame at time %s"%(self.getFrameCounter(),self.t))
84                 self.trace("scalar data: (min,max) =(%s,%s)"%(inf(self.scalar),sup(self.scalar)))                 if not self.scalar==None:
85              if not self.vector==None:                    self.trace("scalar data: (min,max) =(%s,%s)"%(inf(self.scalar),sup(self.scalar)))
86                 self.trace("vector data: (min,max) =(%s,%s)"%(inf(self.vector),sup(self.vector)))                 if not self.vector==None:
87              if not self.tensor==None:                    self.trace("vector data: (min,max) =(%s,%s)"%(inf(self.vector),sup(self.vector)))
88                 self.trace("tensor data: (min,max) =(%s,%s)"%(inf(self.tensor),sup(self.tensor)))                 if not self.tensor==None:
89                                self.trace("tensor data: (min,max) =(%s,%s)"%(inf(self.tensor),sup(self.tensor)))
     def doFinalization(self):  
         """  
         Finalises the visualisation.  For instance, makes a movie of the image files.  
   
         @note: to be overwritten  
         """  
         pass  
90    
91  class WriteVTK(Visualization):  class WriteVTK(Visualization):
92      """      """
# Line 99  class WriteVTK(Visualization): Line 98  class WriteVTK(Visualization):
98          Initialisation of the WriteVTK object          Initialisation of the WriteVTK object
99    
100          @param debug: Debugging flag          @param debug: Debugging flag
101            @type debug: C{bool}
102          """          """
103          super(WriteVTK,self).__init__(debug=debug)          super(WriteVTK,self).__init__(debug=debug)
104    
105      def doInitialization(self):      def doInitialization(self):
106          """          """
107          Does some kind of initialisation          does some kind of initialisation
108          """          """
109          super(WriteVTK,self).doInitialization()          super(WriteVTK,self).doInitialization()
110          fnc=self.filename.split('.')          fnc=self.filename.split('.')
# Line 123  class WriteVTK(Visualization): Line 123  class WriteVTK(Visualization):
123    
124      def doStepPostprocessing(self, dt):      def doStepPostprocessing(self, dt):
125          """          """
126          Do any necessary postprocessing operations after a timestep.          writes
127            do any necessary postprocessing operations after a timestep.
128    
129          @param dt:          @param dt: current time increment
130            @type dt: C{float}
131          """          """
132          if self.writeFrame():          if self.writeFrame():
133              kwargs={}              kwargs={}

Legend:
Removed from v.628  
changed lines
  Added in v.814

  ViewVC Help
Powered by ViewVC 1.1.26