/[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 2344 by jfenwick, Mon Mar 30 02:13:58 2009 UTC revision 2455 by jfenwick, Wed Jun 3 03:29:07 2009 UTC
# Line 24  import vtk Line 24  import vtk
24  from esys.escript import *  from esys.escript import *
25  from esys.escript.linearPDEs import LinearPDE  from esys.escript.linearPDEs import LinearPDE
26  from esys.escript.modelframe import Model  from esys.escript.modelframe import Model
27  import numarray  import numpy
28  import math  import math
29  from tempfile import mkstemp  from tempfile import mkstemp
30    
# Line 62  class GridData: Line 62  class GridData:
62              x_shape0 = x.getNumberOfDataPoints()              x_shape0 = x.getNumberOfDataPoints()
63              return_data_object = True              return_data_object = True
64          else:          else:
65              x_array = numarray.array(x)              x_array = numpy.array(x)
66              x_shape0 = x_array.shape[0]              x_shape0 = x_array.shape[0]
67              return_data_object = False              return_data_object = False
68    
69          data=numarray.zeros(x_shape0, numarray.Float)          data=numpy.zeros(x_shape0, numpy.float_)
70          ox,oy = self.getOrigin()          ox,oy = self.getOrigin()
71          dx,dy = self.getSpacing()          dx,dy = self.getSpacing()
72          data_array = self.getData()          data_array = self.getData()
# Line 74  class GridData: Line 74  class GridData:
74          i_dy = 1          i_dy = 1
75          for i in range(x_shape0):          for i in range(x_shape0):
76              if return_data_object:              if return_data_object:
77                  x_array = x.getValueOfDataPoint(i)                  x_array = x.getTupleForDataPoint(i)
78                  x_long = x_array[0]-ox                  x_long = x_array[0]-ox
79                  x_lat = x_array[1]-oy                  x_lat = x_array[1]-oy
80              else:              else:
# Line 759  class Bathymetry(Model): Line 759  class Bathymetry(Model):
759              data_grd_list.append(float(v[2]))              data_grd_list.append(float(v[2]))
760              line=f.readline().strip()              line=f.readline().strip()
761          self.trace("%s lines have been read from %s." % (len(data_grd_list), self.source))          self.trace("%s lines have been read from %s." % (len(data_grd_list), self.source))
762          data_grd=numarray.array(data_grd_list)          data_grd=numpy.array(data_grd_list)
763          x_grd=numarray.array(x_grd_list)          x_grd=numpy.array(x_grd_list)
764          y_grd=numarray.array(y_grd_list)          y_grd=numpy.array(y_grd_list)
765          if len(x_grd)<2:          if len(x_grd)<2:
766              raise ValueError,"%s: data base is too small"%str(self)              raise ValueError,"%s: data base is too small"%str(self)
767          ox=x_grd[0]          ox=x_grd[0]
# Line 921  class TsunamiInDeepWater(Model): Line 921  class TsunamiInDeepWater(Model):
921          self.__pde = LinearPDE(self.domain)          self.__pde = LinearPDE(self.domain)
922          self.__pde.setSolverMethod(self.__pde.LUMPING)          self.__pde.setSolverMethod(self.__pde.LUMPING)
923          self.__pde.setValue(D=1.)          self.__pde.setValue(D=1.)
924          self.__c2 = RegionOnEarthSurface.GRAVITY*self.bathymetry/(RegionOnEarthSurface.RADIUS*2*numarray.pi/360.)**2          self.__c2 = RegionOnEarthSurface.GRAVITY*self.bathymetry/(RegionOnEarthSurface.RADIUS*2*numpy.pi/360.)**2
925          c_max = math.sqrt(Lsup(self.__c2))          c_max = math.sqrt(Lsup(self.__c2))
926          self.__dt = self.safety_factor*inf(self.domain.getSize()/(sqrt(self.__c2)+EPS*c_max))          self.__dt = self.safety_factor*inf(self.domain.getSize()/(sqrt(self.__c2)+EPS*c_max))
927          if self.initial_time_step==None:          if self.initial_time_step==None:
# Line 1008  class SurfMovie(Model): Line 1008  class SurfMovie(Model):
1008          numYPoints = bathZData.shape[0]          numYPoints = bathZData.shape[0]
1009          numPoints = numXPoints*numYPoints          numPoints = numXPoints*numYPoints
1010    
1011          bathXData = numarray.zeros(numXPoints, numarray.Float)          bathXData = numpy.zeros(numXPoints, numpy.float_)
1012          bathYData = numarray.zeros(numYPoints, numarray.Float)          bathYData = numpy.zeros(numYPoints, numpy.float_)
1013          for i in range(numXPoints):          for i in range(numXPoints):
1014              bathXData[i] = bathOrigin[0] + i*bathSpacing[0]              bathXData[i] = bathOrigin[0] + i*bathSpacing[0]
1015    
# Line 1075  class SurfMovie(Model): Line 1075  class SurfMovie(Model):
1075          numColours = len(data)          numColours = len(data)
1076    
1077          # convert the colourmap into something vtk is more happy with          # convert the colourmap into something vtk is more happy with
1078          height = numarray.zeros(numColours, numarray.Float)          height = numpy.zeros(numColours, numpy.float_)
1079          red = numarray.zeros(numColours, numarray.Float)          red = numpy.zeros(numColours, numpy.float_)
1080          green = numarray.zeros(numColours, numarray.Float)          green = numpy.zeros(numColours, numpy.float_)
1081          blue = numarray.zeros(numColours, numarray.Float)          blue = numpy.zeros(numColours, numpy.float_)
1082          for i in range(numColours):          for i in range(numColours):
1083              (h, r, g, b) = data[i]              (h, r, g, b) = data[i]
1084              height[i] = float(h)              height[i] = float(h)

Legend:
Removed from v.2344  
changed lines
  Added in v.2455

  ViewVC Help
Powered by ViewVC 1.1.26