Ignore:
Timestamp:
Jun 9, 2005, 3:37:55 PM (19 years ago)
Author:
matthew
Message:

To avoid computing the flux function at each internal edge twice, we now call the C implementation of compute_fluxes with the extra integer vector argument already_computed_flux. This is an array of dimension (N,3) in python (or 3N in C) and thus each entry corresponds to a triangle-edge pair. If triangle t has neighbour n across its i-th edge, and this edge is the m-th edge of triangle n, then we update this edge's flux contribution to explicit_update for both triangle n and triangle t. Both corresponding entries of already_computed_flux will be incremented so that, when we come to edge m of triangle n, we know that the update across this edge has already been done.
The array already_computed_flux is defined and initialised to zero in domain.py.

For run_profile.py, with N=128, the version of compute_fluxes in which each edge was computed twice consumed 13.64 seconds (averaged over 3 runs). By keeping track of which edges have been computed, compute_fluxes now consumes 8.68 seconds.

File:
1 edited

Legend:

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

    r1506 r1508  
    2121                      tagged_elements, geo_reference, use_inscribed_circle)
    2222
    23         from Numeric import zeros, Float
     23        from Numeric import zeros, Float, Int
    2424        from quantity import Quantity, Conserved_quantity
    2525
     
    8585        self.checkpoint = False
    8686
     87        #MH310505 To avoid calculating the flux across each edge twice, keep an integer (boolean) array,
     88        #to be used during the flux calculation
     89        N=self.number_of_elements
     90        self.already_computed_flux = zeros((N, 3), Int)
    8791
    8892    #Public interface to Domain
Note: See TracChangeset for help on using the changeset viewer.