/[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 127 by jgs, Fri Jul 22 05:11:29 2005 UTC revision 147 by jgs, Fri Aug 12 01:45:47 2005 UTC
# Line 1  Line 1 
1  # $Id$  # $Id$
2    
3    from escript.modelframe import Model
 from esys.modelframe import Model  
4    
5  class Visualization(Model):  class Visualization(Model):
6         """         """
7    
8               generic visualization of scalar, vector and tensorial data (not implemeted yet)               generic visualization of scalar, vector and tensorial data (not implemeted yet)
9    
10                 t:      current time
11               scalar: scalar data set               scalar: scalar data set
12               vector: vector data set               vector: vector data set
13               tensor: tensor data set               tensor: tensor data set
# Line 17  class Visualization(Model): Line 17  class Visualization(Model):
17         """         """
18         def __init__(self,debug=False):         def __init__(self,debug=False):
19              Model.__init__(self,debug=debug)              Model.__init__(self,debug=debug)
20              self.declareParameter(scalar=None,vector=None,tensor=None,stride=1,filename="movie.mpg")              self.declareParameter(t=0.,scalar=None,vector=None,tensor=None,stride=1,movie="movie.mpg",counter=0)
21    
22         def doInitialization(self,t):         def doInitialization(self):
            self.__tn=t  
23             self.__n=0             self.__n=0
24             self.__scene=None             self.__scene=None
25    
26         def doStep(self,dt):         def doStepPostprocessing(self,dt):
            self.__tn+=dt  
27             self.__n+=1             self.__n+=1
28             if self.__n%self.stride:             if self.__n%self.stride:
29                 data=self.scalar                 data=self.scalar
# Line 55  class WriteVTK(Visualization): Line 53  class WriteVTK(Visualization):
53         """         """
54         def __init__(self,debug=False):         def __init__(self,debug=False):
55              Visualization.__init__(self,debug=debug)              Visualization.__init__(self,debug=debug)
56              self.declareParameter(scalar=None,vector=None,tensor=None,stride=1,filename="data.%s.vtk",counter=0)              self.declareParameter(filename="data.%s.xml")
   
        def doInitialization(self,t):  
            self.__tn=t  
57    
58         def doStep(self,dt):         def doStepPostprocessing(self,dt):
            self.__tn+=dt  
59             self.counter+=1             self.counter+=1
            print self.counter,self.stride,self.counter%self.stride  
60             if self.counter%self.stride==0:             if self.counter%self.stride==0:
61                 n=self.counter/self.stride                 n=self.counter/self.stride
62                 data=self.scalar                 data=self.scalar
63                 if hasattr(data,"saveVTK"): data.saveVTK(self.filename%("s%d"%n))                 if hasattr(data,"saveVTK"): data.saveVTK(self.filename%("s.%d"%n))
64                 data=self.vector                 data=self.vector
65                 if hasattr(data,"saveVTK"): data.saveVTK(self.filename%("v%d"%n))                 if hasattr(data,"saveVTK"): data.saveVTK(self.filename%("v.%d"%n))
66                 data=self.tensor                 data=self.tensor
67                 if hasattr(data,"saveVTK"): data.saveVTK(self.filename%("t%d"%n))                 if hasattr(data,"saveVTK"): data.saveVTK(self.filename%("t.%d"%n))

Legend:
Removed from v.127  
changed lines
  Added in v.147

  ViewVC Help
Powered by ViewVC 1.1.26