Changeset 7589


Ignore:
Timestamp:
Dec 10, 2009, 12:29:22 PM (14 years ago)
Author:
ole
Message:

Removed interpolation and brought run time down from 20+ seconds to < 1 second

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/development/classroom/ripcurrent.py

    r7588 r7589  
    175175#------------------------------------------------------------------------------
    176176
    177 # Read in gauge locations for interpolation and convert them to floats
    178 gauge_file = open('New_gauges.csv', 'r')
    179 G = [(float(x[0]), float(x[1])) for x in csv.reader(gauge_file,
    180                                                     dialect='excel',
    181                                                     delimiter=',')]
    182 gauges = numpy.array(G)
    183 number_of_gauges = len(gauges)
    184 
    185177# Allocate space for velocity values
    186 u = numpy.zeros(number_of_gauges)
    187 v = numpy.zeros(number_of_gauges)
     178u = numpy.zeros(len(domain))
     179v = numpy.zeros(len(domain))
    188180
    189181t0 = time.time()
    190182for t in domain.evolve(yieldstep = timestep, finaltime = simulation_length):
    191183    print domain.timestepping_statistics()
    192     S = domain.get_quantity('stage').get_values(interpolation_points=gauges)
    193     E = domain.get_quantity('elevation').get_values(interpolation_points=gauges)
     184   
     185    S = domain.get_quantity('stage').get_values(location='centroids')
     186    E = domain.get_quantity('elevation').get_values(location='centroids')
    194187    depth = S-E
    195188
    196     uh = domain.get_quantity('xmomentum').get_values(interpolation_points=gauges)
    197     vh = domain.get_quantity('ymomentum').get_values(interpolation_points=gauges)
     189    uh = domain.get_quantity('xmomentum').get_values(location='centroids')
     190    vh = domain.get_quantity('ymomentum').get_values(location='centroids')
    198191    u += uh/depth
    199192    v += vh/depth
     
    207200print 'There were %i time steps' % n_time_intervals
    208201
     202nodes = domain.get_nodes()
     203
     204X = nodes[:,0]
     205Y = nodes[:,1]
    209206U = u/n_time_intervals
    210207V = v/n_time_intervals
    211 X = gauges[:,0]
    212 Y = gauges[:,1]
    213 
    214208
    215209print 'Computation took %.2f seconds' % (time.time()-t0)
Note: See TracChangeset for help on using the changeset viewer.