tautomatically turn on sorting optimizations if grids are identical - 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 272496b31ba1ba7d932c60ad77974c0f94bca3fe
 (DIR) parent e9251cfbec42e68b3bba195c3629726ff62a1170
 (HTM) Author: Anders Damsgaard <andersd@riseup.net>
       Date:   Mon, 19 Jun 2017 11:55:50 -0400
       
       automatically turn on sorting optimizations if grids are identical
       
       Diffstat:
         M src/simulation.jl                   |      17 +++++++++++++++++
         M test/grid.jl                        |       5 +++--
       
       2 files changed, 20 insertions(+), 2 deletions(-)
       ---
 (DIR) diff --git a/src/simulation.jl b/src/simulation.jl
       t@@ -93,6 +93,23 @@ function run!(simulation::Simulation;
        
            checkTimeParameters(simulation)
        
       +    # if both are enabled, check if the atmosphere grid spatial geometry is 
       +    # identical to the ocean grid
       +    if simulation.time_iteration == 0 &&
       +        typeof(simulation.atmosphere.input_file) != Bool &&  
       +        typeof(simulation.ocean.input_file) != Bool
       +
       +        if simulation.ocean.xq ≈ simulation.atmosphere.xq &&
       +            simulation.ocean.yq ≈ simulation.atmosphere.yq
       +            if verbose
       +                info("identical ocean and atmosphere grids, turning on " * 
       +                     "optimizations")
       +            end
       +            simulation.atmosphere.collocated_with_ocean_grid = true
       +        end
       +    end
       +
       +
            # number of time steps between output files
            n_file_time_step = Int(ceil(simulation.file_time_step/simulation.time_step))
        
 (DIR) diff --git a/test/grid.jl b/test/grid.jl
       t@@ -262,7 +262,7 @@ pos = SeaIce.findEmptyPositionInGridCell(sim, sim.ocean, 2, 2, 0.5,
        info("Test default sorting with ocean/atmosphere grids")
        sim = SeaIce.createSimulation()
        sim.ocean = SeaIce.createRegularOceanGrid([4, 4, 2], [4., 4., 2.])
       -sim.atmosphere = SeaIce.createRegularAtmosphereGrid([4, 4, 2], [4., 4., 2.])
       +sim.atmosphere = SeaIce.createRegularAtmosphereGrid([4, 4, 2], [4., 4.000001, 2.])
        SeaIce.addIceFloeCylindrical(sim, [0.5, 0.5], .1, 1., verbose=verbose)
        SeaIce.addIceFloeCylindrical(sim, [0.7, 0.7], .1, 1., verbose=verbose)
        SeaIce.addIceFloeCylindrical(sim, [2.6, 2.5], .1, 1., verbose=verbose)
       t@@ -270,6 +270,7 @@ SeaIce.sortIceFloesInGrid!(sim, sim.ocean, verbose=verbose)
        SeaIce.setTimeStep!(sim)
        SeaIce.setTotalTime!(sim, 1.0)
        SeaIce.run!(sim, single_step=true, verbose=verbose)
       +@test sim.atmosphere.collocated_with_ocean_grid == false
        @test sim.ice_floes[1].ocean_grid_pos == [1, 1]
        @test sim.ice_floes[2].ocean_grid_pos == [1, 1]
        @test sim.ice_floes[3].ocean_grid_pos == [3, 3]
       t@@ -287,7 +288,6 @@ info("Test optimization when ocean/atmosphere grids are collocated")
        sim = SeaIce.createSimulation()
        sim.ocean = SeaIce.createRegularOceanGrid([4, 4, 2], [4., 4., 2.])
        sim.atmosphere = SeaIce.createRegularAtmosphereGrid([4, 4, 2], [4., 4., 2.])
       -sim.atmosphere.collocated_with_ocean_grid = true
        SeaIce.addIceFloeCylindrical(sim, [0.5, 0.5], .1, 1., verbose=verbose)
        SeaIce.addIceFloeCylindrical(sim, [0.7, 0.7], .1, 1., verbose=verbose)
        SeaIce.addIceFloeCylindrical(sim, [2.6, 2.5], .1, 1., verbose=verbose)
       t@@ -295,6 +295,7 @@ SeaIce.sortIceFloesInGrid!(sim, sim.ocean, verbose=verbose)
        SeaIce.setTimeStep!(sim)
        SeaIce.setTotalTime!(sim, 1.0)
        SeaIce.run!(sim, single_step=true, verbose=verbose)
       +@test sim.atmosphere.collocated_with_ocean_grid == true
        @test sim.ice_floes[1].ocean_grid_pos == [1, 1]
        @test sim.ice_floes[2].ocean_grid_pos == [1, 1]
        @test sim.ice_floes[3].ocean_grid_pos == [3, 3]