Ignore:
Timestamp:
Nov 5, 2004, 4:42:19 PM (20 years ago)
Author:
ole
Message:

Played with regridding of Cornell data

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution/cornell_room.py

    r320 r488  
    1212     Transmissive_boundary, Time_boundary, Constant_height
    1313
    14 from mesh_factory import from_polyfile
     14from mesh_factory import from_polyfile, rectangular
    1515from Numeric import array
     16from math import sqrt
     17from least_squares import Interpolation
    1618   
    1719
    1820print 'Creating domain'
    19 #points, triangles, values = from_polyfile('cornell_room_medres')
    20 points, triangles, values = from_polyfile('hires2')
     21#data_points, _, data_values = from_polyfile('cornell_room_medres')
     22#points, triangles, values = from_polyfile('hires2')
     23data_points, _, data_values = from_polyfile('hires2')
    2124
    2225
     26#Regrid onto numerically stable mesh
     27#
     28#Compute regular mesh based on resolution and extent of data
     29data_points = array(data_points)
     30pmax = max(data_points)
     31pmin = min(data_points)
     32
     33M = len(data_points)
     34
     35N = int(0.8*sqrt(M))
     36
     37#print N
     38
     39mesh_points, vertices, boundary = rectangular(N, N,
     40                                              len1=pmax[0]-pmin[0],
     41                                              len2=pmax[1]-pmin[1],
     42                                              origin = pmin)
     43                                             
     44
     45#Compute smooth surface on new mesh based on values from old (regrid)
     46print 'Interp'
     47interp = Interpolation(mesh_points, vertices, data_points, alpha=0.1)
     48mesh_values = interp.fit(data_values)
     49print 'Len mesh values', len(mesh_values)
     50print 'Len mesh points', len(mesh_points)
     51
     52   
    2353#Create shallow water domain
    24 domain = Domain(points, triangles)
    25    
     54print 'Creating domain'
     55domain = Domain(mesh_points, vertices) #, boundary)
     56
    2657domain.check_integrity()
    2758domain.default_order = 2
     
    4778
    4879print 'Field values'
    49 domain.set_quantity('elevation', values)
     80domain.set_quantity('elevation', mesh_values)
    5081domain.set_quantity('friction', manning)
    5182
Note: See TracChangeset for help on using the changeset viewer.