tskip fixed contact pairs correctly, add more tests - 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 6204c8ac361eeb4c3bee652eac20975622c7bd71
 (DIR) parent 0a7bd6d1abc511f73270af2c77a3090900105b3a
 (HTM) Author: Anders Damsgaard <andersd@riseup.net>
       Date:   Mon,  1 May 2017 13:48:35 -0400
       
       skip fixed contact pairs correctly, add more tests
       
       Diffstat:
         M examples/nares_strait.jl            |       3 ++-
         M src/contact_search.jl               |      14 +++++++-------
         M test/contact-search-and-geometry.jl |      32 +++++++++++++++++++++++++++++++
       
       3 files changed, 41 insertions(+), 8 deletions(-)
       ---
 (DIR) diff --git a/examples/nares_strait.jl b/examples/nares_strait.jl
       t@@ -9,7 +9,8 @@ Lx_constriction = Lx*.25
        L = [Lx, Lx*1.5, 1e3]
        Ly_constriction = L[2]*.33
        #n = [100, 100, 2]
       -n = [50, 50, 2]
       +#n = [50, 50, 2]
       +n = [25, 25, 2]
        sim.ocean = SeaIce.createRegularOceanGrid(n, L, name="poiseuille_flow")
        sim.ocean.v[:, :, 1, 1] = 1e-8*((sim.ocean.xq - Lx/2.).^2 - Lx^2./4.)
        
 (DIR) diff --git a/src/contact_search.jl b/src/contact_search.jl
       t@@ -60,8 +60,8 @@ function findContactsAllToAll!(simulation::Simulation)
                for j = 1:length(simulation.ice_floes)
                    if i < j
        
       -                if simulation.ice_floes[i].fixed &&
       -                    simulation.ice_floes[j].fixed ||
       +                if (simulation.ice_floes[i].fixed &&
       +                    simulation.ice_floes[j].fixed) ||
                            !simulation.ice_floes[i].enabled ||
                            !simulation.ice_floes[j].enabled
                            continue
       t@@ -107,11 +107,11 @@ function findContactsOceanGrid!(simulation::Simulation)
                        for idx_j in simulation.ocean.ice_floe_list[i, j]
        
                            if idx_i < idx_j
       -                        if simulation.ice_floes[i].fixed &&
       -                            simulation.ice_floes[j].fixed ||
       -                            !simulation.ice_floes[i].enabled ||
       -                            !simulation.ice_floes[j].enabled
       -                            continue
       +
       +                        if (simulation.ice_floes[idx_i].fixed &&
       +                            simulation.ice_floes[idx_j].fixed) ||
       +                            !simulation.ice_floes[idx_i].enabled ||
       +                            !simulation.ice_floes[idx_j].enabled
                                end
        
                                # Inter-grain position vector and grain overlap
 (DIR) diff --git a/test/contact-search-and-geometry.jl b/test/contact-search-and-geometry.jl
       t@@ -30,6 +30,16 @@ info("Testing findContacts(...)")
        sim = deepcopy(sim_copy)
        SeaIce.findContacts!(sim)
        
       +sim.ice_floes[1].fixed = true
       +@test 1 == length(sim.overlaps)
       +@test 1 == length(sim.contact_pairs)
       +@test_approx_eq [1, 2] sim.contact_pairs[1]
       +@test_approx_eq [-2., 0.] sim.overlaps[1]
       +
       +info("Testing findContacts(...)")
       +sim = deepcopy(sim_copy)
       +SeaIce.findContacts!(sim)
       +
        @test 1 == length(sim.overlaps)
        @test 1 == length(sim.contact_pairs)
        @test_approx_eq [1, 2] sim.contact_pairs[1]
       t@@ -67,6 +77,28 @@ SeaIce.findContactsOceanGrid!(sim)
        @test_approx_eq [1, 2] sim.contact_pairs[1]
        @test_approx_eq [-2., 0.] sim.overlaps[1]
        
       +sim = deepcopy(sim_copy)
       +sim.ocean = SeaIce.createRegularOceanGrid([4, 4, 2], [80., 80., 2.])
       +sim.ice_floes[1].fixed = true
       +SeaIce.sortIceFloesInOceanGrid!(sim)
       +SeaIce.findContactsOceanGrid!(sim)
       +
       +@test 1 == length(sim.overlaps)
       +@test 1 == length(sim.contact_pairs)
       +@test_approx_eq [1, 2] sim.contact_pairs[1]
       +@test_approx_eq [-2., 0.] sim.overlaps[1]
       +
       +sim = deepcopy(sim_copy)
       +sim.ocean = SeaIce.createRegularOceanGrid([4, 4, 2], [80., 80., 2.])
       +sim.ice_floes[1].fixed = true
       +sim.ice_floes[2].fixed = true
       +println(length(sim.ice_floes))
       +SeaIce.sortIceFloesInOceanGrid!(sim)
       +SeaIce.findContactsOceanGrid!(sim)
       +
       +@test 0 == length(sim.overlaps)
       +@test 0 == length(sim.contact_pairs)
       +
        info("Testing findContacts(...)")
        sim = deepcopy(sim_copy)
        sim.ocean = SeaIce.createRegularOceanGrid([4, 4, 2], [80., 80., 2.])