tfirst check previous grid position during ice floe grid sorting - Granular.jl - Julia package for granular dynamics simulation
 (HTM) git clone git://src.adamsgaard.dk/Granular.jl
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 9f6b79535d4c51ac755a88255173c5382d54d4d8
 (DIR) parent 29d74ee0276bec09dd8593645f4668907539eb2f
 (HTM) Author: Anders Damsgaard <andersd@riseup.net>
       Date:   Fri, 12 May 2017 16:48:30 -0400
       
       first check previous grid position during ice floe grid sorting
       
       Diffstat:
         M src/grid.jl                         |      32 +++++++++++++++++++++----------
       
       1 file changed, 22 insertions(+), 10 deletions(-)
       ---
 (DIR) diff --git a/src/grid.jl b/src/grid.jl
       t@@ -88,17 +88,29 @@ function sortIceFloesInOceanGrid!(simulation::Simulation; verbose=false)
                    continue
                end
        
       -        i, j = findCellContainingPoint(simulation.ocean,
       -                                       simulation.ice_floes[idx].lin_pos)
       +        # After first iteration, check if ice floe is in same cell before 
       +        # traversing entire grid
       +        i_old, j_old = simulation.ice_floes[idx].ocean_grid_pos
       +        if simulation.time > 0. &&
       +            i_old > 0 && j_old > 0 &&
       +            isPointInCell(simulation.ocean, i_old, j_old,
       +                         simulation.ice_floes[idx].lin_pos)
       +            i = i_old
       +            j = j_old
        
       -        # remove ice floe if it is outside of the grid
       -        if i == 0 && j == 0
       -            disableIceFloe!(simulation, idx)
       -            continue
       -        end
       +        else
       +            i, j = findCellContainingPoint(simulation.ocean,
       +                                           simulation.ice_floes[idx].lin_pos)
        
       -        # add cell to ice floe
       -        simulation.ice_floes[idx].ocean_grid_pos = [i, j]
       +            # remove ice floe if it is outside of the grid
       +            if i == 0 && j == 0
       +                disableIceFloe!(simulation, idx)
       +                continue
       +            end
       +
       +            # add cell to ice floe
       +            simulation.ice_floes[idx].ocean_grid_pos = [i, j]
       +        end
        
                # add ice floe to cell
                push!(simulation.ocean.ice_floe_list[i, j], idx)
       t@@ -157,7 +169,7 @@ conformal mapping approach (`method = "Conformal"`).  The area-based approach is
        more robust.  This function returns `true` or `false`.
        """
        function isPointInCell(ocean::Ocean, i::Int, j::Int, point::Array{float, 1};
       -                       method::String="Area")
       +                       method::String="Conformal")
        
            sw, se, ne, nw = getCellCornerCoordinates(ocean, i, j)