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

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

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

revision 263 by cochrane, Tue Nov 29 09:55:16 2005 UTC revision 276 by cochrane, Wed Nov 30 04:31:40 2005 UTC
# Line 903  class SurfMovie(Model): Line 903  class SurfMovie(Model):
903    
904             self.firstFrame = True             self.firstFrame = True
905    
906           self.imageFiles = []
907    
908         def doInitialization(self):         def doInitialization(self):
909            """            """
910            Initializes the time integration scheme            Initializes the time integration scheme
# Line 1120  class SurfMovie(Model): Line 1122  class SurfMovie(Model):
1122               # vtkobj=...               # vtkobj=...
1123               # save(self.__frame_name)               # save(self.__frame_name)
1124    
1125               # get the wave data           # make a reader for the data
1126               waveDomain = self.wave_height.getDomain().getX()           waveReader = vtk.vtkXMLUnstructuredGridReader()
1127               waveX = waveDomain[0].convertToNumArray()           waveReader.SetFileName(self.__fn)
1128               waveY = waveDomain[1].convertToNumArray()           waveReader.Update()
              waveZ = self.wave_height.convertToNumArray()  
   
              numPoints = len(waveZ)  
   
              # make the points  
              wavePoints = vtk.vtkPoints()  
              wavePoints.SetNumberOfPoints(numPoints)  
   
              # make the vtk data array  
              waveData = vtk.vtkFloatArray()  
              waveData.SetNumberOfComponents(1)  
              waveData.SetNumberOfTuples(numPoints)  
              waveData.SetName("data")  
   
              # put the data into the points and array  
              for i in range(numPoints):  
                  wavePoints.InsertPoint(i, waveX[i], waveY[i], 0.0)  
                  waveData.InsertTuple1(i, waveZ[i])  
1129    
1130               # make the grid               # make the grid
1131               waveGrid = vtk.vtkUnstructuredGrid()               waveGrid = waveReader.GetOutput()
1132               waveGrid.SetPoints(wavePoints)           waveGrid.Update()
              waveGrid.GetPointData().AddArray(waveData)  
              waveGrid.GetPointData().SetActiveScalars("data")  
1133    
1134               (zMin, zMax) = waveGrid.GetPointData().GetScalars().GetRange()               (zMin, zMax) = waveGrid.GetPointData().GetScalars().GetRange()
1135               print "Wave height range %f - %f" % (zMin, zMax)               print "Wave height range %f - %f" % (zMin, zMax)
1136    
          # do a delaunay on the data  
          waveDelaunay = vtk.vtkDelaunay2D()  
          waveDelaunay.SetInput(waveGrid)  
          waveDelaunay.SetTolerance(0.001)  
          waveDelaunay.SetAlpha(2.5)  
   
1137               # make a mapper for the grid               # make a mapper for the grid
1138               waveMapper = vtk.vtkDataSetMapper()               waveMapper = vtk.vtkDataSetMapper()
1139               waveMapper.SetInput(waveDelaunay.GetOutput())               waveMapper.SetInput(waveGrid)
1140           waveMapper.SetLookupTable(self.lutTrans)           waveMapper.SetLookupTable(self.lutTrans)
1141               waveMapper.SetScalarRange(zMin, zMax)               waveMapper.SetScalarRange(zMin, zMax)
1142    
# Line 1188  class SurfMovie(Model): Line 1164  class SurfMovie(Model):
1164               outWriter.SetFileName(imgFname)               outWriter.SetFileName(imgFname)
1165               outWriter.Write()               outWriter.Write()
1166               print "Wrote %s" % imgFname               print "Wrote %s" % imgFname
1167               os.system("display %s" % imgFname)  
1168             # helpful for debugging:
1169             #os.system("display %s" % imgFname)
1170    
1171               self.paramsFileString += "%s\n" % imgFname               self.paramsFileString += "%s\n" % imgFname
1172             self.imageFiles.append(imgFname)
1173    
1174               self.__next_t+=self.dt               self.__next_t+=self.dt
1175    
# Line 1225  class SurfMovie(Model): Line 1205  class SurfMovie(Model):
1205            if result != 0:            if result != 0:
1206                print "An error occurred in mpeg conversion"                print "An error occurred in mpeg conversion"
1207    
1208          # now clean up the image files
1209          print "Removing temporary image files"
1210          os.unlink("%s.params" % self.filename)
1211          for fname in self.imageFiles:
1212              os.unlink(fname)
1213    
1214  if __name__=="__main__":  if __name__=="__main__":
1215     from esys.escript.modelframe import Link,Simulation     from esys.escript.modelframe import Link,Simulation
1216     from esys.modellib.input import Sequencer     from esys.modellib.input import Sequencer
# Line 1256  if __name__=="__main__": Line 1242  if __name__=="__main__":
1242     src.end_lat=-12.     src.end_lat=-12.
1243     src.start_long=110.     src.start_long=110.
1244     src.end_long=120.     src.end_long=120.
1245     src.width=0.1     src.width=1.
1246     src.decay_zone=0.01     src.decay_zone=0.01
1247     src.amplitude=1.     src.amplitude=1.
1248    

Legend:
Removed from v.263  
changed lines
  Added in v.276

  ViewVC Help
Powered by ViewVC 1.1.26